Lecture 6
Lecture 6
Iram Rubab
Outline
• What is Domain Model?
• Why Domain Model?
• Features of Domain Model
• Syntax of Domain Model
• Examples on Various Case Studies
Revision up till now
10
A Domain Model is Conceptual, not a Software Artifact
Sale SalesDatabase
amt
item vs. Sale
Double amt;
Item item;
What’s the void print()
difference?
WHY DOMAIN MODEL? 12
Why do a domain model?
• Gives a conceptual framework of the things in the problem space
• Helps you think – focus on semantics
• Provides a glossary of terms – noun based
• Foundation for use case/workflow modelling
• Based on the defined structure, we can describe the state of the problem domain
at any time.
SYNTAX OF DOMAIN MODEL 14
Notation – UML Class Diagram
• UML class diagram is used to model a domain with a twist
• Domain Class
• Domain class consist of class name and attributes
• Domain class does not have methods
• Relation
• A line with a label represents the relation between two classes
• A relation has a cardinality constraint
15
Q2
Syntax of Domain Model
Conceptual Class:
Attributes
EXAMPLE: Partial Domain
Model
1
Rents4 1..*
Customer VideoStore
Video
address Rents-from 4 address Stocks4
name
* 1
name 1 * ID
phoneNumber phoneNumber
HOW TO CREATE DOMAIN MODEL 18
How to Create Domain Model
• Find conceptual classes
19
Finding Conceptual Classes
1. Reuse or modify the existing model if one exists
• There are many published, well-crafted domain models.
2. Domain Experts
20
Reuse or Modify Existing Models
• There are published, well--‐crafted domain models and data
models (which can be modified into domain models) for many
common domains, such as inventory, finance, health, and so
forth..
21
Identify Noun Phrase in Use Cases
Basic Flow for a POS System
1. Customer arrives at a POS checkout with goods and/or
services to purchase
2. Cashier start a new sale
3. Cashier enters item identifier
4. System records sale line item and presents item
description, price, and running total
5. …
22
List and Draw UML Diagram
• Sale • Register
• SaleLineItem • Cashier
• Item • …
1. Decide which ones are classes and which ones are attributes
2. Add attributes and relation to the identified domain classes
23
Part of POS System
24
Association Notations
Association name:
Reading direction:
Use verb phrase
Can exclude if
Capitalize
association reads left-
Typically camel-case or
to-right or top-to-
hyphenated
bottom
Avoid “has”, “use”
Multiplicity (Cardinality):
‘*’ means “many”
x..y means from x to y 25
inclusively
Cardinality (or Multiplicity)
zero or more;
* T
"many"
1..*
T one or more
1..40
T one to 40
5
T exactly 5
26
3, 5, 8
T exactly 3, 5, or 8
UML: Multiplicity
zero or more;
* T
"many"
Customer
One instance of a
1..*
T one or more Customer may be
0..1
27
renting zero or more
Videos.
Rents
1..40
T one to forty One instance of a Video
may be being rented by
* zero or one Customers.
5
T exactly five Video
3, 5, 8 exactly three,
T
five or eight
Attributes
• An object’s logical data value that must be remembered
• Some attributes are derived from other attributes
dateTime
28
/ total : Money derived
attribute
Visibility in Domain Models
VideoRental
0..1
CashPayment RentalTransaction
Pays-for 4 1 dueDate
amount : Money 1 1 date 1 returnDate
1 1..*
returnTime
* *
Initiates 4
Records-rental-of
1 1
Rents4
Notice how this can
1..*
be viewed as a
“visual dictionary.”
31
Customer VideoStore
Video
Rents-from 4 address
address Stocks4
It illustrates
name
* 1
name 1 * ID 1
concepts, words,
phoneNumber phoneNumber
1
* * things in a domain.
1
1
Has Maintains
Owns-a 4
1 1
Membership * Catalog
ID 1
startDate
Described-by
1
1..*
LoanPolicy VideoDescription
Defines 1
perDayRentalCharge title
perDayLateCharge 1..* subjectCategory
1..* 1
Determines-rental-charge 4