Author Topic: Class Diagrams - use of packages  (Read 1707 times)


  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Class Diagrams - use of packages
« on: September 22, 2004, 08:37:26 pm »

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 ???


  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Class Diagrams - use of packages
« Reply #1 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.

"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.


  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: Class Diagrams - use of packages
« Reply #2 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.