Re: UML-ish question



Responding to Jhinchey...

I came across something on a UML class diagram today that I have never
seen before and I'm wondering about the validity of it. The diagram
has a class which has an association with itself (a line coming out of
the class, making 2 90 degree turns and going back into itself).

Is that legal UML? If so, what does it mean? I think they are trying
to show an association between two instances of the class, which I
don't think belongs on the class diagram.

Yes, it is quite legal and fairly common. It is known as a reflexive relationship. The problem you are having is over the difference between static structure and individual participation in relationships.

For example, the organization of a POS web site's pages is typically in a hierarchical tree. One can express that very succinctly as:

[Web Site]
| 0..1
|
| R1
|
| rooted at
| 1 0..* parent of
[Page] ----------------+
| 0..1 |
| child of | R2
| |
+-------------------+

Basically this says that any web page fits into the hierarchy through child/parent relationships. The conditionality just reflects that leaf Pages don't have children and the root Page doesn't have a parent. [In a real POS web site one would probably use a more complex structure that would eliminate the conditionality, but this is just an example.]

The reason that this is valid is because the relationship defines that static structure of individual relationships between [Page] objects, but it doesn't describe who the objects are related to on an individual basis. So your second paragraph is close to the justification; it is instance based. For example, in a real POS site the tree might look like:

[Home]
/ \
/ \
[Computers] [Books]
/ \ / \
/ \ / \
[Laptops] [Desktops] [Fiction] [Nonfiction]

Here I am representing Page identity in the brackets, rather than classes. Thus every [...] represents a specific [Page] object.

The parent of [Computers] and [Books] happens to be [Home] in both cases here, but that would usually not be true for a tree with more levels. However, the children of [Computers] are entirely different pages than the children of [Books]. Thus at the level of the Computers and Books objects, their participation in the static structure is quite different.

So at the instance level the relationships have different participants. But all Pages participate in the same parent/child relationship structure.


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
(888)OOA-PATH



.



Relevant Pages

  • Re: Diff b/w factory pattern and strategy pattern
    ... >tool will use a diagram as a single expression of the data, ... If we use a tool to create a "model" of the static structure of our ... The Bowling game example begins with an Object Oriented Design in UML ... We may be measuring some technical aspect of the system (e.g. ...
    (comp.object)
  • Re: In book,Use case diagram is static or dynamic view? (for UML)
    ... The Unified Modeling Language User Guide ... This just means that a Use Case Diagram just captures the static structural relationships among use cases, actors, etc. ... The Use Case Diagram only describes static structure, not the dynamics of individual use case content. ...
    (comp.object)