Domain Model I
Lecture 4
1
Case requirements
The requirements for the first iteration of the NextGen
POS:
Implement a basic, key scenario of the Process Sale
use case
Implement a Start Up use case as necessary to
support the initialization needs of the iteration
Nothing fancy or complex is handled
No collaboration with external services
No complex pricing rules are applied
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
2
Incremental Development
Incremental development for the same use case
across iteration
1
Use Case
Process Sale
2
3
...
Use Case
Process Sale
Use Case
Process Sale
A use case or feature is
often too complex to
co p ete in o
complete
one
e sshort
ot
iteration.
Therefore, different parts
or scenarios must be
allocated to different
iterations.
Use Case
Process Rentals
Feature:
Logging
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
3
1
What is a domain model
A domain model is a visual representation of conceptual classes
or real-situation objects in a domain.
Various names
conceptual models, domain object models, analysis object
models
A domain model is illustrated with a set of CLASS DIAGRAMS
in which no operations (method signatures) are defined
Input
Problem Description, Use Cases, …
Output
A set of class diagrams
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
4
Example
Sales
LineItem
concept
or domain
object
Item
Records-sale-of
1
0..1
quantity
*
1..*
association
Stocked-in
Contained-in
1
1
Sale
attributes
date
time
Store
address
name
0..1
1
1
Houses
Paid-by
1
Payment
1..*
Register
Captured-on 4
1
amount
Identifying a rich set of conceptual classes is at the heart of OO analysis
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
5
Domain models is a visual
dictionary
Domain model provides a conceptual
perspective
Domain objects or conceptual classes
Associations between conceptual
p
classes
Attributes of conceptual classes
The information it illustrates could
alternatively have been expressed in plain
text
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
6
2
Object and Class concepts
Object is a thing with unique identity in a
problem domain
Joe Smith, the University of Sydney,
Australia are all objects
All objects have identity and are
distinguishable
Two apples with the same color, shape, and
texture are still individual apples
Objects are distinguished by their inherent
existence and not by descriptive properties that
they may have
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
7
Classes
A class describes a group of objects with the same
properties, behaviour and possible relationships.
An object is an instance of a class
Person, University and Country are classes
Domain objects are the focus of modelling
Why bother with conceptual class?
The power of abstraction
The level of abstraction is a matter of judgement and is
related with the application.
Client’s description of a future system may have a
combination of classes and objects
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
8
object & class diagram
Person
JoeSmith : Person
Class
MarySharp : Person
: Person
Objects
Person
JoeSmith : Person
MarySharp : Person
-name : string
-dob : Date
name : string = Joe Smith
dob : Date = Oct 21 1983
name : string = Mary Sharp
dob : Date = March 16 1980
Class with Attributes
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
Objects with Values
9
3
Class and conceptual class
Domain model is a
Sale
visualization of things in
dateTime
a real-world domain of
interest
Domain model should
not show software
oid
av
classes
av
visualization of a real-world concept in
the domain of interest
it is a not a picture of a software class
SalesDatabase
software artifact; not part
of domain model
Sale
oid
software class; not part
of domain model
date
time
print()
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
10
Domain model vs. Data model
Data model – persistent data to be stored
somewhere
Domain model also include
Temporary
p
y object
j
Object with no attribute
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
11
Motivation
Help to understand the key concepts in a business or problem domain
Lower representational gap with OO Modeling
UP Domain Model
Stakeholder's view of the noteworthy concepts in the domain.
A Payment in the Domain Model
is a concept, but a Payment in
the Design Model is a software
class. They are not the same
thing but the former inspired the
thing,
naming and definition of the
latter.
Payment
Sale
1 Pays-for
1
date
time
amount
inspires
objects
and
names in
This reduces the representational
gap.
Sale
This is one of the big ideas in
object technology.
Payment
amount: Money
getBalance(): Money
1
Pays-for
1
date: Date
startTime: Time
getTotal(): Money
...
UP Design Model
The object-oriented developer has taken inspiration from the real world domain
in creating software classes.
Therefore, the representational gap between how stakeholders conceive the
domain, and its representation in software, has been lowered.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
12
4
How to create a Domain Model
Steps
Find the conceptual classes
Draw them as classes in a UML class diagram
Add
dd assoc
associations
a o sa
and
da
attributes
bu es
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
13
Find conceptual classes
Three strategies to find conceptual classes
Reuse or modify existing models
There are published, well-crafted domain models
and data models for common domains: inventory,
finance,, health..
Books: Analysis patterns by Martin Fowler, Data
Model Patterns by David Hay, Data Model
Resource Book by Len Silverston
Use a category list
Identify noun phrases
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
14
Use a category list
Use a conceptual class category list:
Physical or tangible objects
Register, Airplane
Specifications, descriptions of things
ProductSpecification, FlightDescription
Places
Pl
Store, Airport
Transactions
Sale, Payment, Reservation
etc. (see Table 9.1 for a fuller list)
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
15
5
Noun Phrase Identification
Noun Phrase Identification [Abbot 83]
Analyze textual description of the domain
Identify nouns and noun phrases
(indicate candidate classes, objects or
attributes)
Caveats:
Automatic mapping isn’t possible
Textual descriptions are ambiguous!
(different words may refer to the same class,
people may refer to things at different abstract
levels: class, object, or somewhere in between)
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
16
Example: a typical description
An institution may issue many credit card accounts, each
identified by an account number. Each account serves
one or more customers who reside at the mailing
address. The institution periodically issues a statement
for each account.
account The statement lists a payment due
date, finance charge, and minimum payment. The
statement itemizes various transactions that have
occurred through the billing interval: cash advances,
interest charges, purchases, fees and adjustments to
the account. The name of the merchant is associated
for each purchase.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
17
Mapping parts of speech to object model
components
CreditCardAccount
MailingAddress
Institute
-maximumCredit
-currentBalance
-accountNumber
Statement
Customer
Transaction
-statementDate
paymentDueDate
-paymentDueDate
-minimumpayment
-financeCharge
CashAdvance
Interest
Purchase
-transactionDate
-explanation
Fee
Adjustment
Merchant
-name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
18
6
Example: find and draw conceptual
classes
Case study: POS Domain
Input
fully dressed use case model (excellent textual
description of the domain)
Iteration
Iteration-1:
1: success (cash
(cash-only)
only) scenario of Process
Sale use case.
Strategy: category list & noun phrase identification
There is no such thing as a “correct” list. It is a
somewhat ARBITRARY collection of domain
vocabulary that the modelers consider NOTEWORTHY
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
19
POS Domain model:Input
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
20
Initial POS domain model
Register
Item
Store
Sale
Sales
LineItem
Cashier
Customer
Ledger
Cash
Payment
Product
Catalog
Product
Description
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
21
7
Agile modeling style
It is normal to miss significant conceptual
classes during early domain modeling and to
discover them later during DESIGN sketching
or PROGRAMMING.
We can maintain the model by drawing it with
a software engineering tool
OFTEN, a long-life OO analysis domain
model does not add value
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
22
Include report objects?
Receipt is a noteworthy term in POS domain
It has duplicate information contained in sale and
payment.
Guidelines
In
I general,l showing
h i a reportt off other
th information
i f
ti in
i a
domain model is not useful
However, it might has special role in terms of business
rules. We might have a reason to show it in the model.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
23
Associations
Definition
An association is a relationship between objects that
indicates some meaningful and interesting connection
Objects are usually “linked” by a ( or a number of ) physical
or conceptual connections.
Casher “Joe Smith” works on Register
g
“12”.
Flight “QF435” flies from “Sydney” to “Melbourne”
association
Register
Records-current
1
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
1
Sale
24
8
When to show association
Associations for which knowledge of the relationship
needs to be preserved for some duration
In the POS domain
We need to remember what SalesLineItem instances are
associated with a Sale.
C hi may look
Cashier
l k up ProductionDescription
P d ti D
i ti d
during
i th
the
process of sale, but we do not need to remember who
looked up what after the sales has been made.
We should avoid showing too many associations
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
25
Associations and implementation
There is no direct relationship between
associations and implementation.
Associations do not indicate a certain
implementation
p
construct.
Many associations may be implemented in
software differently
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
26
Association Notation
-"reading direction arrow"
-it has no meaning except to indicate direction of
reading the association label
-often excluded
Register
Records-current 4
1
association name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
0..1
Sale
multiplicity
27
9
Naming association
Name an association based on a
ClassName-VerbPhrase-ClassName format
Eg.
Sales p
paid-by
y CashPayment
y
Piece is-on Square
Bad alternative: Sales uses CashPayment
Bad alternative: Piece has Square
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
28
Applying UML: multiplicity
Multiplicity defines how many instances of a class A
can be associated with one instance of class B
Store
Stocks
1
Item
*
multiplicity of the role
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
29
Multiplicity values
Multiplicity focus on the
relationship at a particular
moment, rather than over a
span of time.
Eg. “In countries with
monogamy laws, a person
can be
b Married-to
M i d t only
l one
other person at any
particular moment, even
though over a span of time,
that same person may be
married to many persons.”
*
1..*
1..40
5
3, 5, 8
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
T
zero or more;
"many"
T
one or more
T
one to 40
T
exactly 5
T
exactly 3, 5, or 8
30
10
Object diagram may help to determine
the multiplicity
Country
-has capital
CipitalCity
-name
Class diagram
-name
1
China : Country
1
-has capital
Beijing : CipitalCity
name = China
name = beijing
object diagram
France : Country
-has capital
name
Paris : CipitalCity
name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
31
Object Diagram to Class Diagram
Person
-owns stock of
?
Company
?
-owns stock of
Mary : Person
GE : Company
-owns stock of
Sue : Person
IBM : Company
Jeff : Person
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
32
Multiple association between two
classes
Description :Flight “QF435” flies from “Sydney” to “Melbourne”
-fly from
-fly from
Flight
City
-fly to
1
1
1
1
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
QF435 : Flight
Sydney : City
-fly to
Melbourne : City
33
11
Reflexive association
A conceptual class may have association with
itself
Eg. A Directory can contain other directories
Eg. A node in a liked list is linked to another
node
-contains
1
Directory
-linked to
*
1
Node
1
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
34
Discussion Question
Prepare a class diagram from the object diagram
below
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
35
Find association
Use the common associations list
A is a physical part of B
A is a logical part of B
A uses or submanages B
Square - Board
SalesLineItem - Sale
Cashier- Register
etc. (see table 9.2 on p. 155 for a fuller list)
Omit associations that can be defined in terms of other associations.
Multiple paths between classes may indicate redundancy
However
keep the extra association if multiplicity is important.
Keep the extra association if they represent an important
relationship in the real world.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
36
12
The Credit card problem
An institution may issue many credit
card accounts, each identified by an
account number. Each account
serves one or more customers who
reside at the mailing address. The
institution periodically issues a
statement for each account. The
statement lists a payment due date
date,
finance charge, and minimum
payment. The statement itemizes
various transactions that have
occurred through the billing interval:
cash advances, interest charges,
purchases, fees and adjustments to
the account. The name of the
merchant is associated for each
purchase.
CreditCardAccount
-serve
MailingAddress
1
*
*
-maximumCredit
-currentBalance
-accountNumber
-issue
*
Institute
1
-reside
1
-is issued for
*
*
Statement
Customer
-statementDate
-paymentDueDate
-minimumpayment
i i
t
-financeCharge
CashAdvance
Interest
Purchase
*
Transaction
-itemize
-transactionDate
-explanation
l
ti
*
1
Fee
Adjustment
-is made to
1
Merchant
-name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
37
POS partial domain model
Records-sale-of
Ledger
Product
Description
Product
Catalog
Contains
1
1..*
1
1
Recordsaccountsfor
0..1
Sales
LineItem
1
Used-by
Describes
*
*
Store
Item
Stocks
1
1
*
1 *
1..
1..*
Contained-in
1
Logscompleted
1
*
Sale
Houses
1..*
Register
Captured-on
0..1
1
Paid-by
1
1
1
Is-for
1
CashPayment
Customer
1
3 Works-on
1
Cashier
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
38
Attributes
An attribute is a logical data value of an
object
When to show attribute
Include attributes that the requirements
s ggest or imply
suggest
impl a need to remember
information
Eg.
Sale needs a dateTime attribute
Store needs a name and address.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
39
13
UML notation
Attributes are shown in the second compartment of the class box.
Type and other information may optionally be shown
Derived attribute
The total attribute in the Sale can be calculated from other
information
It is worth noting down.
Math
Sale
- dateTime : Date
- / total : Money
Private visibility
attributes
Person
+ pi : Real = 3.14 {readOnly}
firstName
middleName : [0..1]
lastName
Public visibility readonly
attribute with initialization
Optional value
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
40
Suitable attribute types
Most attribute types
should be what are
often thought of as
“primitive” data types
Relate conceptual
classes with an
association, not with an
attribute
Cashier
not a "data type" attribute
Worse
name
currentRegister
Cashier
1
Better
Uses
Worse
Register
1
name
number
Flight
destination is a complex
concept
destination
Better
Flight
1
Flies-to
1
Airport
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
41
Class or Attributes
Class or attribute?
If we do not think of some conceptual class X as a
number or text in the real world, X is probably a
conceptual class, not an attributes
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
42
14
Data types as attributes
We sometimes represent what may initially be considered a number or
string as a new data type class in the domain model
We can show the data type only in attribute compartment or as a
separate class associated with another class.
Address
ItemID
OK
OK
1
Product
Description
1
Store
id
manufacturerCode
countryCode
Product
Description
1
1
street1
street2
cityName
...
Store
address : Address
itemId : ItemID
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
43
Attributes are NOT foreign keys
During implementation, there are many ways to relate
objects, including foreign key, but the decision should
be deferred till DESIGN stage.
Cashier
a "simple" attribute, but being
used as a foreign key to relate to
another object
Worse
name
currentRegisterNumber
Cashier
1
Better
Works-on
Register
1
name
number
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
44
Description Class
What’s the rationale for representing the description or specification separately
from the item
In the following domain model, can you tell the difference between (description,
price, itemID) and serial number?
Item
Worse
description
price
serial number
itemID
ProductDescription
description
price
itemID
Item
Describes
1
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
*
Better
serial number
45
15
Description classes
When are description classes
useful?
There needs to be a
description about an item or
service, independent of the
current existence of any
examples of those items or
services
Deleting instances of things
they describe results in a
loss of information that
needs to be maintained, but
was incorrectly associated
with the deleted things
It reduces redundant or
duplicated information
Flight
date
number
time
Airport
Flies-to
Worse
1
*
Flight
FlightDescription
Described-by
date
time
*
name
1
Better
number
*
Describes-flights-to
1
Airport
name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
46
Iterative and evolutionary domain
model
Is the domain model correct?
There is no such thing as a single correct
domain model!
Domain model is incrementally evolve over
several iterations.
In each iteration, the domain model is limited
to the prior and current scenarios under
consideration.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
47
Discussion Question II
Prepare a domain model to describe undirected
graphs. An undirected graph consists of a set of
vertices and a set of edges. Edges connect pairs of
vertices.
How would you modify the model to describe directed
graphs?
h ?
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
48
16
Generalization
We can identify commonality among concepts and
define super class (general concept) and sub class
(specialized concept) relationships in a domain model
superclass - more general
concept
Payment
these are conceptual
classes, not software
classes
Cash
Payment
Credit
Payment
Check
Payment
subclass - more
specialized concept
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
49
Conceptual super class and sub
class
100% rule
100% of the conceptual superclass’s definition
should be applicable to the subclass. The subclass
must conform to 100% of the superclass’s
Attributes
Associations
Is-a rule
All the instances of a subclass must be
instances of their superclasses.
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
50
Conceptual subclass
When to define a conceptual subclass?
The subclass has additional attributes of interest
The subclass has additional associations of interest
The subclass concept is operated on, handled, reacted to, or
manipulated differently than the superclass or other
subclasss, in a way that are of interest
The subclass concept represents an animated thing (for
example, animal, robot) that behaves differently than the
superclass or other subclasses in a ways that are of interest
Correct subclasses.
Customer
But useful?
Male
Customer
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
Female
Customer
51
17
Example subclass partitions
Conceptual Subclass Motivation
Examples
Additional attributes of interest
Book, subclass of LoanableResource,
has an ISBN attribute.
Subclass has additional associations
of interests
CreditPayment, subclass of Payment,
is associated with a CreditCard class.
The subclass is operated upon
upon,
handled, reacted to, or manipulated
differently
CreditPayment, subclass of Payment,
CreditPayment
Payment
is handled differently than other kinds of
payments in how it is authorized
The subclass concept represents an
animated thing that behaves
differently than the superclass or
other subclasses
Car, Truck are subclasses of
PoweredVehicle, Car behaves
differently from Truck
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
52
When to define a conceptual
superclass
Create a conceptual superclass in a generalization
relationship to subclass when
The potential conceptual subclasses represent
variations of a similar concept
The subclasses will conform to the 100% and Is-a
Is a rule
All subclasses have the same attribute which can be
factored out and expressed in the superclass
All subclasses have the same association which can
be factored out and related to the superclass
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
53
Example
Transaction
-transactionDate
-explanation
CashAdvance
Interest
Purchase
*
Fee
Adjustment
-is made to
1
Merchant
-name
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
54
18
Thanks
COMP5028 Object-Oriented Analysis and Design
© Dr. Ying Zhou, School of IT, The University of Sydney
55
19
© Copyright 2026 Paperzz