What is a Class Diagram?
Class diagram is a UML diagram type. It describe the system by graphically representing
- Different classes within the system
- Relationships among those classes
Class diagram also illustrates the attributes and operations inside each class.
Class usually used to explore the
- Domain concepts
- Understand the software requirements
- Describe the detailed designs
Class Diagram Notations
There are several class diagram notations that are used when drawing UML class diagrams. We’ve listed below the most common class diagram notations.
Classes represent the central objects in a system. It represented by rectangle. It has 3 compartments-
1.1). Class Name Compartment:
First compartment shows the name of the class.
1.2). Attributes Compartment:
The second compartment (middle compartment) shows the attributes contains by the class. Attributes are usually describes the characteristics of the objects.
+ Or – symbols
Inside above class diagram ‘+’ or ‘-’ symbols uses before each attributes. These indicate the visibility status of each attribute.
Attibute1, Attibute2 etc.
Indicates the each attribute name of the class
Data type of each attribute
1.3). Operations Compartments
The third compartment (last compartment) contains the list of operations (methods) performed by the class. These operations actually represent the behavior of the class.
+ Or – symbols
Inside above class diagram ‘+’ or ‘-’ symbols uses before each methods/operations. These indicate the visibility status of each operation.
Operation1, Operation2 etc.
Indicates each operation name
List of arguments passes to the operation
Return (void / primitive type / reference type) type of each method/operation.
2. Simple Class
The last two compartments are optional. The class notation without the last two compartments is called a simple class and it only contains the name of the class.
Interface diagram also similar to class diagram. It also has three compartments. The only difference is
- There will have <<Interface>> symbol inside the name compartment that will indicate that all sets and operations are abstract inside the interface and must have to implement inside class.
- All attributes will by default public i.e. before every attribute name there will have “+” sign
- All methods will by default public i.e. before every methods name there will have “+” sign
The package symbol is used to group classes or interfaces that are either similar in nature or related. Grouping these design elements using the package symbols improves the readability of the diagram.
Visibility Symbols in Class diagram
UML has following types of visibility
Public elements are visible to all. Public visibility represented by ‘+’ symbol
Private elements are visible only from the class where it is being defined. Private visibility represented by ‘-’ symbol.
Protected elements are visible only from the class and its derived classes. Protected visibility represented by ‘#’ symbol.
Elements are visible only from classes within the same package. Package visibility represented by ‘~’ symbol.
CSM, CSPO, CSD, CSP-SM, CSP-PO (ScrumAlliance.org)
Certification Profile Link-
Currently working as Lead Team (Application Architecture) at Raven Systems Ltd. Passion for software development especially agile practices such as TDD with in depth knowledge of Object Oriented Programming, SOLID Principles, Gang of Four Design Patterns, Some Enterprise Application Architectural Patterns. Over 8 years of software development experience ASP.NET. Has the ability to understand and transform complex business requirements into software ensuring applications are delivered on time. Also experience in non Microsoft .NET technologies such as Dapper.Net, Git, Structure Map & Angular, Bootstrap, HTML-5, CSS-3 etc.