Diagram Illustration

How to Draw a Class Diagram in UML


Contents

Class diagrams are the foundation for all other UML structure diagrams. Use this tutorial to learn how to draw a class diagram of your own in UML.

How to make a class diagram

Class diagrams map out complex architecture, but they can be surprisingly easy to create. Class diagrams are a popular subset of UML, so if you’re new to the topic, use our class diagram tutorial to familiarize yourself and find different ways you can use class diagrams for mapping out your technical process and infrastructure.

If you’re new to UML altogether, use our guide to answer questions like "What is UML?" and "How can I use UML?" Once you sign up for a diagramming program like Lucidchart, it's time to start drawing.

Get started with Lucidchart

If you haven’t registered with Lucidchart, you can sign up for free. Log in and select a template or open a new document.

Add or import shapes

Every class diagram must include the UML class shapes. In Lucidchart, you can add the entire UML shape library to your toolbar—click "Shapes" on the left side of the editor and choose "UML." If you still need more shapes, you can search icons using the image search feature or you can import your own stencils and icons. When it comes to shapes, there are no limitations in Lucidchart.

Lucidchart UML shapes

Click your starting shape and drag the symbol onto the canvas. The standard class symbol has three rows, but you can use a similar shape that omits the bottom two rows if you prefer.

Add texts and concepts to your class diagram

To add text in each row of the class shape, just click and type. The first row should include only the class name, while the second features the attributes of the class. The last section lists potential methods or operations the class could take. The text in the bottom two sections is usually aligned to the left and typed with lowercase first letters. See the images on this page as an example.

Continue to add class shapes until your static application is fully represented.

Indicate scope by underlining certain members (the term for attributes or methods in a class). Members can be classified as either instances or classifiers. Classifiers are often recognized as static, meaning that attribute values remain the same in all instances, and method invocation doesn't affect the instance's state. In comparison, instances contain methods that can change the instance's state and attribute values that may vary between instances. To indicate a classifier, just underline its name; leave the text to indicate an instance.

Demonstrate visibility by placing the correct symbol within the class shape and before the particular attribute or method. This is also called assessing visibility. Consult this list to find the symbol associated with each access level:

Public (+)
Private (-)
Protected (#)
Package (~)
Derived (/)

Show your audience the interactions with class and object diagrams, or the relationships and links that exist between objects. While there are too many to list here, you can see some of the most common interactions on our class diagram definition page. In Lucidchart, you can indicate relationships between objects by drawing a line and then changing the notation style as needed.

How to format class diagrams

Easily format your class diagrams in Lucidchart. Open the Themes feature in the right sidebar to select a pre-made style format, or select your specific shapes and lines of choice to update their fonts, colors, and line settings.

Publish, implement, and share

Once you’ve created a class diagram in Lucidchart, you can easily share it to increase understanding throughout your entire organization. Publish and embed your chart in your company wiki, or send it to other current Lucidchart users or non-users with easy share features. You can also download your final class diagram in any file format.

Lucidchart sharing

With so many Lucidchart integrations, you can include your class diagrams in the applications that you use daily. With our free G Suite integrations, you can add your class diagram with additional context in Google Docs, Sheets, or Slides. Our Microsoft integrations allow you to import your diagrams seamlessly after you collaborate in real time within the cloud.