Class Diagram

Quickly create class diagrams and other UML style diagrams with SmartDraw

With SmartDraw, You Can Create Many Different Types of Diagrams, Charts, and Visuals

Learn More

What is a Class Diagram?

A class diagram models the static structure of a system. It shows relationships between classes, objects, attributes, and operations.

Back to top

Basic Class Diagram Symbols and Notations

Class diagram classes
Classes

Classes represent an abstraction of entities with common characteristics. Associations represent the relationships between classes.

Illustrate classes with rectangles divided into compartments. Place the name of the class in the first partition (centered, bolded, and capitalized), list the attributes in the second partition (left-aligned, not bolded, and lowercase), and write operations into the third.

Active class
Active Classes

Active classes initiate and control the flow of activity, while passive classes store data and serve other classes. Illustrate active classes with a thicker border.

Class diagram visibility
Visibility

Use visibility markers to signify who can access the information contained within a class. Private visibility, denoted with a - sign, hides information from anything outside the class partition. Public visibility, denoted with a + sign, allows all other classes to view the marked information. Protected visibility, denoted with a # sign, allows child classes to access information they inherited from a parent class.

Class diagram associations
Associations

Associations represent static relationships between classes. Place association names above, on, or below the association line. Use a filled arrow to indicate the direction of the relationship. Place roles near the end of an association. Roles represent the way the two classes see each other.

Class diagram multiplicity
Multiplicity (Cardinality)

Place multiplicity notations near the ends of an association. These symbols indicate the number of instances of one class linked to one instance of the other class. For example, one company will have one or more employees, but each employee works for just one company.

Class diagram contraints
Constraint

Place constraints inside curly braces {}.

Class diagram composition aggregation
Composition and Aggregation

Composition is a special type of aggregation that denotes a strong ownership between Class A, the whole, and Class B, its part. Illustrate composition with a filled diamond. Use a hollow diamond to represent a simple aggregation relationship, in which the "whole" class plays a more important role than the "part" class, but the two classes are not dependent on each other. The diamond ends in both composition and aggregation relationships point toward the "whole" class (i.e., the aggregation).

Class diagram generalization
Generalization

Generalization is another name for inheritance or an "is a" relationship. It refers to a relationship between two classes where one class is a specialized version of another. For example, Honda is a type of car. So the class Honda would have a generalization relationship with the class car.

Back to top

Generate a Class Diagram Automatically from Data

You can generate a class diagram automatically using a GitHub repo or a local repository. You don't need to draw anything at all.

Simply launch the SmartDraw Class Diagram data visualizer and point it to Github or a local directory, choose which classes you want to include and click Build Diagram to have a class diagram built for you, automatically.

The class diagram extension will work with C#, C, Java, JavaScript, Ruby and Python.

Learn more about how to build a class diagram without drawing at all using SmartDraw's Class Diagram Data Visualizer.

Back to top
Launch extension
Manual class diagram

How to Draw a Class Diagram Manually

Class diagrams are pretty simple to construct manually too if you don't have source code to point to yet and want to think about designing a new project. All you need to do is connect shapes that represent classes in your system with lines. SmartDraw's class diagram libraries have all the appropriate class notations you can drag and drop and connect easily. Read SmartDraw's complete UML diagram tutorial.

Back to top

More Class Diagram Information

Try SmartDraw's Class Diagram Software Free

Discover why SmartDraw is the best class diagram software today.

By continuing to use the website, you consent to the use of cookies.   Read More