A Class diagram is made up with a set of classes and the relationship between them

Representation of a Classes in a class diagram.

Class is represented by a Box with separate partitions

  • Class Name : This is in the first partition.Screenshot from 2014-02-20 15:47:04
  • Instance Variables : This is in the second partition. Variable type is shown after the colon.
  • Methods : This is in the third partition. Method’s return type is provided after the colon at the end of the method signature. Argument type is provided after the colon at the end of the argument name. Method directionality is mentioned as in/out and inout. A reference to some class is denoted by an asterix (*).

If a class variable or a method is a static it must be underlined. And if Class or a method is abstract it should be italic.

In the picture, we can observe the following for MyClassName

  • MyClassName has 3 attributes and 3 operations
  • op2 returns a float
  • Parameter p3 of op2 is of type int
  • op3 returns a pointer (denoted by a *) to Class6

Visibility and Access for the variables and methods of the class diagram

Access levels are denoted by +, – and # signs preceded to the variable and method names.

  1. + denotes public attributes or operations
  2. – denotes private attributes or operations
  3. # denotes protected attributes or operations

Method parameter directionality

Screenshot from 2014-02-20 16:01:52

Each parameter in an operation (method) may be denoted as in, out or in/out which specifies its direction with respect to the caller. This directionality is shown before the parameter name.

Check this sample for more info.

References :

Advertisements