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

Lecture-05-DomainModel

The lecture discusses the importance of understanding domain models in programming, emphasizing the need to identify conceptual classes and create an initial domain model that illustrates relationships and attributes. It outlines the process of creating a domain model, including identifying noun phrases, associations, and attributes, while distinguishing between conceptual classes and software artifacts. The lecture also highlights common mistakes and best practices in modeling, including the iterative nature of refining domain models.

Uploaded by

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

Lecture-05-DomainModel

The lecture discusses the importance of understanding domain models in programming, emphasizing the need to identify conceptual classes and create an initial domain model that illustrates relationships and attributes. It outlines the process of creating a domain model, including identifying noun phrases, associations, and attributes, while distinguishing between conceptual classes and software artifacts. The lecture also highlights common mistakes and best practices in modeling, including the iterative nature of refining domain models.

Uploaded by

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

Lecture 05

Domain Models

1
Why do this?

• If
you don’t understand the domain, you

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


can’t program for it effectively(terms like in
specific business)

• Lower
the representational gap between
mental model and software model

2
Objectives

• Identifyconceptual classes related to the


current iteration( Product, Customer, Order, Cart )

• Create an initial domain model(like Customer places


an Order)

• Modelappropriate attributes and


associations (Product has name, price, productID)

3
What is a Domain Model?

• Illustrates
noteworthy concepts in a domain.
That, defines what the system is about
• Modelsthe things in your system and the
way they relate to each other
•A domain model is conceptual, not a
software artifact
•A visual dictionary

4
What’s the Difference?

Conceptual Software Artifacts:


Class:
Sale SalesDatabase

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


amt
Sale
item
Double amt;
Item item;
void print()

5
Business Object Model

• Class diagrams with no methods, just

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


fields
• May show domain objects
• Associations between classes
• Attributes of conceptual classes

6
Domain Model, visually

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


7
Conceptual Classes

• An idea, thing, or object


• Symbol—Words or images representing a
conceptual class
• Intension—Definition of a conceptual class
• Extension—The set of examples to which
the class applies
• It is not a data model

8
How to Create a Domain
Model

• Find the conceptual classes


• Draw them as classes in a UML class
diagram

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• Add associations necessary to record
relationships
• Addattributes necessary for information to
be preserved
• Use
existing names, the vocabulary of the
domain
9
How do I find Conceptual
Classes?
• Reuse or modify existing models. If there are
published models, prior art, or books, use them
• Use a category list (Table 9.1)

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• Identify noun phrases (linguistic analysis)

10
Noun Phrase Identification
• Consider the following problem description, analyzed for Subjects, Verbs,
Objects:
The ATM verifies whether the customer's card number and PIN are correct.
S V O O O
If it is, then the customer can check the account balance, deposit cash, and withdraw

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


cash.
S V O V O V
O
Checking the balance simply displays the account balance.
S O V O
Depositing asks the customer to enter the amount, then updates the account balance.
S V O V O V O
Withdraw cash asks the customer for the amount to withdraw; if the account has
enough cash,
S O V O O V S
V O
the account balance is updated. The ATM prints the customer’s account balance on a
receipt.
O
O
V S V O 11
Noun Phrases
Analyze each subject and object as follows:
• Does it represent a person performing an action? Then it’s an
actor, ‘R’.

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• Is it also a verb (such as ‘deposit’)? Then it may be a method,
‘M’.

• Is it a simple value, such as ‘color’ (string) or ‘money’


(number)?
Then it is probably an attribute, ‘A’.
• Which NPs are unmarked? Make it ‘C’ for class.
Verbs can also be classes, for example:
• Deposit is a class if it retains state information

12
Where are the Terms?
• Some are in the use case
• Some come from domain experts
• Natural language is imprecise and ambiguous, so

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


you need to use judgment

13
POS example
You can create a list, or you can use a set of class diagrams, per the table
below

Register Item Store Sale

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


Sales
Cashier Customer Manager
LineItem

Product Product
Payment
Catalog Specification

14
Model
Monopoly Game Domain

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


15
Attributes vs. Classes
• Common mistake: representing something as an
attribute when it should have been a class.
• “If we do not think of some conceptual class X as a
number or text in the real world, it should probably

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


be a class, not an attribute.”
• Should “store” be an attribute of Sale or should it be
a class?

16
Description Classes
• A description class contains information that
describes something else
• E. g. Product Description records the price, picture,
text description (and what else?) of an item

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


17
Why Use Them?
• If we keep all the information in, say, a sales line
item, once all of that item are sold, there is no
record of what the item was
• How does this relate to database design?

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


18
Associations
• Relationship between (instances of) classes that
indicates some interesting and meaningful
connection
• What objects need memory of a relationship?

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• In Monopoly, where each piece is and which player
owns which token
• No need to remember numbers on the dice

19
Associations (cont’d)
• Avoid having too many; this adds communication
paths and complexity
• Will they be implemented in software?

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• UML: Line between classes with the name of the
association
• Name with VerbPhrase-ClassName format. E. g.
Sale Paid By CashPayment
• Each end of an association is called a Role

20
Associations (cont’d)
• Multiplicity: how many instances of
class A can be associated with an
instance of class B.
• E. g. an instance of Store can be

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


associated with many (zero or more)
Items
• This is at a particular moment, not
over time
• Discussion of 0..1 or 1
• Multiple associations: Flight FliesTo and
FliesFrom an airport
• Common Associations List on p. 155
21
Attributes
• It is useful to identify those attributes of conceptual classes that are
needed to satisfy the information requirements of the current
scenarios under development.
• An Attribute is a logical data value of an object
• You can also have derived attributes denoted by / before the name

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• Full syntax: visibility Name : type multiplicity = default {property
string}
• +pi : Real=3.14159 {read-only}

Sale
attributes
date
startTime : Time

22
Attribute Types
• Usually primitive data types, as well as things like
Color, DateTime, Zip code, etc. The latter are
specializations of primitive types
• It should not normally be a class, such as Sale or

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


Airport
• Relate conceptual classes with an association, not
an attribute. No foreign keys
• Attributes in code are okay

23
New Data Type Classes
• Things like ItemID or ClaimNumber are not always
simple data types, even though they look like them
• If the attribute contains separable pieces, it can be
its own class. For example, a Claim Number has the

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


state, year, and day encoded in it
• If it has operations associated with it

24
New Data Type Classes
(cont’d)
• If it has other attributes, such as a sale price
• If it has units, such as currency
• If it is an abstraction of one or more types with

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


these properties

25
Is the Domain Model
Correct?
• No, but it’s a good approximation
• It gets better with each iteration; don’t try to get it
all at once

CS3213 Fall 2023 - Muhammad Zeeshan Sabir


• Domain model usually done in the elaboration phase

26

You might also like