Software Engineer, Your next Programming Instructor.

"Here I share myself."

Tuesday, 29 October 2019

UML Class Diagram with solved example tutorial


UML Class diagram :
Student often found it difficult to understand and difficult to draw class diagram, but I think if you know the core concepts of class diagram it is not some thing that much difficult. Lets  have a discussion at it.

What is a class? from where it comes?

Anything from the real world which we want to map in software engineering for making a software that can be a class. I think examples are best part to understand tricky things lets have a look at example.

For Example: I am planing to make a software i.e as "Hospital Management System" now the next part is I will collect the requirements for it and think over it what will be the real world objects and things participate in this software. What first come into the mind? 
  • Patient
  • Patient Record
  • Doctor
And lots of many other things I am not going to write each and every thing, now these can be the classes. 

a Patient can be a class same for other two.

What is class diagram?

I think concept is cleared about what is class and from where it comes now it will be easy to understand what is class diagram, that simple collection of classes linked with each other known as class diagram.

What is the link? - Association between the classes

Link formally known as association between the classes, when you will made lots of different classes for a software off-course there will be link between those classes and those links are known as association between the classes.

Types of Associations :

Now there can be many types of associations between the classes.
  • One to One (* to *)
  • One to Many (1 to *)
  • Many to One (* to 1)
  • Many to Many  (* to *)
  • Many to 0..1 (pronounced as : many to 0 or 1)

Graphical representation of class :

I think theoretical concepts are more than clear now lets have a look at practical representation of the class

So this is the patient class divided in to three part, part 1 represent the name of the class part 2 represent the attributes of the class with data types and part 3 represents the operations that a class will perform.

Note: Attributes and operations of the real class can be vary form the one, this is just a simple assumption to make you understand.


Here you can see two classes patient class and patient record class the line between them is showing the link (association) between these classes, where is the type of association is one to one that is why it is written on both side.

lets have an explanation on what is meant by one to one here
One to one means one patient has exactly one record (in this case if we replace it with one to many (1..*) it means that one patient have more than one (record) record.


 Download PPT Slides of the topic

No comments: