0% found this document useful (0 votes)
13 views

Lecture 6

object oriented analysis and design

Uploaded by

hira bukhari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Lecture 6

object oriented analysis and design

Uploaded by

hira bukhari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Domain Modeling

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

Set of Use Case High-Level


and Domain Model
Requirements Diagram
Expanded
Use cases
Use case Identification Main Success
Scenarios
Non- Functional • Boss test
Functional Requirements • Elementary Business Process
Requirements • Size Test

 Represent feature/functions/user goals


 Presented as VERB
WHAT IS DOMAIN MODEL? 4
“Good designs require
deep application
knowledge.”
Curtis’law
Domain Model
• The domain model is created during object-oriented analysis
to decompose the domain into concepts or objects in the real
world

• The model should identify the set of conceptual classes (The


domain model is iteratively completed.)

• It is the basis for the design of the software

• The domain model is also called conceptual model, domain


object model or analysis object mode
6
Domain Model
• Illustrates meaningful conceptual classes in problem domain
(Analysis phase)

• It helps us identify, relate and visualize important information.

• Represents real-world concepts, not software components

• Software-oriented class diagrams will be developed later (during


design phase)

• It provides inspiration for later creation of software design classes,


to reduce “representational gap.” 7
Monopoly Game domain model
(first identify concepts as classes)

Monopoly Game Dice Board

Player Piece Square


Monopoly Game domain model
Larman, Figure 9.28
To visualize domain models the UML class diagram
notation is used.

• However, no operations are defined in domain models


• Only ...
• domain objects and conceptual classes
• associations between them
• attributes of conceptual classes

10
A Domain Model is Conceptual, not a Software Artifact

Conceptual Class: Software Artifacts:

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:

Student Association Cardinality


- age: int Registers Registers
- name: String
1 *

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

• Draw them as classes in a UML class diagram

• Add associations and attributes

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

3. Identify noun phrases in your use-cases


• Identify nouns and phrases in textual descriptions of a domain (
use cases, or other documents)

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..

• Reusing existing models is excellent, but out of the scope of


this course

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

• Cash Payment • Amount

• 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

• Usual primitive attributes (data types not shown in DM)

• Common compound attributes


• Date, time, address, SSN, phone number, bar codes, etc.
• May even become full class objects in design…
attributes
Sale

dateTime
28
/ total : Money derived
attribute
Visibility in Domain Models

Sale Math Person

- dateTime : Date + pi : Real = 3.14 {readOnly} firstName


- / total : Money middleName : [0..1]
lastName

Private visibility Public visibility readonly


attributes attribute with initialization Optional value

The full UML attribute syntax:

e.g. + store : Walmart [1..*] {readOnly} 29


EXAMPLES 30
EXAMPLE: Domain Model
Pays-for-overdue-charges 4

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

You might also like