Sunday, December 4, 2011

The Undisclosed Element and the [Tendrils] of Code Coupling.

I'll disclose some code here. It's my code, so I'm free to do this. These code disclosures are meant to elicit interest and hopefully a response by people who may be interested in what I'm doing. That's the theory; I don't know the reader's mind, but one hopes the reader is one who has scruples enough to honour the fact that this idea is mine, and who will respect the fact that I have patented it.

This post, and the code disclosed therein demonstrate how complicated structural parameterisation can sometimes be; something of what some have come to see as a nuisance about Java. Java parameterises classes and interfaces through a mechanism called generic declarations. There's a lot about what a generic declaration is, so I'll leave it to the curious - but hitherto ignorant - reader to discover this wonderland. However, I need to put the mechanism into context here: generics bind one Java element (object, class, interface) to one or more others. When a class or interface is declared with a generic declaration that refers to another class or interface, objects of both classes or interfaces are bound by a "contract" which depends on some mutually recognised generic property.

Now, all this means that one or more objects is being structurally bound to others - increasing the objects' degree of coupling. This doesn't appeal to purist doctrine but there are plenty of times where this structural binding is absolutely necessary. My seven-Element (to be six-Element eventually - but that's another story) Client Device structure is one of these times.

The Client Device is loosely based around an arrangement of seven distinct, but related, Element types. At least one of each of these Element types are necessary to express one Client Device. Hence, one should be totally unsurprised to imagine that there would be a high degree of coupling between these Elements. Each element encapsulates a property of any device which is connected to a Clique Space(TM), so each Element describes only a part of the Client Device. Hence, the Client Device (the abstract representation of any device in Clique Space) and its constituent Elements is a prime component of the Clique Space concept. This particular Client Device mechanism was the epiphany I had in mid-2004 while jogging.

Working with generics in my implementation, I can see why some might become dismayed with what can sometimes become an intractable exercise that generates compile-time errors of sometimes frustratingly obscure origin. It almost seems that even a powerful IDE cannot help ease one's frustrations when it comes to getting code involving generics to compile. The relationships generics create do not appear to me to have an easily way to be visualised, so one really has to be careful and patient when one has to manage generic relationships between approximately 30 classes and interfaces - a structure not only as described, but a whole structure of subinterfaces, and their implementations for Elements as they manifest on the administrator Client Device, and the Agent Device.

Still, if one exercises patience against a solid application model defined around a clear concept, one can navigate through what may seem like a maze of these coupling relationships.

The massaged code snippet that I disclose is of a class called an undisclosed Element. This class is intended to be a substitute on the Client Device for situations where information about projected Elements and their identifiers is known to be missing, and this information cannot appear on the device's View, or persisted to a device activity audit log. Hence, the undisclosed Element and its identifier are used as place-holders whenever an Element or its identifier are known not to be projected. Instances of non disclosure could be the result of a lack of Limiting Constraint affinity between the user doing the viewing and the user being viewed, or if the user of a device collaborating with others isn't themselves connected to the same Clique Space or a federated neighbour Clique Space capable of sharing information about the user being viewed, or where the operator of the serving Agent Device to which the View device is connected has insufficient Limiting Constraint affinity; even though the operator of the View device may themselves, have sufficient affinity.

Instances where Elements might not be disclosed include, say, a user who lets you know what device they're using, and how they're using it, but not who they are (one can see that the Active Affiliation, Connection, Affiliation, Account Profile, and Media Profile are disclosed, but no Account has been likewise disclosed). At other times, say, a user may let you know who they are when you're letting them know who you are in some situations. In these cases, the Account may be disclosed for times when the particular user lets you know who they are, but in situations where they don't, an identifier relating neither the connection nor affiliation to their account will be likewise disclosed. So near, yet so far... and so very flexible.

In any situations where partial or non disclosure of Elements is apparent, the Client Device substitutes its undisclosed Element. This Element must have an interface that is compatible with every type of Element. It must therefore be structurally coupled to each Element's interface, expressing specific behaviour of the undisclosed Element which is compatible with all of the other disclosed Elements in terms of how a particular undisclosed Element's type is represented.

So, here it is in all its syntactic glory - a compromise to accommodate the apparent limitations of this web log. I also think HTML is a distraction that is not worthy of me.
 39 /**
40 *
41 * @author owen
42 */
43 public class UndisclosedElement
44 extends NonLocalElementImpl<
45 NonLocalCliqueSpace<
46 ?extends NonLocalElement,
47 ?extends NonLocalAccount,
48 ?extends NonLocalAccountProfile,
49 ?extends NonLocalAccountProfileRoot,
50 ?extends NonLocalMediaProfile,
51 ?extends NonLocalMediaProfileRoot,
52 ?extends NonLocalAffiliation,
53 ?extends NonLocalActiveAffiliation,
54 ?extends NonLocalClique>,
55 UndisclosedIdentifier,
56 IdentifierTransmitter,
57 ElementToken>
58 implements
59 NonLocalAccount<
60 NonLocalCliqueSpace<
61 ?extends NonLocalElement,
62 ?extends NonLocalAccount,
63 ?extends NonLocalAccountProfile,
64 ?extends NonLocalAccountProfileRoot,
65 ?extends NonLocalMediaProfile,
66 ?extends NonLocalMediaProfileRoot,
67 ?extends NonLocalAffiliation,
68 ?extends NonLocalActiveAffiliation,
69 ?extends NonLocalClique>,
70 UndisclosedIdentifier,
71 IdentifierTransmitter,
72 ElementToken,
73 NonLocalAccountProfileNode<
74 ?extends NonLocalCliqueSpace,
75 ?extends AccountProfileNodeIdentifier,
76 ?extends IdentifierTransmitter,
77 ?extends ElementToken,
78 ?extends NonLocalAccount,
79 ?extends NonLocalAffiliation,
80 ?extends NonLocalAccountProfile>,
81 NonLocalMediaProfileNode<
82 ?extends NonLocalCliqueSpace,
83 ?extends MediaProfileNodeIdentifier,
84 ?extends IdentifierTransmitter,
85 ?extends ElementToken,
86 ?extends NonLocalAccount,
87 ?extends NonLocalConnection,
88 ?extends NonLocalMediaProfile>,
89 NonLocalAffiliation<
90 ?extends NonLocalCliqueSpace,
91 ?extends AffiliationIdentifier,
92 ?extends IdentifierTransmitter,
93 ?extends ElementToken,
94 ?extends NonLocalAccount,
95 ?extends NonLocalAccountProfileNode,
96 ?extends NonLocalActiveAffiliation>,
97 NonLocalConnection<
98 ?extends NonLocalCliqueSpace,
99 ?extends ConnectionIdentifier,
100 ?extends IdentifierTransmitter,
101 ?extends ElementToken,
102 ?extends NonLocalAccount,
103 ?extends NonLocalMediaProfileNode,
104 ?extends NonLocalActiveAffiliation>>,
105 NonLocalAccountProfile<
106 NonLocalCliqueSpace<
107 ?extends NonLocalElement,
108 ?extends NonLocalAccount,
109 ?extends NonLocalAccountProfile,
110 ?extends NonLocalAccountProfileRoot,
111 ?extends NonLocalMediaProfile,
112 ?extends NonLocalMediaProfileRoot,
113 ?extends NonLocalAffiliation,
114 ?extends NonLocalActiveAffiliation,
115 ?extends NonLocalClique>,
116 UndisclosedIdentifier,
117 IdentifierTransmitter,
118 ElementToken,
119 NonLocalAccount<
120 ?extends NonLocalCliqueSpace,
121 ?extends AccountIdentifier,
122 ?extends IdentifierTransmitter,
123 ?extends ElementToken,
124 ?extends NonLocalAccountProfileNode,
125 ?extends NonLocalMediaProfileNode,
126 ?extends NonLocalAffiliation,
127 ?extends NonLocalConnection>,
128 NonLocalAffiliation<
129 ?extends NonLocalCliqueSpace,
130 ?extends AffiliationIdentifier,
131 ?extends IdentifierTransmitter,
132 ?extends ElementToken,
133 ?extends NonLocalAccount,
134 ?extends NonLocalAccountProfileNode,
135 ?extends NonLocalActiveAffiliation>>,
136 NonLocalAccountProfileNode<
137 NonLocalCliqueSpace<
138 ?extends NonLocalElement,
139 ?extends NonLocalAccount,
140 ?extends NonLocalAccountProfile,
141 ?extends NonLocalAccountProfileRoot,
142 ?extends NonLocalMediaProfile,
143 ?extends NonLocalMediaProfileRoot,
144 ?extends NonLocalAffiliation,
145 ?extends NonLocalActiveAffiliation,
146 ?extends NonLocalClique>,
147 UndisclosedIdentifier,
148 IdentifierTransmitter,
149 ElementToken,
150 NonLocalAccount<
151 ?extends NonLocalCliqueSpace,
152 ?extends AccountIdentifier,
153 ?extends IdentifierTransmitter,
154 ?extends ElementToken,
155 ?extends NonLocalAccountProfileNode,
156 ?extends NonLocalMediaProfileNode,
157 ?extends NonLocalAffiliation,
158 ?extends NonLocalConnection>,
159 NonLocalAffiliation<
160 ?extends NonLocalCliqueSpace,
161 ?extends AffiliationIdentifier,
162 ?extends IdentifierTransmitter,
163 ?extends ElementToken,
164 ?extends NonLocalAccount,
165 ?extends NonLocalAccountProfileNode,
166 ?extends NonLocalActiveAffiliation>,
167 NonLocalAccountProfile<
168 ?extends NonLocalCliqueSpace,
169 ?extends AccountProfileIdentifier,
170 ?extends IdentifierTransmitter,
171 ?extends ElementToken,
172 ?extends NonLocalAccount,
173 ?extends NonLocalAffiliation>>,
174 NonLocalAccountProfileRoot<
175 NonLocalCliqueSpace<
176 ?extends NonLocalElement,
177 ?extends NonLocalAccount,
178 ?extends NonLocalAccountProfile,
179 ?extends NonLocalAccountProfileRoot,
180 ?extends NonLocalMediaProfile,
181 ?extends NonLocalMediaProfileRoot,
182 ?extends NonLocalAffiliation,
183 ?extends NonLocalActiveAffiliation,
184 ?extends NonLocalClique>,
185 UndisclosedIdentifier,
186 IdentifierTransmitter,
187 ElementToken,
188 NonLocalAccount<
189 ?extends NonLocalCliqueSpace,
190 ?extends AccountIdentifier,
191 ?extends IdentifierTransmitter,
192 ?extends ElementToken,
193 ?extends NonLocalAccountProfileNode,
194 ?extends NonLocalMediaProfileNode,
195 ?extends NonLocalAffiliation,
196 ?extends NonLocalConnection>,
197 NonLocalAffiliation<
198 ?extends NonLocalCliqueSpace,
199 ?extends AffiliationIdentifier,
200 ?extends IdentifierTransmitter,
201 ?extends ElementToken,
202 ?extends NonLocalAccount,
203 ?extends NonLocalAccountProfileNode,
204 ?extends NonLocalActiveAffiliation>>,
205 NonLocalActiveAffiliation<
206 NonLocalCliqueSpace<
207 ?extends NonLocalElement,
208 ?extends NonLocalAccount,
209 ?extends NonLocalAccountProfile,
210 ?extends NonLocalAccountProfileRoot,
211 ?extends NonLocalMediaProfile,
212 ?extends NonLocalMediaProfileRoot,
213 ?extends NonLocalAffiliation,
214 ?extends NonLocalActiveAffiliation,
215 ?extends NonLocalClique>,
216 UndisclosedIdentifier,
217 IdentifierTransmitter,
218 ElementToken,
219 NonLocalAffiliation<
220 ?extends NonLocalCliqueSpace,
221 ?extends AffiliationIdentifier,
222 ?extends IdentifierTransmitter,
223 ?extends ElementToken,
224 ?extends NonLocalAccount,
225 ?extends NonLocalAccountProfileNode,
226 ?extends NonLocalActiveAffiliation>,
227 NonLocalConnection<
228 ?extends NonLocalCliqueSpace,
229 ?extends ConnectionIdentifier,
230 ?extends IdentifierTransmitter,
231 ?extends ElementToken,
232 ?extends NonLocalAccount,
233 ?extends NonLocalMediaProfileNode,
234 ?extends NonLocalActiveAffiliation>,
235 NonLocalParticipant<
236 ?extends NonLocalCliqueSpace,
237 ?extends ParticipantIdentifier,
238 ?extends IdentifierTransmitter,
239 ?extends ElementToken,
240 ?extends NonLocalActiveAffiliation,
241 ?extends NonLocalClique>>,
242 NonLocalAffiliation<
243 NonLocalCliqueSpace<
244 ?extends NonLocalElement,
245 ?extends NonLocalAccount,
246 ?extends NonLocalAccountProfile,
247 ?extends NonLocalAccountProfileRoot,
248 ?extends NonLocalMediaProfile,
249 ?extends NonLocalMediaProfileRoot,
250 ?extends NonLocalAffiliation,
251 ?extends NonLocalActiveAffiliation,
252 ?extends NonLocalClique>,
253 UndisclosedIdentifier,
254 IdentifierTransmitter,
255 ElementToken,
256 NonLocalAccount<
257 ?extends NonLocalCliqueSpace,
258 ?extends AccountIdentifier,
259 ?extends IdentifierTransmitter,
260 ?extends ElementToken,
261 ?extends NonLocalAccountProfileNode,
262 ?extends NonLocalMediaProfileNode,
263 ?extends NonLocalAffiliation,
264 ?extends NonLocalConnection>,
265 NonLocalAccountProfileNode<
266 ?extends NonLocalCliqueSpace,
267 ?extends AccountProfileNodeIdentifier,
268 ?extends IdentifierTransmitter,
269 ?extends ElementToken,
270 ?extends NonLocalAccount,
271 ?extends NonLocalAffiliation,
272 ?extends NonLocalAccountProfile>,
273 NonLocalActiveAffiliation<
274 ?extends NonLocalCliqueSpace,
275 ?extends ActiveAffiliationIdentifier,
276 ?extends IdentifierTransmitter,
277 ?extends ElementToken,
278 ?extends NonLocalAffiliation,
279 ?extends NonLocalConnection,
280 ?extends NonLocalParticipant>>,
281 NonLocalConnection<
282 NonLocalCliqueSpace<
283 ?extends NonLocalElement,
284 ?extends NonLocalAccount,
285 ?extends NonLocalAccountProfile,
286 ?extends NonLocalAccountProfileRoot,
287 ?extends NonLocalMediaProfile,
288 ?extends NonLocalMediaProfileRoot,
289 ?extends NonLocalAffiliation,
290 ?extends NonLocalActiveAffiliation,
291 ?extends NonLocalClique>,
292 UndisclosedIdentifier,
293 IdentifierTransmitter,
294 ElementToken,
295 NonLocalAccount<
296 ?extends NonLocalCliqueSpace,
297 ?extends AccountIdentifier,
298 ?extends IdentifierTransmitter,
299 ?extends ElementToken,
300 ?extends NonLocalAccountProfileNode,
301 ?extends NonLocalMediaProfileNode,
302 ?extends NonLocalAffiliation,
303 ?extends NonLocalConnection>,
304 NonLocalMediaProfileNode<
305 ?extends NonLocalCliqueSpace,
306 ?extends MediaProfileNodeIdentifier,
307 ?extends IdentifierTransmitter,
308 ?extends ElementToken,
309 ?extends NonLocalAccount,
310 ?extends NonLocalConnection,
311 ?extends NonLocalMediaProfile>,
312 NonLocalActiveAffiliation<
313 ?extends NonLocalCliqueSpace,
314 ?extends ActiveAffiliationIdentifier,
315 ?extends IdentifierTransmitter,
316 ?extends ElementToken,
317 ?extends NonLocalAffiliation,
318 ?extends NonLocalConnection,
319 ?extends NonLocalParticipant>>,
320 NonLocalMediaProfile<
321 NonLocalCliqueSpace<
322 ?extends NonLocalElement,
323 ?extends NonLocalAccount,
324 ?extends NonLocalAccountProfile,
325 ?extends NonLocalAccountProfileRoot,
326 ?extends NonLocalMediaProfile,
327 ?extends NonLocalMediaProfileRoot,
328 ?extends NonLocalAffiliation,
329 ?extends NonLocalActiveAffiliation,
330 ?extends NonLocalClique>,
331 UndisclosedIdentifier,
332 IdentifierTransmitter,
333 ElementToken,
334 NonLocalAccount<
335 ?extends NonLocalCliqueSpace,
336 ?extends AccountIdentifier,
337 ?extends IdentifierTransmitter,
338 ?extends ElementToken,
339 ?extends NonLocalAccountProfileNode,
340 ?extends NonLocalMediaProfileNode,
341 ?extends NonLocalAffiliation,
342 ?extends NonLocalConnection>,
343 NonLocalConnection<
344 ?extends NonLocalCliqueSpace,
345 ?extends ConnectionIdentifier,
346 ?extends IdentifierTransmitter,
347 ?extends ElementToken,
348 ?extends NonLocalAccount,
349 ?extends NonLocalMediaProfileNode,
350 ?extends NonLocalActiveAffiliation>>,
351 NonLocalMediaProfileRoot<
352 NonLocalCliqueSpace<
353 ?extends NonLocalElement,
354 ?extends NonLocalAccount,
355 ?extends NonLocalAccountProfile,
356 ?extends NonLocalAccountProfileRoot,
357 ?extends NonLocalMediaProfile,
358 ?extends NonLocalMediaProfileRoot,
359 ?extends NonLocalAffiliation,
360 ?extends NonLocalActiveAffiliation,
361 ?extends NonLocalClique>,
362 UndisclosedIdentifier,
363 IdentifierTransmitter,
364 ElementToken,
365 NonLocalAccount<
366 ?extends NonLocalCliqueSpace,
367 ?extends AccountIdentifier,
368 ?extends IdentifierTransmitter,
369 ?extends ElementToken,
370 ?extends NonLocalAccountProfileNode,
371 ?extends NonLocalMediaProfileNode,
372 ?extends NonLocalAffiliation,
373 ?extends NonLocalConnection>,
374 NonLocalConnection<
375 ?extends NonLocalCliqueSpace,
376 ?extends ConnectionIdentifier,
377 ?extends IdentifierTransmitter,
378 ?extends ElementToken,
379 ?extends NonLocalAccount,
380 ?extends NonLocalMediaProfileNode,
381 ?extends NonLocalActiveAffiliation>>,
382 NonLocalMediaProfileNode<
383 NonLocalCliqueSpace<
384 ?extends NonLocalElement,
385 ?extends NonLocalAccount,
386 ?extends NonLocalAccountProfile,
387 ?extends NonLocalAccountProfileRoot,
388 ?extends NonLocalMediaProfile,
389 ?extends NonLocalMediaProfileRoot,
390 ?extends NonLocalAffiliation,
391 ?extends NonLocalActiveAffiliation,
392 ?extends NonLocalClique>,
393 UndisclosedIdentifier,
394 IdentifierTransmitter,
395 ElementToken,
396 NonLocalAccount<
397 ?extends NonLocalCliqueSpace,
398 ?extends AccountIdentifier,
399 ?extends IdentifierTransmitter,
400 ?extends ElementToken,
401 ?extends NonLocalAccountProfileNode,
402 ?extends NonLocalMediaProfileNode,
403 ?extends NonLocalAffiliation,
404 ?extends NonLocalConnection>,
405 NonLocalConnection<
406 ?extends NonLocalCliqueSpace,
407 ?extends ConnectionIdentifier,
408 ?extends IdentifierTransmitter,
409 ?extends ElementToken,
410 ?extends NonLocalAccount,
411 ?extends NonLocalMediaProfileNode,
412 ?extends NonLocalActiveAffiliation>,
413 NonLocalMediaProfile<
414 ?extends NonLocalCliqueSpace,
415 ?extends MediaProfileIdentifier,
416 ?extends IdentifierTransmitter,
417 ?extends ElementToken,
418 ?extends NonLocalAccount,
419 ?extends NonLocalConnection>>,
420 NonLocalParticipant<
421 NonLocalCliqueSpace<
422 ?extends NonLocalElement,
423 ?extends NonLocalAccount,
424 ?extends NonLocalAccountProfile,
425 ?extends NonLocalAccountProfileRoot,
426 ?extends NonLocalMediaProfile,
427 ?extends NonLocalMediaProfileRoot,
428 ?extends NonLocalAffiliation,
429 ?extends NonLocalActiveAffiliation,
430 ?extends NonLocalClique>,
431 UndisclosedIdentifier,
432 IdentifierTransmitter,
433 ElementToken,
434 NonLocalActiveAffiliation<
435 ?extends NonLocalCliqueSpace,
436 ?extends ActiveAffiliationIdentifier,
437 ?extends IdentifierTransmitter,
438 ?extends ElementToken,
439 ?extends NonLocalAffiliation,
440 ?extends NonLocalConnection,
441 ?extends NonLocalParticipant>,
442 NonLocalClique<
443 ?extends NonLocalActiveAffiliation,
444 ?extends NonLocalCliqueSpace,
445 ?extends NonLocalParticipant>>
446 {

Etcetera...


700 }
I will not disclose the entire body of this class. You might find that a relief, but I will at least disclose one of the overridden methods which contains a not uncommonly long signature.
541     @Override
542 public AffiliationIdentifier[]getAffiliationIdentifiers(NonLocalAccountextends NonLocalCliqueSpace,?extends AccountIdentifier,
543 ?extends IdentifierTransmitter,?extends ElementToken,?extends NonLocalAccountProfileNode,?extends NonLocalMediaProfileNode,
544 ?extends NonLocalAffiliation,?extends NonLocalConnection>account,NonLocalCliqueSpaceextends NonLocalElement,?extends NonLocalAccount,
545 ?extends NonLocalAccountProfile,?extends NonLocalAccountProfileRoot,?extends NonLocalMediaProfile,?extends NonLocalMediaProfileRoot,
546 ?extends NonLocalAffiliation,?extends NonLocalActiveAffiliation,?extends NonLocalClique>cliqueSpace) throws CliqueSpaceException {
547 AffiliationIdentifier[]afia={this.getAffiliationIdentifier()};
548 return afia;
549 }

Indeed, it's a bit bewildering, but apparently necessary. If you observe the relationship between the definition of this undisclosed Element and all the other Elements given in the class declaration, the pattern shows that the concept is strong, uniform, consistent, and efficacious. At least, that's what I'm asserting. Likewise, I assert this class discloses a very small part of an implementation of a novel and unique concept.

4 comments:

  1. I find this blogger thing can be frustrating.

    I've done my best...

    ReplyDelete
  2. And there they are... 9 additional page views from the US. Maybe some time soon perhaps I'll know why.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Although it would be possible to write Clique Space in Java without parameterising classes and interfaces, parameterisation does afford me compile time type checking. Additionally, I love the fact that Java allows the programmer to parameterise an interface or a class with its own definition. Parameterisation in Java would be useless to me if this flavour of logical self-reference was not available.

    ReplyDelete