CERN UML Guide


CLASSES

A Class The diagram to the left shows a class.
  • A class is drawn as a 'multibox with three compartments
    • The top most compartment gives the name of the class
    • The centre compartment gives the data members of the class (attributes)
    • The lowest compartment gives the member functions of the class
  • The little symbols next to the attributes and operations are put in by Rational Rose to show access rights


INHERITANCE

Inheritance The arrow symbol in this diagram is used to show derived types
  • Dog and Cat are both subclasses of mammal
    • They inherit from the class Mammal
  • The key phrase that shows an inheritance relationship is
    'a dog is a kind of mammal'
  • The c++ code equivalent of this diagram is
      class Dog : public Mammal {
      ...
      }


CONTAINMENT BY VALUE

Aggregation by Value The black diamond symbol in diagram is used to show containment by value
  • An object of type Car will contain and object of type Engine
    • equivalent code in C++ is
      class Car{
      private:
        Engine engine;
      }
  • The key phrase that shows aggregation is
    'a car has an engine'
  • The name on the arrow shows the name of the object that will be contained. In this cases the Car object will contain and Engine called 'engine'
    • The negative sign before engine means private containment
      • + public
      • # protected
      • - private
  • The numbers on the arrows show cardinality


CONTAINMENT BY REFERENCE

Aggregation by Reference The white diamond shows containment by reference
  • Containment by reference means that only a pointer to the object is stored
  • An object of type person will contain the address of objects of type Cat and Dog (or null pointers)
    • equivalent code in C++ is
      class Person{
      private:
        Cat *myCat;
        Dog *myDog;
      }
  • As before, the numbers on the arrows show cardinality


CARDINALITY

Cardinality The numbers on the ends of the relationship arrows show cardinality
  • Cardinality is the number of objects of that type that your object will be associated with
  • A person may have no dogs or one dog only. A dog however has to have exactly one owner
  • A person may own as many fish as he likes
    • The fish will be stored in a container. For LHCb a STL vector is used
      vector


DEPENDENCY (USE RELATIONSHIP)

Dependency The dotted arrow shows that one class depends upon (uses) another
  • Dependency is the weakest relationship
  • Used when one class may require the services of another
  • In this example the Printer knows about the class Formatter so that it can use its services


I have created a one page glossary of the relationships. You can download it as a post script by clicking
here or you can veiw the giff version here


If you would like to see an example using all of these components click here
Otherwise you may return to top page


Author Thomas.O'Reilly@cern.ch