Wednesday 18 April 2018

UML FAQ

Actor: Actor is the who of the system, in other words the end user.
Use Case: Use case is task or the goal performed by the end user

CLASS Diagram
  • Class name: This is the first section or top most section of the Class which represents the name of the Class (clsCustomer).
  • Attributes: This is the second section or the middle section of the class which represents the properties of the system.
  • Methods: This section carries operation or method to act on the attributes.
Figure: Three sections of the class



Figure: Private, public and protected


Associations in Class diagrams

A single Class cannot represent the whole module in a project so we need one or more classes to represent a module. 
In the figure ‘Order is paid by payments class’, we can see Order class and the Payment class and arrowed line showing relationship that the order class is paid using payment class in other words order class is going to be used by payment class to pay the order. The left to right marked arrow basically shows the flow that order class uses the payment class.
Figure:- Order is paid by Payments class

Multiplicity

Multiplicity can be termed as classes having multiple associations or one class can be linked to instances of many other classes
Note: ‘*’ means “many” where as ‘(0, 1)’ means “(zero or at least one)” respectively.
Figure: Multiplicity in Classes


aggregation and composition in class diagrams?

Aggregation Association signifies that the whole object can exist without the Aggregated Object. For example in the below figure we have three classes university class, department class and the Professor Class. The university cannot exist without department which means that university will be closed as the department is closed.
In the same figure we have defined second Association between the department and the Professor. In this case, if the professor leaves the department still the department continues in other words department is not dependent on the professor this is called as Composition Association.

Note: The filled diamond represents the aggregation and the empty diamond represents the composition. You can see the figure below for more details.
Figure: Aggregation and composition in action


Generalization and Specialization

In Generalization and Specialization we define the parent-child relationship between the classes.
In the below figure there are three classes to show Generalization and Specialization relationship. All phone types have phone number as a generalized property but depending upon landline or mobile you can have wired or simcard connectivity as specialized property. In this diagram the clsphone represent Generalization whereas clslandline and clsmobile represents specialization.
Figure: Generalization and Specialization

How do we represent an abstract class and interface UML?

Interface is represented by <> in the class diagram. Below figure ‘Interface in action’ shows we have defined an interface ‘IContext’. Note the ‘<>’ represents an interface. If we want to show that the interface is used in a class we show the same with a line and a simple circle as shown in figure ‘Interface in Action’ below.
Figure: Interface in action
Abstract classes are represented by ‘{abstract}’ as shown in figure ‘Abstract classes in action’.
Figure: Abstract classes in action.

object diagrams in UML?

Object diagram gives a pictorial representation of class diagram at any point of time. Below figure ‘Object diagram’ shows how a class looks in when actual objects are created. 

Figure: Object diagrams

Sequence diagrams

Sequence diagram shows interaction between objects over a specific period time.
One of the points to be noted is product and stock object is not active when the payment activity occurs.
Figure: Sequence diagram


Synchronous and asynchronous messages

Synchronous messages are represented by a dark arrow head while asynchronous messages are shown by a thin arrow head as shown in figure ‘Synchronous and Asynchronous’.
Figure: Synchronous and Asynchronous

Recursive message

We have scenarios where we need to represent function and subroutines which are called recursively. Recursive means the method calling himself. Recursive messages are represented by small rectangle inside a big rectangle with an arrow going from the big rectangle to the small rectangle as shown in figure ‘Recursive message’.
Figure: Recursive message

Message constraint

If we want to represent constraints it is put in a rectangle bracket as shown in figure ‘message constraint’. In the below figure ‘message constraint’ the ‘customer’ object can call ‘book tickets’ only if the age of the customer is greater than 10.
Figure: Message constraint

Message branching

Below figure ‘message branching’ shows how ‘customer’ object have two branches one is when the customer calls save data and one when he cancels the data.
Figure: Message branching



No comments:

Post a Comment