Introduction
Are you a developer currently moving towards an architect position in your company. Do you need to draw a diagram fast and effortlessly? Then here is some script where you can draw a diagram.
What is UML?
-
Unified Modeling Language, a standard language for designing and documenting a system in an object-oriented manner.
-
Communicating language between technical architects and developers
-
Diagram also express the design of software architecture
-
UML diagram has 2 types:
-
Below are a few important diagrams used frequently:
- Class diagram (Structural type)
- Activity Diagram (Behavioral type)
- Use case diagram (Behavioral type)
- Sequence diagram (Behavioral type)
Activity Diagram
Activity diagram used to capture complicated process flows in the project
Scenario
In case you want to have some kind of flow chart where the User will enter his credentials, check the condition based on if the user is an admin or not. If they are an admin, redirect them to the admin page or else redirect them to the User page. When we have to capture some process flow on some activity, then the Activity Diagram is suitable for this.
Below is the diagram for Activity diagram:
Copy the below code:
- [<frame>Check Admin login |
- [<start>st]->[Login]
- [Login]->[<choice>Check if User is Admin]
- [Check if User is Admin] yes ->[Redirect to admin page]
- [Check if User is Admin] no ->[User page]
- [Redirect to admin page] yes ->[<end>e]
- [User page] no ->[<end>e]
- ]
Use Case Diagram
Use case diagram is divided into 3 types:
The actor is two types:
- Primary (Simple user)
- Secondary (Admin user)
Include and Exclude denines relationship between use cases.
Scenario
In case you want to have some use case based on the same page where you want to add some logic to it. Like if the admin user enters the customer page, they are able to add some discount to it (or they is able to edit the feature). If a simple user enters to customer page, they should go ahead with simple logic (or no rights for the editing feature). Where admin is included in normal entry with discount logic. In this scenario, we can implement this use case diagram
Below is the diagram for the Use case diagram:
Copy the below code:
- [<frame>Use case diagram |
- [<actor>Simple user] - [Add simple Customer]
- [<actor>Admin user] - [Add Discount Customer]
- [Add Discount Customer] <extend> --> [Add simple Customer]
- [Add simple Customer] <include> -> [<usecase>Send notification]
- [Add Discount Customer] <include> -> [<usecase>Send notification]
- ]
Class diagram
The class diagram is our prototype that helps us to create objects
Scenario
In case you want to have a prototype of your classes, interface and it's property and methods then we can use Class diagram.
Below is the diagram for the Class diagram.
Visibility Member
public |
+ |
private |
- |
protected |
# |
Abstract class |
{} |
Interface |
<<>> |
Copy the below code:
- [Customer]--:>interface[<<ICustomer>>|+Add()]
- [Customer|+CustomerCode: int;-CustomerName: nvarchar(100);#CustomerName: nvarchar(100)|+Add();-Validate()]
- [GoldCustomer|+Discount()]-:>[Customer]
-
- [<abstract>{Engine}||start()]
Conclusion
In this blog, we have seen how we can implement UML representation and the types of it.