View
1.681
Download
0
Category
Tags:
Preview:
DESCRIPTION
Citation preview
UML Use of UML Diagrams as
an aid to Database Design Specification
OverviewWhat is Modeling?What is UML?A brief history of UMLUnderstanding the basics of UMLUML diagrams UML Modeling toolsExample
Modeling Describing a system at a high level of
abstraction A model of the system Used for requirements and specifications
Is it necessary to model software systems?
Object Oriented Modeling
What is UML? UML stands for “Unified Modeling Language”
It is a industry-standard graphical language for specifying, visualizing, constructing, and documenting the artifacts of software systems
The UML uses mostly graphical notations to express the OO analysis and design of software projects.
Simplifies the complex process of software design
Why UML for Modeling
Use graphical notation to communicate more clearly than natural language (imprecise) and code(too detailed).
Help acquire an overall view of a system.
UML is not dependent on any one language or technology.
UML moves us from fragmentation to standardization.
History of UML
Types of UML Diagrams
Use Case Diagram
Class Diagram
Sequence Diagram
Collaboration Diagram
State Diagram
This is only a subset of diagrams … but they are most widely used
Use Case Diagram Used for describing a set of user
scenarios Mainly used for capturing user
requirements Work like a contract between end user
and software developers
Use Case Diagram (core components)
Actors: A role that a user plays with respect to the system,including human users and other systems. e.g.,inanimate physical objects (e.g. robot); an external system that needs some information from the current system.
Use case: A set of scenarios that describing an interaction between a user
and a system, including alternatives.
System boundary: rectangle diagram representing the boundary between the actors and the system.
Use Case Diagram(core relationship)
Association: communication between an actor and a use case; Represented by a solid line.
Generalization: relationship between one general use case and a special use case (used for defining special alternatives)Represented by a line with a triangular arrow head toward the parent use case.
Use Case Diagram(core relationship)
Extend: a dotted line labeled <<extend>> with an arrow toward the base case. The extending use case may add behavior to the base use case. The base class declares “extension points”.
<<extend>>
Include: a dotted line labeled <<include>> beginning at base use case and ending with an arrows pointing to the include use case. The include relationship occurs when a chunk of behavior is similar across more than one use case. Use “include” instead of copying the description of that behavior.
<<include>>
Use Case Diagrams
Library System
Borrow
Order Title
Fine Remittance
ClientEmployee
Supervisor
• A generalized description of how a system will be used.
• Provides an overview of the intended functionality of the system
Boundary
ActorUse Case
Class diagram Used for describing structure and
behavior in the use cases Provides a conceptual model of the
system in terms of entities and their relationships
Used for requirement capture, end-user interaction
Detailed class diagrams are used for developers
Class representation Each class is represented by a rectangle
subdivided into three compartments Name Attributes Operations
Modifiers are used to indicate visibility of attributes and operations. ‘+’ is used to denote Public visibility (everyone) ‘#’ is used to denote Protected visibility (friends
and derived) ‘-’ is used to denote Private visibility (no one)
By default, attributes are hidden and operations are visible.
OO Relationships
There are two kinds of Relationships Generalization Association
Associations can be further classified as Aggregation Composition
Subtype2
Supertype
Subtype1
OO Relationships: Generalization
- Generalization expresses a parent/child relationship among related classes.
- Used for abstracting details in several layers
Regular Customer
Loyalty Customer
Customer Example:
Regular Customer
Loyalty Customer
Customer or:
OO Relationships: Association
Represent relationship between instances of classes Student enrolls in a course Courses have students Courses have exams Etc.
Association has two ends Role names (e.g. enrolls) Multiplicity (e.g. One course can have many
students) Navigability (unidirectional, bidirectional)
Association: Multiplicity and Roles
University Person
1
0..1
*
*
Multiplicity
Symbol Meaning
1 One and only one
0..1 Zero or one
M..N From M to N (natural language)
* From zero to any positive integer
0..* From zero to any positive integer
1..* From one to any positive integer
teacheremployer
Role
Role
“A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; a given teacher may or may not be working for the university at a particular time.”
student
OO Relationships: Composition
Class W
Class P1 Class P2
Composition: expresses a relationship among instances of related classes. It is a specific kind of Whole-Part relationship.
It expresses a relationship where an instance of the Whole-class has the responsibility to create and initialize instances of each Part-class.
It may also be used to express a relationship where instancesof the Part-classes have privileged access or visibility tocertain attributes and/or behaviors defined by theWhole-class.
Composition should also be used to express relationship where instances of the Whole-class have exclusive access to and control of instances of the Part-classes.
Composition should be used to express a relationship wherethe behavior of Part instances is undefined without beingrelated to an instance of the Whole. And, conversely, thebehavior of the Whole is ill-defined or incomplete if one or more of the Part instances are undefined.
Whole Class
Part Classes
Automobile
Engine Transmission
Example
[From Dr.David A. Workman]
OO Relationships: Aggregation
Class C
Class E1 Class E2
AGGREGATION
Aggregation: expresses a relationship among instances of related classes. It is a specific kind of Container-Containee relationship.
It expresses a relationship where an instance of the Container-class has the responsibility to hold and maintain instances of each Containee-class that have been created outside the auspices of the Container-class.
Aggregation should be used to express a more informalrelationship than composition expresses. That is, it is anappropriate relationship where the Container and its Containees can be manipulated independently.
Aggregation is appropriate when Container and Containees have no special access privileges to each other.
Container Class
Containee Classes
Bag
Apples Milk
Example
[From Dr.David A. Workman]
Aggregation vs. Composition• CompositionComposition is really a strong form of aggregation
•components have only one owner •components cannot exist independent of their owner •components live or die with their owner e.g. Each car has an engine that can not be shared with other cars.
•Aggregations may form "part of" the aggregate, but may not be essential to it. They may also exist independent of the aggregate. e.g. Apples may exist independent of the bag.
Sequence Diagram:Object interaction
Self-CallSelf-Call: A message that an Object sends to itself.
Condition: indicates when a message is sent. The message is sent only if the condition is true.
Iteration
Condition
A B
Synchronous
Asynchronous
Transmission delayed
Self-Call
[condition] remove()
*[for each] remove()
Sequence Diagrams – Object Life Spans Creation
Create message Object life starts at that point
Activation Symbolized by rectangular
stripes Place on the lifeline where
object is activated. Rectangle also denotes when
object is deactivated. Deletion
Placing an ‘X’ on lifeline Object’s life ends at that
point
Activation bar
A
BCreate
XDeletion
Return
Lifeline
Sequence DiagramUser Catalog Reservations
1: look up ()
2: title data ()
3: [not available] reserve title ()
4 : title returned ()
5: hold title ()
5 : title available ()
6 : borrow title ()
6 : rem ove reservation ()
•Sequence diagrams demonstrate the behavior of objects in a use case by describing the objects and the messages they pass.
•The horizontal dimension shows the objects participating in the interaction.
•The vertical arrangement of messages indicates their order.
•The labels may contain the seq. # to indicate concurrency.
Message
Interaction Diagrams: Collaboration diagrams
User
Catalog
Reservations
start
1: look up2: title data
3 : [not available] reserve title
4 : title returned
5 : hold title
6 : borrow title
6: remove reservation
5: title available
•Shows the relationship between objects and the order of messages passed between them. between them. •The objects are listed as rectangles and arrows indicate the messages being passed •The numbers next to the messages are called sequence numbers. They show the sequence of the messages as they are passed between the objects. •convey the same information as sequence diagrams, but focus on object roles instead of the time sequence.
State Diagrams
State Diagrams show the sequences of states an object goes through during its life cycle in response to stimuli, together with its responses and actions; an abstraction of all possible behaviors.
Unpaid
Start End
PaidInvoice created payin
gInvoice destroying
SampleImplementation of
UML
29
Hotel Reservation [USE CASE]
(1) Identify the actors.(2) Identify the responsibilities of
each role.(3) Identify the use cases by
considering what the system can offer.
30
Hotel Reservation [USE CASE]
(1) Identify the actors.
staff customer guest management front desk laundry service room service
31
Hotel Reservation [USE CASE]
(2) Identify the responsibilities of each role.
Staff includes management, front desk, laundry service, room service
Each actor is considered individually. Dividing the responsibilities based on
the description gives the following breakdown:
32
Hotel Reservation [USE CASE]
i) front desk
accept reservationcancel reservationassign roomscheck in guestscheck out guestsreceive payment
33
Hotel Reservation [USE CASE]
ii) room service
provide room servicelaundry serviceprovide laundry service
iii) customer
make reservationcancel reservation
34
Hotel Reservation [USE CASE]
iv) guest check in check out
v) managementneed for increasing rooms based on non availabilityoccupancy raterevenue from servicesreservation pattern based on holidays and conventionscorporate customer reservations
35
Hotel Reservation [USE CASE]
(3) Identify the use cases by considering what the system can offer.
A set of use cases can be derived by grouping the related actions together
accept reservation AcceptReservationcancel reservation CancelReservationassign rooms AssignRoomscheck in guests CheckInGuestscheck out guests CheckOutGuestsreceive payment ReceivePaymentprovide room service ProvideRoomServiceprovide laundry service
ProvideLaundryService
36
Hotel Reservation [USE CASE]
Consider any other possible situations.You can also consider different situations representing the use case.
ExampleWhen a person walks into the hotel without any reservation and wants to
stayNotice that the current use cases cannot handle this situation.We discover the need to separate two possible situations where a guest
may use our hotel.
i) Walk in ii) Previous reservation made
i) Walk inThe walk in use case represents the situation when no previous
reservations were made.The customer walks into the hotel and wants to stayA new class may be created to represent this use case. This use
case comprises a combination of the following existing use cases:
a) accept reservationb) assign roomsc) check in guests
37
Hotel Reservation [USE CASE]
38
Hotel Reservation [Analysis Class Diagram ]
(1) Identify the nouns and model the concepts as classes and adjectives as attributes.
(2) Identify the possible attributes by looking at how to describe each concept.
(3) Test the 3 relationships between the classes, has a or part of, uses or depends on, kind of or is a.
(4) Consider the range, default and limitations of each attribute.
39
(1) Identify the nouns and model the concepts as classes and adjectives as attributes.
(2) Identify the possible attributes by looking at how to describe each concept.
Guidelines in abstracting the possible classes and attributes
You may also include the adjectives as adjectives represent descriptions.
Adjectives become the attributes. When absolute values are mentioned, it
represents an attribute.
Hotel Reservation [Analysis Class Diagram ]
40
Hotel Reservation [Analysis Class Diagram ]
Example $250 for a twin roomDescriptions attached to the nouns indicate possible
specializations.
ExampleSingle room, Twin room, SuiteRoom can be thought of as the general class and the single
and twin as specialized classes.If there are no additional attributes or operations in the
specialized classes, it is possible to replace the specialized classes by an attribute.
In this example the suite is described by a name. A set of specialized classes is used.
To represent the type of roomThis indicates that an attribute has to be defined in a room
class to hold the value.
41
Hotel Reservation [Analysis Class Diagram ]
i) Abstracting the nouns from the description gives the following:
hotel, branch, reservation, room, room no, customer, Customer’s name
Contact address, Country, Sex, Type of accommodations, and number of rooms required
Names of the people and the type of room they needPeriod of stay, Expected check in date, reservation
identity, Block bookings, agencies, payment, Credit card, Credit card type, number and issuing company
Traveler’s checks, Check No., issuing company, Direct corporate billing corporate account number, Cash, room rate, $10 for breakfast, $10 for lunch, $10 for dinner, Reservation, Name of the guest’s expected, Type of payment, Shirt $5, Suits $12, Dress $8, Trousers $9, Others $6, suite, single, twin, Single $150, Twin $250, Suite $550
42
Hotel Reservation [Analysis Class Diagram ]
ii) Organizing the nouns and adjectives gives the following:
SystemHotel represents the system.
Possible classes
The following gives the potential classes and the possible attributes from the list of nouns and adjectives.
43
Hotel Reservation [Analysis Class Diagram ]
ReservationReservation identityNo. of single rooms requiredNo. of twin rooms requiredNo. of suite rooms requiredbreakfastlunchdinner
Meal chargetype of mealcost
44
Hotel Reservation [Analysis Class Diagram ]
Guestname
Single roomroom no.rate
Twin roomroom no.rate
Suiteroom no.ratesuite name
Customername, contact address, country, sex,
Cash paymentamount
Credit card paymentamount, Credit card type, number and issuing company
Traveler’s check paymentamount, Check No., issuing company
45
Hotel Reservation [Analysis Class Diagram ]
Direct corporate billing paymentamount, corporate account number
Laundry chargetype of clothing cost per piece
Laundry usedate of use No. of piecestype of clothing
Room service chargetype of servicecost
46
Hotel Reservation [Analysis Class Diagram ]
(3) Test the 3 relationships between the classes, has a or part of, uses or depends on, kind of or is a.
Generalization specialization Traveler’s check, Direct corporate billing,
cash and credit card are types of payment.The general class is abstracted.
paymentamount
47
Hotel Reservation [Analysis Class Diagram ]
Aggregationlaundry use is a set of objects.laundry usage has many laundry items.An aggregation can be used to represent laundry.
AssociationThe following shows the type:Customer makes reservation.rooms are assigned to the reservation.guests belonging to the reservationreservation requires meals Reservation has a payment attached.Payment comprises meals, room service, laundry service and room chargeWhen rooms are assigned to the reservation, an assignment class representing
the association is created.The reservation object is associated with room objects through the room
assignment object. Each room object is related through one room assignment object to the reservation.
This means one reservation may have one or more rooms.One customer can make one or more reservations.One reservation may have one or more guests.Each reservation can have the meal options.
48
Hotel Reservation [Analysis Class Diagram ]
(4) Consider the range, default and limitations of each attribute.
laundry chargetype of clothing: Shirt, Suits, Dress, Trousers, Otherscost per piece: 5, 12, 8, 9, 6single roomroom No.: 100 to 149, 200 to 249rate 150twin roomroom No., 150 to 199, 250 to 299rate 250suiteroom No., 300, 301, 302rate 550suite name Royal suite, Presidential suite, Honeymoon suite meal chargetype of meal breakfast, lunch, dinnercost: $10
49
50
[Statecharts](1) Consider the state changes induced by the use case.
Now that we have a set of classes, we can consider how the objects representing each class is affected by the use cases.
The following shows the possible state changes and the classes affected:
accept reservation use caseThe reservation object is created and the state is unpaid and room
Unassigned.It can also be a Block reservation if the reservation is made by the
agency.Or a Not Block reservation
assign roomsThe reservation object goes from room Unassigned to rooms Not
checked in state but is still in the unpaid state.The association object (Room Assignment) is created with the state
assigned Not check in.To represent the relationship between the reservation and the room
check in guestsThe reservation object goes from rooms Not checked in state to
Partial check Out when the first guest checks in.The Room Assignment object goes from the assigned Not check in to
Assigned Check in.A change back to the same state is also allowed in this use case.The reservation object goes from Partial check Out state to Partial
check Out when the other guests checks in.If the last guest comes in then it becomes All Guest Check in.
51
cancel reservationThe reservation object goes from Rooms Not checked in if rooms are assigned or Room
Unassigned to Cancelled if the whole reservation is cancelled.A change back to the same state is also allowed in this use case.This represents the situation where only some guests are cancelled.The reservation object goes from Rooms Not checked in to Rooms Not checked in.
check out guestsThe reservation object goes from Unpaid to paid if the type of payment is cash, check
or credit card.The payment takes place in the check out.If the type of payment is corporate, a different payment use case takes place after the
checkout representing the payment received from the corporate.The reservation also goes from the Partial check in or all guest checked in to the partial
checked out if the there are still guests remaining in the hotel for the reservation.A change back to the same state is also allowed in this use case.The reservation also goes from partial checked out to partial checked out when the
guests checked out.When the last guest checked out, the reservation goes to the All guest checked out.The Room Assignment object goes from the assigned Not check in to Assigned
Checkout.receive payment
This is done either the checkout or a different use case depending upon the Type of payment.If the type of payment is corporate the payment is a separate use case as the Hotel have to wait for notification of payment from the company.For the other payment types, direct payment is made when the guests checked out
provide room serviceThe room service usage object is created.
provide laundry serviceThe laundry service usage object is created.
[Statecharts]
52
53
54
Activity DiagramThe activity diagram shows the actual steps performed in the
use case. It looks like a flowchart with the decisions represented by a diamond and the tasks represented by a box.
(1) Make ReservationThe following shows the related tasks and decisions made
when a reservation is made.- A customer specifies the type of accommodation, number
required, period of stay, and expected check in date.- The person at the front desk checks the availability, and if
available, the following additional information is requested:Name and Contact telephone of the person making the
reservationName of the guest’s expectedType of room for them - The person at the front desk also asks if any combination of
the meals is required, i.e. breakfast, lunch or dinner.- The person at the front desk then informs the customer of
the reservation identity.
55
56
57
58
59
60
61
62
63
64
65
66
Continuation….
67
68
69
70
71
72
73
74
Recommended