Author Topic: Inner Classes - major inconsistency  (Read 5851 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8195
  • Karma: +232/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Inner Classes - major inconsistency
« on: August 15, 2005, 07:11:51 am »
When is an inner class not an inner class?
When it's connected to the parent class by a nesting relationship!

Create a class, create another class, link the first to the second via a nesting relationship.  Try to generate code for the "nested" (inner) class.  The UI will (correctly) tell you: "Generation of code for inner classes is only supported through generating the outer class"

Generate code for the outer calls, and the inner class is generated... So far so good.

The problem is that if you get a list of inner elements via the automation interface, this inner class is not listed.

Now, before I report this as a bug, can anyone confirm that (in their view) the nested class should be treated as a more normally created inner class.

Also, even for normal inner classes, they are exposed both as a class of their own and as an inner class.  As I'm emitting this information under my control, do people think I should repeat the class information or make the inner class a link to the other copy of the class.

(Recall that if we accept the nesting relationship, the linked class may be in an entirely different part of the model and may not be in the set of classes to be emitted)

Also, since it is possible to nest a class in more than one parent what does that do to things?

Cheerz,
Paolo
« Last Edit: August 15, 2005, 07:13:56 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Inner Classes - major inconsistency
« Reply #1 on: August 15, 2005, 04:02:06 pm »
Quote
Also, since it is possible to nest a class in more than one parent what does that do to things?
Youch!  I've never tried that one.

Paolo,
I have no answers to your questions, I just want to add another one.

Why use inner classes?  I mean, I use them but its always been a naturally "obvious" situation. Is there some design / architecture framework for recognizing that a class should be implemented as an inner?

bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8195
  • Karma: +232/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inner Classes - major inconsistency
« Reply #2 on: August 15, 2005, 04:28:02 pm »
Quote
[size=13][SNIP][/size]
Why use inner classes?  I mean, I use them but its always been a naturally "obvious" situation. Is there some design / architecture framework for recognizing that a class should be implemented as an inner?

bruce
Since I'm primarily a modeller rather than a programmer, I'm not sure I've got good answers for that one.  However, let me throw the question back to you.  Think about the times you've used them for obvious reasons, is there a pattern (or a very small numbers of patterns) that can account for your usage?

Paolo

BTW: what's the formal definition of an Inner Class.  Are they necessarily singletons (in the meta sense).  That is, if you use exactly the same class structure inside two or more parents, do you (by definition) no longer have an inner class?
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8195
  • Karma: +232/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inner Classes - major inconsistency
« Reply #3 on: August 15, 2005, 08:19:53 pm »
Quote
[size=13][SNIP][/size]
Why use inner classes?  I mean, I use them but its always been a naturally "obvious" situation. Is there some design / architecture framework for recognizing that a class should be implemented as an inner?

bruce
I found this in my ramblings...

Recommendations on Nested Classes in Components

As an extension to those recommendations, I think the operative reason for instantiating a class as an inner (or nested) class relates to whether the instance of the inner class can be moved to another enclosure (parent).  This gets back, in part to the World vs Business vs System model.  In the real world, a tyre can be moved between wheels - in the Conceptual (World) model I would model it as such - composition.  But if in the system I was building, I wanted to see the tyre (to see if it was punctured or not) but not to move it, the transformation/generation policy would say "Instance cannot be re-enclosed" and so the generator would implement as a nested class.  If the policy was "Instance cannot be re-enclosed" the generator would implement as a non nested class.

HTH,
Paolo
« Last Edit: August 15, 2005, 08:20:34 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!