UML Representation With Scripting

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:
    • Structural
    • Behavioral

  • 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:
  1. [<frame>Check Admin login |    
  2.    [<start>st]->[Login]    
  3.    [Login]->[<choice>Check if User is Admin]    
  4.    [Check if User is Admin] yes ->[Redirect to admin page]    
  5.    [Check if User is Admin] no ->[User page]    
  6.    [Redirect to admin page] yes ->[<end>e]    
  7.    [User page] no ->[<end>e]    
  8. ]   
Use Case Diagram
 
Use case diagram is divided into 3 types:
  • Scenario
  • Actor
  • Use Case
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: 
 
UML Representation With Scripting
 
Copy the below code:
  1. [<frame>Use case diagram |    
  2. [<actor>Simple user] - [Add simple Customer]    
  3. [<actor>Admin user] - [Add Discount Customer]    
  4. [Add Discount Customer] <extend> --> [Add simple Customer]     
  5. [Add simple Customer] <include> -> [<usecase>Send notification]     
  6. [Add Discount Customer] <include> -> [<usecase>Send notification]     
  7. ]   
Class diagram
 
The class diagram is our prototype that helps us to create objects
 
UML Representation With Scripting
 
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:
  1. [Customer]--:>interface[<<ICustomer>>|+Add()]    
  2. [Customer|+CustomerCode: int;-CustomerName: nvarchar(100);#CustomerName: nvarchar(100)|+Add();-Validate()]    
  3. [GoldCustomer|+Discount()]-:>[Customer]    
  4.     
  5. [<abstract>{Engine}||start()]    
 

Conclusion

 
In this blog, we have seen how we can implement UML representation and the types of it.