Learn How to Draw a Class Diagram!

Gimhan Wijayawardana
3 min readAug 14, 2020

--

Are all dogs animals? Can we live without a liver? Can a room exist without a house? You may think what’s with all these weird questions and how it’s related to the class diagram tutorial. Don’t panic! We’ll move step by step to draw our class diagram. For starters,

What is a Class diagram?

A class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects.

Now let’s get down to the important facts. In a class diagram, we use 3 compartment box to define a class. So basically, you should create these types of boxes for each of your classes.

(Single Class Representation)

You may have noticed that I’ve used a “-” before defining class attributes & “+” before the class methods. Those signs used to display the visibility of that certain attribute or method. You can add yours according to your project.

(Methods to display the visibility)

So far so good! And here comes to the “Relationships”.

Good luck Ross & Rachel :)

Well, this isn’t about “personal relationships” because that’s gonna take million years to finish. Anyway, when creating a class diagram you should consider the type of relationship between each of the classes.

(Types of relationships)

You may think, “What’s with all the arrows?” Well, it’s important to know how each of these arrows represents the relationship between classes. To learn more about relationships you can refer to this.

(Relationship between dog and animal classes)

For instance, I’ll take the first question I mentioned in the beginning. “Are all dogs animals?” It is obvious that the answer is “YES”. So the relationship between animal and dog belongs to “inheritance”

You can create relationships between each of the classes according to your requirement.

One single step and we are done creating our class diagram. After creating your relationships you should add “Multiplicity” to your class diagram. It’s really simple to understand.

There are mainly 6 cases when it comes to Multiplicity. In our scenario, there can be 0 or more dogs related to the animal class. Use the below table to identify what kind of Multiplicity to add to each of your relationships.

(Multiplicity)

I guess you learned something to work on your class diagram. It’s pretty easy and takes a little time to complete. This is the class diagram we’ve created for an upcoming project called “ScholarX” launching by SEF.

If you wanna check out the full class diagram click here. Hope you learned something about class diagrams. Good luck drawing yours :)

--

--