UML1
UML1
Multiplicity – the
minimum and
maximum number
of occurrences of
one object/class
for a single
occurrence of the
related
object/class.
Aggregation
Composition – an
aggregation
relationship in
which the “whole”
is responsible for
the creation and
destruction of its
“parts.” If the
“whole” were to
die, the “part”
would die with it.
Messages
Override – a technique
whereby a subclass
(subtype) uses an
attribute or behavior of
its own instead of an
attribute or behavior
inherited from the class
(supertype).
UML Diagrams
• Use-Case Model Diagrams
• Static Structure Diagrams
– Class diagrams
– Object diagrams
• Interaction Diagrams
– Sequence diagrams
– Collaboration diagrams
• State Diagrams
– Statechart diagrams
– Activity diagrams
• Implementation Diagrams
– Component diagrams
– Deployment diagrams
The Process of Object Modeling
ระบบการสั่งซื้อของทางโทรศัพท์ ต้องประกอบด้วย
สิ่งที่มาเกี่ยวข้อง (Actor) และหน้าที่ หรือเหตุการณ์
(Use Case) ที่จะเกิดขึ้นของแต่ละ Actor ดังนี้
ลูกค้าโทรศัพท์ไปหาเซลล์ เพื่อตรวจสอบว่ามีสินค้า
หรือไม่ ถ้ามีสินค้าก็จะทำการสั่งซื้อ ฝ่ ายจัดส่งสินค้าก็
จะกรอกแบบฟอร์มรายละเอียดของลูกค้าเพื่อจัดส่ง
ลูกค้าก็จะทำการจ่ายเงินด้วยเครคิตกับผู้จัดการ
ระบบการสอบของมหาวิทยาลัยแห่งหนึ่งเป็ นดังนี้
The project manager is a user who is responsible for ensuring the success of
project and uses the system to manage projects.
58
Actor
- A person or system that derives benefit
from and is external to the system.
- Participates in a sequence by sending
and/or receiving messages.
- Is placed across the top of the diagram.
anActor
59
Object
- Participates in a sequence by sending
and/or receiving messages.
- Is placed across the top of the diagram.
- The name of the class that they are an
instance of is given after the object’s
name.
60
Lifeline
- Denotes the life of an object during a
sequence.
- Runs vertically below each actor and
object.
- Contains an “X” at the point at which the
class no longer interacts.
61
anObject:aClass
anActor
62
Focus of Control
- Is a long, narrow rectangle placed
atop a lifeline.
- Denotes when an object is sending
or receiving messages.
63
Message
- Conveys information from one object to
another one.
- If there is a condition to be met, the
condition is placed between a set of [ ] in
front of the message name.
- If a message is repeated, an * is placed
in front of the message name.
64
aMessage()
[condition] aMessage()
* aMessage()
65
Object Destruction
- An “X” is placed at the end of an object’s
lifeline to show that it is going out of
existence.
66
Sometimes an object will create
another object.
67
The actor aReceptionist creates an
object anAppt.
aReceptionist
CreateAppt()
anAppt:Appointment
68
http://bdn.borland.com/article/0,1410,31863,00.htm
Building a Sequence Diagram
1. Determine the context.
The context of the diagram can be a
system, a use case, a scenario of a use
case, or an operation of a class. Most
commonly, it is one use-case scenario.
75
2. Identify which objects will participate.
The objects are identified during the
development of the structural model.
These are the classes on which the
objects of the sequence diagram for this
scenario will be based.
76
4. Lay out the messages from the top to the
bottom of the diagram based on the
order in which they are sent.
77
Ecat:Catalog :LibraryItem Lib1:NetServer
:LibraryUser
Lookup()
Display()
Issue()
IssueLicence()
AcceptLicence()
Compress()
Deliver()
78
จาก USE CASE การออกสอบข้างต้น จงแสดงลำดับการส่งข้อมูลกันอย่างไร
An instructor first notifies the students of the exam date and the
material to be covered.
The instructor then gives the exam papers to the TAs, along
with sample solutions to each question, and gets them to mark
it. She then records all marks and returns the papers to the
students.
89
- Equivalent to sequence diagrams:
90
Elements of a Collaboration
Diagram
• Actor
• Object
• Association
• Message
91
Actor
- A person or system that derives benefit
from and is external to the system.
- Participates in a sequence by sending
and/or receiving messages.
anActor
92
Object
- Participates in a sequence by sending
and/or receiving messages.
anObject:aClass
93
Association
- Shows an association between actors
and/or objects.
- Messages are sent over associations.
94
Message
- Conveys information from one object to
another.
- Direction is shown using an arrowhead.
- Sequence is shown by a sequence
number.
- If there is a condition to be met, the
condition is placed between a set of [ ] in
front of the message name.
95
- If a message is repeated, an * is placed
in front of the message name.
1:aMessage()
96
Building a Collaboration
Diagram
1. Set the context.
2. Identify which objects and associations
between the objects will participate in the
collaboration.
3. Lay out the collaboration diagram.
4. Add messages.
5. Validate the collaboration diagram.
97
Ecat:Catalog :LibraryItem Lib1:NetServer
:LibraryUser
Lookup()
Display()
7:Deliver()
en e(
se )
()
Lib1:NetServer :LibraryItem
6:Compress()
98
collaboration diagram
Class diagrams
Class diagram gives an overview of a system by showing its
classes and the relationships among them. Class diagrams are
static -- they display what interacts but not what happens
when they do interact.
Attribute specification
The class diagram below models a customer order from a
retail catalog. The central class is the Order. Associated
with it are the Customer making the purchase and the
Payment. A Payment is one of three kinds: Cash,
Check, or Credit. The order contains OrderDetails (line
items), each with its associated Item.
Sr. Relation Symbol Description
No.
1 Association When two classes are connected to each
other in any way, an association relation
is established. For example: A "student
studies in a college" association can be
shown as:
•This system provides the basic services to manage bank accounts at a bank
called OOBank. OOBank has many branches, each of which has an address
and branch number. A client opens accounts at a branch. Each account is
uniquely identified by an account number; it has a balance and a credit or
overdraft limit. There are many types of accounts, including: A mortgage
account (which has a property as collateral), a chequing account, and a
credit card account (which has an expiry date and can have secondary
cards attached to it). It is possible to have a joint account (e.g. for a husband
and wife). Each type of account has a particular interest rate, a monthly fee
and a specific set of privileges (e.g. ability to write cheques, insurance for
purchases etc. OOBank is divided into divisions and subdivisions (such as
Planning, Investments and Consumer), the branches are considered
subdivisions of the Consumer Division. Each division has a manager and a
set of other employees. Each customer is assigned a particular employee as
his or her ‘personal banker’.
Draft Class Diagram with clsses Client and
Account, and their association
Client
1..2
accountHolder
*
Account
accountNumber
type
Draft Class Diagram with Account attributes and
subclasses
Client
* 1..2
accountHolder
*
Account
accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance
creditOrOverdraftLimit
*
Account
accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance CreditCard
creditOrOverdraftLimit
name
1..*
Branch
* *
Account
accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance CreditCard
creditOrOverdraftLimit
name
1..*
subdivision
*
OrganizationalUnit 0..1
manager
0..1 *
0..1
Employee Client
* 1..2
personalBanker accountHolder
Branch
* *
Account
accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance CreditCard
creditOrOverdraftLimit
name
1..*
subdivision
*
OrganizationalUnit 0..1
manager
0..1 *
0..1
AccountType Employee Client
* 1..2
interestRate personalBanker
monthlyFee accountHolder
checksAllowed
insuranceAvailable
Branch *
* *
Account
accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance CreditCard
creditOrOverdraftLimit
name
1..*
Person
subdivision name
*
OrganizationalUnit 0..1
manager
0..1 *
0..1
AccountType Employee Client
* 1..2
interestRate personalBanker
monthlyFee accountHolder
checksAllowed
insuranceAvailable
periodicFee
period
Branch *
* *
address Account
number accountNumber
openedDate
closedDate
interestRate
monthlyFee
balance CreditCard
creditOrOverdraftLimit
name
1..*