UML ( Unified Modeling Langauage)

UML is simply another graphical representation of a common semantic model. UML provides a comprehensive notation for the full lifecycle of object-oriented development.

 Advantages:

UML defines several models for representing systems:

UML Diagrams

UML defines nine different types of diagram:

  1. Use case diagrams:  represent the functions of a system from the user's point of view.
  2. Sequence diagrams: are a temporal representation of objects and their interactions.
  3. Collaboration diagrams: spatial representation of objects, links, and interactions.
  4. Object diagrams :represent objects and their relationships and correspond to simplified collaboration diagrams that do not represent message broadcasts.
  5. Class diagrams represent the static structure in terms of classes and relationships
  6. Statechart diagrams represent the behavior of a class in terms of states at run time.
  7. Activity diagrams:  represent the behavior of an operation as a set of actions
  8. Component diagrams: represent the physical components of an application
  9. Deployment diagrams: represent the deployment of components on particular pieces of hardware

The different types of diagrams defined by UML

Relationship among various UML Diagrams in OOAD ( Object Oriented Analysis and design) is illustrated in the following diagrams of  Business Model, Use Case Diagram , Sequence Diagram , Class Diagram  and Code generation..

1. Use Case Diagram:

Use Cases for ATM System:[UML Use Case Diagram]

Use Case Specification:

2. Activity Diagram: 

Used to document complex use case logic. It is not required for simple use case logic.

Use Case to accept credit Card Payment:

1.  The customer then enters and submits her card details. 

2. The system validates these values and either returns to the customer if there is an error or submits the payment to the Credit Card Service. 

3. If the card payment is accepted, then the system notifies the customer of success. If not, then the error is logged, and the customer is notified of the failure (and perhaps directed to handle the payment some other way). 

 

Object Interactions:( Sequence and Collaboration : Complimentary to each other) diagrams.

 Interactions between objects are represented by interaction diagrams both sequence and collaboration diagrams. An example of a collaboration diagram is shown below. Objects are drawn as rectangles and the lines between them indicate links a link is an instance of an association. The order of the messages along the links between the objects is indicated by the number  at the head of the message:

Sequence diagrams show essentially the same information, but concentrate on the time-ordered communication between objects, rather than their relationships. An example of a sequence diagram is shown below. The dashed vertical lines represent the lifeline of the object:

3. Sequence Diagram:

Time ordered message passing:

  [ Interaction for system startup ]

Withdrawal Transaction Use Case

A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. (The dispensing of cash is also recorded in the ATM's log.)

A withdrawal transaction can be cancelled by the customer pressing the Cancel key any time prior to choosing the dollar amount.

 

4. Collaboration Diagram:

Relationship among Objects and Messages.

[ Interaction for specifics of a withdrawal transaction ]

5. Analysis class Diagram:

MVC (Model , View and Control)  high level Design of the System:

[ Analysis Class Diagram ]

6. Class Diagram:

 Class: A Class is represented like this: 

Class

Attribute1
Attribute2

MethodA()
MethodB()

The top part showing the class name, the second showing the attributes and the third showing the methods.

  Object: An object looks very similar to a class, except that its name is underlined

AnObject

Attribute1
Attribute2

MethodA()
MethodB()

Relationships:

 Relationships between classes are generally represented in class diagrams by a line or an arrow joining the two classes. UML can represent the following, different types of object relationships.

3.1 If A depends on B, then this is shown by a dashed arrow between A and B, with the arrowhead pointing at B:

Association: An association between A and B is shown by a line joining the two classes:

1. Bidirectional:

If there is no arrow on the line, the association is taken to be bidirectional.

2. A unidirectional association is indicated like this:

Aggregation:

An aggregation relationship is indicated by placing a white diamond at the end of the association next to the aggregate class. If B aggregates A, then A is a part of B, but their lifetimes are independent:

Composition:

Composition, on the other hand, is shown by a black diamond on the end of association next to the composite class. If B is composed of A, then B controls the lifetime of A.

Multiplicity:

 The multiplicity of a relationship is indicated by a number (or *) placed at the end of an association.

The following diagram indicates a one-to-one relationship between A and B:

A multiplicity can also be a range of values. Some examples are shown below:

 1                         One and only one

*                              Any number from 0 to infinity

0..1                          Either 0 or 1

n..m                         Any number in the range n to m inclusive

1..*                          Any positive integer

Naming an Association

 To improve the clarity of a class diagram, the association between two objects may be named:

Inheritance

 An inheritance (generalization/specialization) relationship is indicated in the UML by an arrow with a triangular arrowhead pointing towards the generalized class.

 If A is a base class, and B and C are classes derived from A, then this would be represented by the following class diagram:

 Multiple Inheritance

 The next diagram represents the case where class C is derived from classes A and B:

Class Diagram for ATM System:

[ Class Diagram ]

Package Diagram for Example ATM System

[ Package Diagram ]

 

Withdrawal Class:

Withdrawal

- from: int

- amount: Money

+ Withdrawal(atm: ATM, session: Session, card: Card, pin: int)

# getSpecificsFromCustomer(): Message throws Cancelled

# completeTransaction(): Receipt

Visibility of Attribute or Method specified by characters like - (Private),  + (Public), # (Protected).

7. State Diagram:

States of objects are represented as rectangles with rounded corners. The transition between difference states is represented as an arrow between states, and a condition of that transition occurring may be added between square braced. This condition is called a guard.

[ Statechart for overall ATM ]

 

8. Component Diagrams:

Component diagrams describe software components and their relationships within the implementation environment; they indicate the choices made  at implementation time.

They may be simple files, or libraries loaded dynamically.

In C++, a specification corresponds to a file with a .h suffix, and a body corresponds to a file with the suffix .cpp.

9. Deployment Diagrams

Deployment diagrams show the physical layout of the various hardware components (nodes) that compose a system, as well as the distribution of executable programs on this hardware.

Deployment diagrams may show node classes or node instances. As with other types of diagram, the graphical difference between classes and objects is implemented by underlining the object name. The following example shows the deployment diagram of a building access management system:

The diagram describes the nature of the communication links between the various nodes. The server and the PCs are connected via an IPX link; the X-terminals and the server communicate via TCP/IP. The nature of the connections between other nodes is not specified.

Each process named in the deployment diagram executes a main program with the same name as the one described within the component diagram.

Click to go to  Home Page