L05-06 Domain Models (Ch09)
L05-06 Domain Models (Ch09)
& Design
面向对象的分析与设计
1
Part 3: Elaboration Iteration 1 Basics
2
Chapter 9 . Domain Models
• Obiectives:
• Identify conceptual classes related to the current iteration
• Create an initial domain mode
• Model appropriate attributes and associations
3
Introduction
4
Sample UP Artifact Relationships
Domain Model
Design Model
enterItem
Design (itemID, quantity)
...
5
A Domain Model Example
concept Sales
Item
or domain LineItem Records-sale-of
object quantity 1
0..1
1..* *
Stocked-in
association Contained-in
1 1
Sale Store
attributes date address
time name
1
1
1
Houses
Paid-by 1..*
1 Register
Captured-on
Payment
1
amount
6
Domain Models within the UP
7
Domain Model
• Domain model
• illustrates meaningful conceptual classes in the problem domain
• is a source of inspiration for design software objects
• A domain model can be illustrated by a set of UML class diagrams
• Domain objects or conceptual classes
• associations between conceptual classes
• attributes of conceptual classes
• Identify a rich set of objects or conceptual classes is at the
heart of OOA.
If it is done with skill and short time investment (no more than a few
hours in each early iteration) , it usually pays off during design ,
when it supports better understanding and communication
8
Domain Model
visualization of a real-
world concept in the
Sale domain of interest
9
Domain Models Are Not Models of Software
Components
Sale
void software class; not part
a date of domain model
time
print()
date
time Symbol:words or images representing a conceptual class
sale-1
sale-4
Extension:the set of examples to which the conceptual
class applies
11
Conceptual Classes
12
Motivation : Why Create a Domain Model ?
13
Lowering the Representational Gap
UP Domain Model
Stakeholder's view of the noteworthy concepts in the domain.
Payment Sale
A Payment in the 1 Pays-for 1
amount date
Domain Model is a time
concept, but a Payment
in the Design Model is a inspires
objects
software class. They are and
not the same thing, but names in
Therefore, the representational gap between how stakeholders conceive the domain,
and its representation in software, has been lowered.
14
How to Create a Domain Model?
15
How to find Conceptual Classes?
16
Well-crafted Domain Models
17
Well-crafted Domain Models
18
Well-crafted Domain Models
19
Well-crafted Domain Models
20
Well-crafted Domain Models
21
Well-crafted Domain Models
22
Well-crafted Domain Models
23
Use a Conceptual Class Category List
24
Use a Conceptual Class Category List
25
Use a Conceptual Class Category List
26
Finding Conceptual Classes with Noun
Phrase Identification
27
Finding Conceptual Classes with Noun
Phrase Identification
Extensions (or Alternative Flows):
…
7a. Paying by cash:
1. Cashier enters the cash amount tendered
2. System presents the balance due, and releases the cash drawer
3. Cashier deposits cash tendered and returns balance in cash to Customer
4. System records the cash payment
…
Sales
Cashier Customer Ledger
LineItem
29
Initial Monopoly Game Domain Model
30
Domain Modeling Guidelines (cont.)
31
Domain Modeling Guidelines (cont.)
33
When to Model with 'Description' Classes?
ProductSpecification
Item
description Describes Better
price
1 * serial number
itemID
34
Descriptions in the Airline Domain
• Consider an airline company that suffers a fatal crash of one of its planes.
Assume that all the flights are cancelled for six months pending completion of an
investigation. Also assume that when flights are cancelled , their corresponding
Flight software objects are deleted from computer memory . Therefore , after the
crash, all Flight software objects are deleted.
Flight
Airport
date Flies-to Worse
number
time
* 1 name
Flight
Better
date Described-by FlightDescription
time * 1 number
*
Describes-flights-to
1
Airport
name 35
Associations
• It's useful to find and show associations that are needed to satisfy the
information requirements of the current scenarios under development,
and which aid in understanding the domain.
• An association is a relationship between classes (more precisely,
instances of those classes) that indicate some meaningful and
interesting connection.
• In the UML , associations are defined as the semantic relationship
between two or more classifiers that involve connections among their
instances.
association
Records-current
Register Sale
1 1
36
When to show an association
37
The UML Association Notation
Records-current ►
Register Sale
1 0..1
38
How to Name an Asociation in UML
Airline
1
Employs
1..*
Assigned-to ◄ Assigned-to
Person Flight Plane
1 * * 1
1 *
S uperv is es 39
Roles
Stocks
Store Item
1 *
40
Multiplicity
* T
zero or more;
"many"
1..*
T one or more
1..40
T one to 40
5
T exactly 5
3, 5, 8
T exactly 3, 5, or 8
41
Multiplicity
42
Multiple Associations Between Two Types
* Flies-to 1
Flight Airport
Flies-from
* 1
43
Finding Association with a Common
Association List
Category Examples
A is a transaction related to another CashierPayment – Sale
transaction B Cancellation - Reservation
A is a line item of a transaction B SalesLineItem - Sale
A is a product or service for a Item – SalesLineItem (or Sale)
transaction (or line item) B Flight - Reservation
A is a role related to a transaction B Customer – Payment
Passenger - Ticket
A is a physical or logical part of B Drawer – Register
Square – Board
Seat - Airplane
A is physically or logically contained in / Register – Store
on B Item –Self
Square – Board
Passenger - Airplane
44
Finding Association with a Common Association
List
Category Examples
A is a description for B ProductDescription – Item
FlightDescription - Flight
A is known / logged / recorded / Sale – Register
reported / captured in B Piece – Square
Reservation – FlightManifest
A is a member of B Cashier – Store
Player – MonopolyGame
Pilot - Airline
A is an organizational subunit of B Department – Store
Maintenance - Airline
A uses or manages or owns B Cashier – Register
Player – Piece
Pilot - Airplane
A is next to B SalesLineItem – SalesLineItem
Square – Square
City - City
45
Associations in the Domain Model
Records-sale-of
Described-by
1
Product
Product Spec ific ation
C atalog Contains
1 1..*
1
0..1
* Used-by
Describes
Sales * *
LineItem Store
Item
Stoc k s
1 1
* 1..*
1..*
Logs- 1 Houses
Contained-in
c om pleted
1 1.. *
1
1
1 Initiated-by 1
Paid-by Records-sales-on
1 1 1
Initiated-by
Pay m ent Customer Cashier
1
46
Associations in the Domain Model
47
Associations in the Domain Model
48
Attributes
attributes
Sale
dateTime
/ total : Money derived
attribute
49
Attributes
50
Where to Record Attribute Requirements
51
What are Suitable Attribute Types
Cashier Register
1 Uses 1
Better
name number
52
Data Types
• Data Types: a set of values for which unique identity is not meaningful
(in the context of our model of system)
• Separate instances of the Number 5
• Separate instances of the String “cat”
• Separate instances of PhoneNumber that contains the same
number
• Separate instances of Address that contain the same address
• Attributes should generally be data types
53
When to Define New Data Type Classes
54
Where to Illustrate These Data Type Classes?
ItemID Address
Product 1 1 id 1 1
Store street1
OK Description
manufacturerCode street2
countryCode cityName
...
Product Store
Description
OK address : Address
itemId : ItemID
55
Modeling Attribute Quantities and Units
variation: Money is a
Payment specialized Quantity whose
amount : Money unit is a currency
56
Attributes in the NextGen Domain Model
Product
Payment Product
Specification
amount : Money Catalog
description : Text
price : Money
id: ItemID
57
NextGen POS Domain Model (with attributes)
Records-sale-of
Product
Ledger Product Description
Catalog Contains
1 itemID
1..*
description
1 1
1 price
0..1 Records-
Used-by Describes
accounts-
Sales for * *
LineItem Store
Item
Stocks
quantity 1 name
address
1
* 1..*
1..*
Contained-in 1 Houses
Logs-
1 completed 1..*
Sale * Register
dateTime Captured-on
id
0..1 1
/ total
1
1 1
Is-for Works-on
Paid-by
1 1 1
amountTendered id
58
Monopoly Game Domain Model (with attributes)
59
Conclusion
60
Homework
• 进行本组目标系统领域模型的建模。
61
Thanks