Class Diagram – Visibility and Scopes

Posted By on April 29, 2016

Download PDF


The class diagram is the main building block of object-oriented modelling. It is used both for general conceptual modelling of the systematics of the application, and for detailed modelling translating the models into programming code. Class diagrams can also be used for data modeling.The classes in a class diagram represent both the main elements, interactions in the application, and the classes to be programmed.

A class with three compartments.

In the diagram, classes are represented with boxes that contain three compartments:

  • The top compartment contains the name of the class. It is printed in bold and centered, and the first letter is capitalized.
  • The middle compartment contains the attributes of the class. They are left-aligned and the first letter is lowercase.
  • The bottom compartment contains the operations the class can execute. They are also left-aligned and the first letter is lowercase.

In the design of a system, a number of classes are identified and grouped together in a class diagram that helps to determine the static relations between them.


To specify the visibility of a class member (i.e. any attribute or method), these notations must be placed before the member’s name:

+ Public
- Private
# Protected
/ Derived (can be combined with one of the others)
~ Package


The UML specifies two types of scope for members: instance and classifier and these last are represented by underlined names

  • Classifier members are commonly recognized as “static” in many programming languages. The scope is the class itself.
    • Attribute values are equal for all instances
    • Method invocation does not affect the instance’s state
  • Instance members are scoped to a specific instance.
    • Attribute values may vary between instances
    • Method invocation may affect the instance’s state (i.e. change instance’s attributes)

To indicate a classifier scope for a member, its name must be underlined. Otherwise, instance scope is assumed by default.

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby