Tuesday, December 9, 2014


A nightmare of confusion.

Recent time with Clique Space(TM) has dragged me into the dependency nightmare that is Java generics; a nightmare from which I might be awakening.

Clique Space code comes in two halves. The chassis is the basic Clique Space data structure definitions and implementation of functionality in relation to the sending and receiving of transmitters while the top half is the body of the specific implementation of a Clique Space aware device.

The halves are separated by a set of parameterised types that make the cute acronym disclosed in the title of this blog entry. The specific device implementation's body "clips on" to the generic chassis. Hence, the chassis defines these generic parameters, and the body completes their implementation. The terms used in the acronym are as follows:
  • CL - The basic Clique structure and mechanisms contained therein.
  • I - The Identity structure and mechanisms contained therein.
  • P - The basic Participant structure and mechanisms contained therein.
  • O - A more specific Participant structure relating to Owner Participants of synapses and involvements.
  • N - A more specific Participant structure relating to non-Owner Participants of synapses and involvements.
The acronym using the first three of these parameterisations has been around for a while. The final two types needed to be added to or "clipped on" the end of the fist three because I wanted a way to discriminate between the Owner and non-Owner Participants of a synapse or a service or viscera as involvements. One of the prime benefits of using generics is that one can check types at compile time, thereby reducing the size of one's code (not having to guard run time type casting) and ensuring one's code has fewer bugs.

Hence, these extra two types (O and N) are used to ensure that an Owner Participant is returned where an Owner Particpant is expected and a non-Owner Participant is likewise returned when expected. This type of discrimination is important in cases where structures derived from the basic Clique (the synapse, the service, and the viscera) are being manipulated. These specific Clique structures have extra functionality because this extra functionality helps a Clique space do the things I intend it to do.

A thing of beauty.

No comments:

Post a Comment