WS11 EiSE 07 Domain - Modeling PDF
WS11 EiSE 07 Domain - Modeling PDF
Michael Eichberg
Software Engineering
Department of Computer Science
Technische Universität Darmstadt
Exercise
The bonus is derived.
Solution task
submission date
achieved exercise points exercise points
An association is a relationship between classes.
The ends of an association are called roles.
Roles optionally have a multiplicity, name and
navigability.
Visualizing the Domain Model | 11
Student
attends ‣ Lecture ◀ reads Lecturer
*
*
name 1..* *
description name
/bonus : Percentage
1
2..3
owns ‣
consists of ‣
12..14
1 Exercise
solves ‣
StudyGroup task
* *
submission date
exercise points
Solution
The Domain Model is
achieved exercise points sometimes also called
a Visual Dictionary.
Domain Modeling
• Overview
Excerpt Of the Domain Model For the POS System
Domain Modeling | 16
?
Which are noteworthy domain concepts / domain
objects?
How to create the domain model?
(If we are not readily familiar with the domain.)
Domain Modeling | 17
}
a. Reuse or modify an existing model explained
b. Use a category list in the
c. Identify noun phrases following
2. Draw them as classes in a UML class diagram
3. Add associations and attributes
Use the domain vocabulary; e.g. a model for a library should use names
like “Borrower” instead of customer.
How to create the domain model?
To find the conceptual classes reuse or modify an
existing model.
Domain Modeling | 18
{balance = sum(entries.amount)}
1 0..* Entry
Acount
amount: Quantity
balance: Quantity
whenChanged: Timepoint
Classes
Conceptual Class Category
(for the POS system)
Business transactions... Sale, Payment
Should Receipt be in
the domain model?
Guidelines when to include a candidate conceptual
class that reports Information into the domain
model
Domain Modeling | 26
A receipt is just a
report of a sale and a
payment...
Guidelines when to include a candidate conceptual
class that reports Information into the domain
model
Domain Modeling | 27
• “Facts”:
• Identified candidate conceptual classes: ... Receipt, .…
• A receipt is just a report of a sale and a payment...
• Should Receipt be in the domain model?
• Well, it depends….
• … if we just consider the current scenario then receipt should
not be part of the domain model; a receipt is just a report
• … if we also consider how to handle returns then a receipt
represents an important concept on its own
• How about legal restrictions...? Domain
Requirement
Guidelines when to include a description class into
the domain model
Domain Modeling | 28
• Rule of Thumb:
If we do not think of some
conceptual class X as a
number, date or text in the real
Exercise
world, X is probably a
conceptual class, not an StudyGroup task
submission date
attribute.
exercise points
Solution
• Rule of Thumb:
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
attribute.
• Should destination be an attribute of flight, or a conceptual
class airport?
• A destination airport is a building at a specific place, it is not
just a number or some text.
• Hence, it should be a conceptual class.
• How about the name of the airport?
Flies-from 1
*
Flight Airport
* Flies-to 1
When should I add an association to the domain
model?
Domain Modeling | 32
• Rule of Thumb:
Include associations in the
domain model for which
knowledge of the relationship
needs to be preserved for some
duration.
We are working on the
conceptual model; we are
not modeling associations
at the software level.
When should I add an association to the domain
model?
Domain Modeling | 33
• Good examples:
• Player Is-on Square!
• Sale Paid-by CashPayment
• Bad examples:
• Sale Uses CashPayment
(Uses is usually generic and doesn’t tell us anything.)
• Player Has Square
(Has is usually generic and doesn’t tell us anything.)
The attributes in a domain model should preferably
be “primitive” data types (w.r.t. the domain!).
Domain Modeling | 36
?
• Consider modeling
quantities as classes to be Cashier
recommended:
able to associate units name
e.g. the data type of the amount
attribute of a payment should Register
indicate the currency number
The attributes in a domain model should preferably
be “primitive” data types.
Domain Modeling | 37
attributes 1
ItemId
• If the string is a quantity id
countryCode
with a unit
e.g., money has a unit for
currency
Excerpt Of the Domain Model For the POS System
Domain Modeling | 39
?
Which are
noteworthy domain concepts / domain objects
?
Excerpt Of the Domain Model For the POS System
Domain Modeling | 40
Records-sale-of
Sales
Item
LineItem
0..1 1
quantity
*
1..*
Stocked-in
Contained-in
1 1
Sale Store
date address
time name
0..1
Captured-on ▶
Paid-by Houses
1
Payment Register
amount
Domain Model and
Domain Modeling
• Summary
The domain model serves as a source of inspiration for
the design model which will be discussed later on.
Purpose of Domain Modeling | 42
inspiration / basis
1 1 Sale
Payment
date: Date
amount: Money
startTime: Time
getBalance():Money
getTotal(): Money
Design Model
By using the domain model as a direct inspiration for software
classes the representational gap between the domain concepts
and the program is (relatively) small.
Goal of the Lecture | 43
The goal of this lecture is to enable you to systematically carry out small(er)
commercial or open-source projects.
Domain Modeling
…
Software Project Management
Project Project
Start Start of an iteration End
Requirements Management
Domain Modeling