Sparx Systems Forum

Discussion => Uml Process => Topic started by: AC on September 22, 2004, 08:37:26 pm

Title: Class Diagrams - use of packages
Post by: AC on September 22, 2004, 08:37:26 pm
hi

I am still Leaning UML - can anyone help me with this question about class diagrams

can I group sub classes into a package and then have this package as a generalization of a class  - so on my diagram I will have :
a class
a Package containing the sub classes of the above class
a generalization arrow pointing to the class from the package ???
Title: Re: Class Diagrams - use of packages
Post by: sargasso on September 22, 2004, 11:29:24 pm
Mechanically, yes you can do it.

However, sematically it means nothing.  A package is a model management construct, not an implementable design.  Generalisation means that the child element will inherit the features of he parent - typically attributes and operations.  

The elements contained in the package are not children - in the inheritence sense - of the containing package.  That is they will not inherit the features of the class.

Without knowing what you are trying to communicate with your model I pose the folowing:

Are you trying to communicate some generic structuring in a shorthand way - i.e. "all these classes are subclasses of the class A"?  If so then what is the import of that? - "all these animals are ducks"?  Typically, (in my experience) design is trying to illustrate "this duck is an animal", "this duck is a plaster wall decoration", "this duck is a wooden toy"  rather than the other way around.





Title: Re: Class Diagrams - use of packages
Post by: TrtnJohn on October 04, 2004, 05:09:11 pm
I do this sometimes too.  But, I always make sure that each sub-package still shows the animal - duck relationship by including a seperate diagram in the package with a linked element of the parent class.   By doing this you can go down N-Levels and still maintain the proper relationships.

The only reason I add the additional package/diagram is because sometimes my class hierachy can get a little busy to show the entire thing in one diagram.