UML Lab Manual
UML Lab Manual
Introduction to UML
UML is a language used for visualizing, specifying, constructing and documenting the artifacts of
software intensive system.UML makes a clear conceptual distinction between models, views and
diagrams.
A Model is an element that contains information for a software model.
A View is a visual expression of the information contained in a model, and
A Diagram is a collection of view elements that represent the users specific design thoughts.
UML is a language used for visualizing, specifying, constructing and documenting the artifacts of a
software intensive system.
A Modeling Language:
UML provides the vocabulary and the rules for communication and focus on conceptual and physical
representations of the system. So it is a modeling language.
UML Visualizes:
UML includes both graphical and textural representation and makes easy to visualize the system and
for better understanding.
UML specifies:
UML addresses the specification of all the important analysis, design implementation decisions,
developing and deploying a software intensive system.
UML Constructs:
UML models can be directly connected to a variety of programming languages. And it is sufficiently
expressive and free from any ambiguity to permit the direct execution of models, simulation of
systems, and the instrumentation of running systems.
UML Documents:
UML produces variety of documents, in addition to raw executable code, the aircrafts include
requirements, Architecture, Design, Source code, Project Plans, Test, Prototypes, Releases.
Things
Relationships
Diagrams.
Things in UML :
Structural Things
Classes
Interfaces
Collaborations
Use Cases
Active Classes
Components
Nodes Classes
Behavioral Things
Interactions
State Machines
Grouping Things
Packages
Annotational Things
Notes
Relationships in UML:
Dependency
Association
1. Aggregation
2. Composition
Generalization
Realization
Diagrams in UML:
Class Diagram
Object Diagram
Usecase Diagram
Sequence Diagram
Collaboration Diagram
Statechart Diagram
Activity Diagram
Component Diagram
Deployement Diagram
Programming
o Convert classes from design to actual code in OOPL
Unit Testing - Class diagrams and specifications
Integration Testing - Component and Collaboration diagrams
System Testing - Use-case diagrams
Class: A class is the descriptor for a set of objects with similar structure, behavior, and
relationships. It is represented by a rectangle.
Relations:
Association
Dependency
Generalization
Realization
Directed Association
Aggregation and
Composition
Association:
An association is a structural relationship that specifies the relation between two objects
when they are at the same level (peer level systems).
An Association can specify the relationship, role of the class and Multiplicity.
It is represented as follows:
Directed Association:
Symbol:
Aggregation:
Composition:
Symbol:
Generalization:
Generalization is a specification relationship in which objects of the specialized element (the child )
are substitutable for objects of the generalization element (the parent).It is used in class diagram.
Symbol:
Dependency:
A dependency is a semantic relationship in which if there is any change occurred in one object that
may effect other object.
Symbol:
Realization:
Realization is a Specified tool that can be represented by providing a relationship with classifier.
Symbol:
---------------------------------------------Class diagrams:
A class diagram is that which represents a set of classes, interfaces, and collaborations and their
relationships, graphically a class diagram is a collection of vertices and arcs.
It consists of three compartments.
<ClassName>
<Attributes>
<Operations>
Uses:
Operations
An object diagram shares the same common properties of all other diagrams.
Name
Attributes
Uses:
Operations
An object diagram is used to model
the static design view of a system.
UseCase Diagrams:
A usecase diagram shares the common properties as all diagrams. It distinguishes in the contents of
use cases, actors, dependency, and generalization relationships.
Actor
Uses:
A Usecase diagram is used to model the static design view of a system.
Interaction Diagrams:
An Interaction diagram shares the same common properties as all other diagrams. It differs in its
contents
Objects
Links
Messages
Collaboration Diagrams:
A collaboration diagram emphasizes the organization of the objects that participate in an
interaction.
Collaboration diagrams have two features that distinguish them from sequence diagrams.
(i)Path
(ii) The Sequence number
Object: It is an instance of a class.
Symbol:
Object name
Send:
Return:
------------------------------------------
Create:
<<create>>
Destroy:
<<destroy>>
Uses:
Interaction diagrams are used to model the dynamic aspects of a system. It is obtained in two ways:
(i)
(ii)
Sub machine State: A submachine state is a syntactical convenience that facilitates reuse
and modularity. It is a shorthand that implies a macro-like expansion by another state
machine and is semantically equivalent to a composite state.
Symbol:
Sub State Name
Initial State:
Activity Diagram:
It represents the different activities in the system.
Action State: An action state represents the execution of an atomic action, typically the
invocation of an operation. An action state is a simple state with an entry action whose only
exit transition is triggered by the implicit event of completing the execution of the entry
action. The state therefore corresponds to the execution of the entry action itself and the
outgoing transition is activated as soon as the action has completed its execution.
Symbol:
Sub Activity State: A sub activity state represents the execution of a non-atomic sequence of
steps that has some duration; that is, internally it consists of a set of actions and possibly
waiting for events. That is, a sub activity state is a hierarchical action, where an associated
sub activity graph is executed.
Symbol:
Initial State: An initial is a kind of pseudo state that represents the starting point in a region
of a state machine. It has a single outgoing transition to the default state of the enclosing
region, and has no incoming transitions. There can be one (and only one) initial state in any
given region of a state machine. It is not itself a state but acts as a marker.
Symbol:
Final State: A final state represents the last or "final" state of the enclosing composite state.
There may be more than one final state at any level signifying that the composite state can
end in different ways or conditions. When a final state is reached and there are no other
enclosing states it means that the entire state machine has completed its transitions and no
more transitions can occur.
Symbol:
Decision: A state diagram (and by derivation an activity diagram) expresses a decision
when guard conditions are used to indicate different possible transitions that depend on
Boolean conditions of the owning object.
Symbol:
Interface:
An interface is a specified for the externally-visible operations of a class,
component, or other classifier (including subsystems) without specification of internal
structure.
Symbol:
Deployment Diagrams:
Package: A package is a grouping of model elements. Packages themselves may be nested within
other packages. A package may contain subordinate packages as well as other kinds of model
elements. All kinds of UML model elements can be organized into packages.
Symbol:
10
managedatabase
invalid PIN
<<extend>>
transcation
Bank client
ATM machine
<<include>>
deposite
withdrawal
balance enquiry
valid client
<<extend>>
invalid client
ACTORS:
1. BANKCLIENT: the bank client is a primary actor which having an ATM card.
2. ATM MACHINE: The ATM machine is a primary actor which is used to
Perform the online transaction. It is an intermediate
between the bank client and bank.
3. BANK: The Bank is a second actor which will verify the bank client account
and also manages the database.
USE CASES SPECIFICATION OF TRANSACTION:
The use case transaction performs the ATM transaction whenever cardholder is valid. It
contains another use cases like deposited, withdrawal & balance enquiry.
I) MAIN FLOW OF EVENTS:
The bank client must be valid person and have a valid PIN number.
II) EXCEPTION FLOW OF EVENTS:
11
ATM machine
+atm_mach no.
1
request for
1..*
+providing_receipt()
+display_message()
+status()
+read_card()
+accept_card()
+view_balance()
+notify_successful receipt()
1
asks for
manages
1
Bank
Thirdparity
+account_number
-pin_balance
+open _account()
+create_account()
+withdraw_funds()
+verification()
+delete_account()
Bank database
-pin number
+verify_card()
+system_shut down()
+sys_start up()
+add_cash()
+verify_customer id()
+verify_customer status()
+asking _operation()
+updating_dbbase()
id()
I) PERSISTENCE CLASSES:
Bank client, ATM machine are the persistence classes.
II) NON-PERSISTENCE CLASSES:
Bank, Third-party, Bank database are non-persistence classes.
12
: ATM machine
: Bank
1 : Insert ATMcard()
2 : Request PINnum()
3 : Enter PINnum()
4 : verify PINnum()
5 : valid PIN()
6 : Request amount()
7 : Enter amount()
8 : withdraw checking()
9 : withdraw successfully()
10 : Transcation successfully finished()
11 : dispense cash()
12 : print reciept()
13 : terminate()
<<destroy>>
13
14
ATM machine
Bank
Insert atmcard
[submite]
read PIN
verify PIN
[invalid]
[verification report]
[valid]
Enter amount
Request amount
dispense cash
give recipt
close transcation
15
ideal
Insert card
Active
cancel
maintain
withdraw/enquiery
validate
maintainance
[continue]
selecting
processing
[not continue]
printreciept
entry/readcard
exit/ejectcard
ATM.exe
ATMdatabase.db
transaction
+pin number
+withdraw()
+enquiery()
.tbl
it contains
databse tables
it contains
ATM.obj files
it contains
ATM.java files
it contain
ATM.dll files
16
ATM machine
Ethernet
server
RAID farm
RS-232
ATM.exe
Bank
17
To borrow the items from library member have option to Enquiry about that item.
The member must confirm the require book is available before borrowing.
The Librarian can take books back when members return books.
Actors
Staff:-Interactive actor who uses the library to Enquire, Borrow books, applies for Reserve
books and Pay fine.
Librarian:-Interactive actor responsible for Lending articles, Return articles, Renew books
and Remove reservations.
Student:-Interactive actor who uses the library to Enquire, Borrow books, applies for
Reserve books and Pay fine.
Usecases:
For Library system, we can find the following use-cases:
Enquiry
Borrow books
Reserve books
18
Pay fine
Lending article
Return article
Renew books
Remove reservation
Usecase Diagram
Usecase Descriptions
Flow of Events
Basic Flow
1. Member gives the book title to search.
2. System gives list of related articles which is matched to given string.
3. Member select or may know the required articles is available or not.
19
Alternative Flows
System displays there is no related books/articles in library.
Preconditions
Member must get memberid from librarian before using the system.
Post-conditions
Member got list of related book information if available, otherwise gives related message.
Flow of Events
Basic Flow
The librarian can give book if it is available.
Alternative Flows
1. The librarian cant give books if member cross borrowing limit.
2. The member has no reservation to borrow books.
Preconditions
The member must confirm that book is available or not in library.
Post-conditions
The librarian can register the information about borrowing book.
3. Use-Case Specification: Return books
Description
This usecase starts when the user wants to return the borrowed book.
Flow of Events
Basic Flow
Member who borrowed the book is going to return the book.
Alternative Flow
Member is going to penalty when time period is over.
Pre condition
Member has check the time period from the time of borrowing.
Post condition
None.
20
Post condition
Librarian can update article information.
Flow of Events
Basic Flow
1. Member who wants to borrow the book, he gives the information about that book.
2. The system marks the item as reserved and associates the borrower with the reservation
Alternative Flows
Member is unable to get book. Re applies for reserve the book.
Pre-conditions
The borrower is viewing a particular title with an item that is not currently available
Post-conditions
The item is marked as reserved and the reservation is saved in the database
21
22
Sequence Diagram
Activity diagram
23
Component Diagram
Deployment Diagram
24
Aim: To design UML diagrams for Online Book Shop, and the functions takes place in the
application.
Usecase diagram:-
25
user
mainform
loginform
welcomeform
logincontroller
errorcontroller
database
1:login()
2:enter username/password
3:authenticatio
5:valid
6:invalid
7:error message
8:relogin
26
administrator
mainform
controller
errormessages
database
1:request id
2:enter id
3:verification
4:invalid
5:errormesage
6:re_enterid
7:verified
8:generate reports
27
cuatomer
mainform
administrator
controller
errormessages
database
2:verify
4:error message
5:verified
6:retrieve data
28
manager
option form
book profile
form
2:add books
sequence
diagram
3:update books
sequence
diagram
4:delete books
sequence
diagrams
29
manager
book controller
error message
database
3:verification
5:error message
6:filled property
7:generate id
30
manager
selector form
modification
form
modification
controller
errormessage
database
2:selecting book
3:intimate database
4:retrive data
5:modify
6:verification
7:improper
8:error message
31
manager
selector form
deletion form
database
1:select book
2:retriving data
3:deleting
4:update()
mainform
loginform
3: authentication
7: error m es s age
welcom eform
logincontroller
errorm es sage
6: invalid
5: valid
4: enter into database
databas e
32
3: verification
administrator
controller
mainform
1: requestid
8: generate reports
database
7: verified
4: invalid id
5: error message
errormessage
2: verify
main form
administrator
controller
6: retrieved data
database
5: verified
3: not filled properly
4: error message
error
message
33
option
1: to avail option
2: add books
3: update books
4: delete books
book profile
form
new book
add form
1: request for new book
book
controller
7: generate id
database
6: filled properly
errormessage
34
selector
form
modification
controller
6: verification
5: modifying
3: intimate database
modification
form
7: improper modification
8: error messages
error
message
4: retrive database
database
e
Delete collaboration diagram:1: select book
manager
selector
form
3: deleting
2: retriving data
4: update()
deletion
form
database
35
4.
Reservation counter.
Identification of actors:
The actors in the system are the passenger, the counter clerk and the reservation
system consisting of form processing, reservation, canceling issued ticket, ticket printing and
updating etc.
Use cases:
User
Role
Use case
Passenger
1.Enquiry
2.Reservation and
ticketing
3.Cancellation
Counter clerk
Reservation
system
36
Passenger
CounterClerk
Availability status
Passenger
Print ticket
Counter Clerk
37
System
Fill Cancellation form
Passenger
38
Class diagram
Passenger
Clerk
+Name
+Gender
+Age
+Address
+Name
+Gender
+Age
0..*
1..*
+fillForm()
+payFareAmount()
+collectTicket()
+getDetails()
+getFareAmount()
+getTicket()
1
1
1
Reservation System
+processForm()
+reservation()
+fareComputation()
+processTicket()
+printTicket()
1..*
Payment
CreditPayment
CashPayment
39
Interaction diagrams
Sequence diagram
: passenger
: clerk
: reservation system
1 : requestForm()
2 : givesForm()
3 : returnsFilledForm()
4 : entersDetails()
5 : checksAvailability()
6 : fareamount
7 : paysAmount()
8 : triggersTicket()
9 : printTicket()
10 : issueTicket()
11 : updates()
40
Collaboration diagram
4 : entersDetails()
1 : requestForm()
2 : givesForm()
5 : checksAvailability()
3 : returnsFilledForm()
: passenger
: clerk
8 : triggersTicket()
6 : fareamount
: reservation system
9 : printTicket()
11 : updates()
7 : paysAmount()
10 : issueTicket()
Activity diagrams
Available
Fills Requisition From
Prints Tickets
41
Clerk
Reservation system
[Form modified]
Not ok
[Verify Availabilities]
Ok
Not
Ok
[Issue Tickets]
Ok
[Collect Amount]
Not ok
Component diagram
reservation.exe
Reservation form
<<artifact>>
update.exe
cancellation.exe
Cancellation form
42
Deployment diagram
Clients
Reservation server
Clerk
Reservation Server
Kiosk
43
44
Activity Diagram:-
45
46
47
48
49
50
51
Motivation:
Structuring a system into subsystems helps reduce complexity. Subsystems are groups
of classes, or groups of classes and other subsystems. The interface exposed by the classes in
a subsystem or set of subsystems can become quite complex. One way to reduce this
complexity is to introduce a facade object that provides a single, simplified interface to the
more general facilities of a subsystem
Applicability
Use the Facade pattern:
To provide a simple interface to a complex subsystem. This interface is good enough
for most clients; more sophisticated clients can look beyond the facade.
To decouple the classes of the subsystem from its clients and other subsystems,
thereby promoting subsystem independence and portability
Benefits
It hides the implementation of the subsystem from clients, making the
subsystem easier to use
It promotes weak coupling between the subsystem and its clients. This allows
you to change the classes the comprise the subsystem without affecting the clients.
It reduces compilation dependencies in large software systems
It simplifies porting systems to other platforms, because it's less likely that building
one subsystem requires building all others
It does not prevent sophisticated clients from accessing the underlying classes
Note that Facade does not add any functionality, it just simplifies interfaces
52
53
54
55
56