Sunteți pe pagina 1din 45

SS ZG514

Object Oriented
Analysis and Design
BITS Pilani Harvinder S Jabbal
Session 07: Domain Model
Pilani|Dubai|Goa|Hyderabad
Outline

No Title
CS3.1.1 Explain how Domain Concepts are different than
software classes, how domain concepts to be
identified?

CS3.1.2 How to identify Associations and Multiplicity among


domain concepts

CS3.1.3 Explain how to add attributes to Domain Model?

CS3.1.4 Demonstrate drawing complete Domain Model for PoS


System
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Domain Concepts
Overview

A Domain Model visualizes noteworthy concepts or objects


in the domain.

You should be able to:


Read and write the UML class diagram notation for a Domain Model
Create a Domain Model
Apply guidelines Concepts,
Relate it to other artifacts
Words,
Things
In the
Domain
4 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
DEFINITION & MOTIVATION:
Domain Model
A Domain Model visualizes, using UML class diagram
notation, noteworthy concepts or objects.
It is a kind of visual dictionary.
Not a picture of software classes.

It helps us identify, relate and visualize important


information.

It provides inspiration for later creation of software design


classes, to reduce representational gap.

5
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Guideline: show real-situation conceptual
classes, not software classes

visualization of a real-world concept in


Sale the domain of interest

dateTime it is a not a picture of a software class

A domain model does not show software artifacts or classes


SalesDatabase
void software artifact; not part
a of domain model

Sale
void software class; not part
a date of domain model
time
print()

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Lower Representational Gap
UP Domain Model
Stakeholder's view of the noteworthy concepts in the domain.
Sale
A Payment in the Domain Model Payment 1
1 Pays-for
is a concept, but a Payment in date
the Design Model is a software amount
time
class. They are not the same
thing, but the former inspired the
inspires
naming and definition of the
objects
latter.
and
names in
This reduces the representational
gap.
Sale
This is one of the big ideas in Payment
object technology. 1 1 date: Date
amount: Money Pays-for startTime: Time

getBalance(): Money 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.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Conceptual Class symbol,
intension, extension

Sale concept's symbol

date
time

"A sale represents the event concept's intension


of a purchase transaction. It
has a date and time."

sale-1

sale-3
sale-2 concept's extension

sale-4

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Guideline: Creting Domain
Model
Find the Conceptual Classes
1. Reuse or modify existing models
2. Use category list (see next slide)
3. Identify noun phrases

Draw them in UML

Add Associations and attributes

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Conceptual Class Category
List
Conceptual Class Category Guideline Examples
Business transaction They are critical (involve money), so Sale, Purchase,
start with transactions reservation
Transaction line item Transactions often come with SelesLineItem
related items, so consider these next
Product or service related to Transactions are for something (a Item, Flight, Seat,
a Transaction or Transaction product or service). Consider next. Meal
line item
Where is the transaction Important Register, Ledger,
recorded FlightManifest
Role of people or Cashier, Customer,
organisation related to the Store,
transaction; actors in a use MonopolyPlayer,
case Passenger, Airline
Place of transaction; place or Store, Airport, Plane,
service Seat
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Conceptual Class Category
List
Conceptual Class Category Guideline Examples
Noteworthy events, often Sale, Payment,
with a time or place we need MonoployGame,
to remember Flight
Physical object Especially relevant when creating a Item, register, Board,
device-control software or Piece, Die, Airplane
simulation
Description of things ProductDescription,
FlightDescription
Catalogs Descriptions are often in a Catalog. ProductCatalog,
FlightCatalog
Containers of things(physical Store, Bin, Board,
or informtion) Airplane

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Conceptual Class Category
List
Conceptual Class Category Guideline Examples
Things in a container Item, Square (in a
board), Passenger
Other collaboration systems CeditAuthorisationSys
tem, AirTrafficCOntrol
Records of finance, work, Receipt, Ledger,
contracts, legal matters MaintenanceLog

Financial instruments Cash,Cheque,


LineofCredit,
TicketCredit
Schedules, manuals, DailyPriceChangeList,
documents that are regularly RepairSchedule
referred to in order to
perform work

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


GUIDELINES:
Finding Domain Concepts
Abbott Analysis; Linguistic Analysis
Most simply, pick out the nouns a mechanical noun-to-
class mapping isn;t possible, and words in natuaral
language are ambiguous.

Avoid a waterfall-mindset big-modeling


effort to make a thorough or correct
domain model
- It wont ever be either, and such over-
modeling efforts lead to analysis paralysis,
with little or no return on investment.

13
use cases sys. sequence diagrams domain
BITS modelsto be University
Pilani, Deemed operation contract
under Section 3 of UGC Act, 1956
Initial PoS Domain Model

Register Item Store Sale

Sales
Cashier Customer Ledger
LineItem

Cash Product Product


Payment Catalog Description

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Adding Attributes to Domain Models


Partial Domain Model
- A visual dictionary

concept Sales
Item
or domain LineItem Records-sale-of
object 1
quantity 0..1

1..* *
Stocked-in
association Contained-in

1 1

Sale Store
attributes date address
time 0..1 name
1
1
Houses
Paid-by 1..*

1 Register
Captured-on
Payment
1
amount

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Partial Domain Model

1
Rents 1..*

Customer VideoStore
Video
address Rents-from address Stocks
name
* 1
name 1 * ID
phoneNumber phoneNumber

17 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UML and GUIDELINES:
Attributes
Show only simple relatively primitive types as attributes.

Connections to other concepts are to be represented as


associations, not attributes.

Payment
attributes
date : Date
time : Time
amount : Money

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


When a ProductDescriotion
has many items

Item

description Worse
price
serial number
itemID

ProductDescription
Item
description Describes Better
price 1 * serial number
itemID

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Description about other things

Flight
Airport
date Flies-to Worse
number 1 name
time *

Flight
FlightDescription Better
Described-by
date
time * 1 number

*
Describes-flights-to
1

Airport

name

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UML: Class and attributes

attributes
Sale

dateTime
/ total : Money derived
attribute

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UML: Attribute Notations

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

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Associations and Multiplicity


Association

association

Records-current
Register Sale
1 1

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UML notation for Associations

-"direction reading arrow"


-it has no meaning except to indicate direction of
reading the association label
-optional

VideoStore Stocks Video


1 *

association name multiplicity

25 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Application UML: Multiplicity

-"reading direction arrow"


-it has no meaning except to indicate direction of
reading the association label
-often excluded

Register Records-current Sale


1 0..1

association name multiplicity

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UML: Multiplicity

zero or more;
* T
"many"

Customer
One instance of a
1..*
T one or more Customer may be
0..1 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
27
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Multiplicity is context
dependent
Store Stocks Item
1
or 0..1
*

Multiplicity should "1" or "0..1"?

The answer depends on our interest in using the model. Typically and practically, the muliplicity communicates a
domain constraint that we care about being able to check in software, if this relationship was implemented or
reflected in software objects or a database. For example, a particular item may become sold or discarded, and thus
no longer stocked in the store. From this viewpoint, "0..1" is logical, but ...

Do we care about that viewpoint? If this relationship was implemented in software, we would probably want to ensure
that an Item software instance would always be related to 1 particular Store instance, otherwise it indicates a fault or
corruption in the software elements or data.

This partial domain model does not represent software objects, but the multiplicities record constraints whose
practical value is usually related to our interest in building software or databases (that reflect our real-world domain)
with validity checks. From this viewpoint, "1" may be the desired value.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


GUIDELINES: Associations

Only add associations for noteworthy relationships.


Literally, those for which making a note is worthy or
business motivated. 1..* Video

1 Rents ...

Customer Important association.


Need to remember.
...

Influenced-by 1 Loan Policy

...
Low value association.
Possible, but so what?
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
GUIDELINES: Attributes

Why??

Customer Video
Worse
rentedVideos: List of Video renter : Customer

Customer 1 1..* Video


Rents
Better
... ...

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Multiple Association

* Flies-to 1
Flight Airport
Flies-from
1
*

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani
Pilani|Dubai|Goa|Hyderabad

Demonstration
Domain Model- Visual
Dictionary
Pays-for-overdue-charges

VideoRental
0..1
CashPayment RentalTransaction
Pays-for

Concepts,
1 dueDate
amount : Money 1 1 date 1 returnDate
1 1..*
returnTime
* *
Words, 1 1
Initiates

Rents
Records-rental-of

Things Customer

address Rents-from address


VideoStore
Stocks
Video
1..*

In the *
name name 1 ID 1
phoneNumber * 1
phoneNumber
1
* *
1
1

Domain Has
1
Maintains
Owns-a
1

Membership * Catalog

ID 1
startDate
Described-by
1
1..*

LoanPolicy VideoDescription
Defines 1
perDayRentalCharge title
perDayLateCharge 1..* subjectCategory

1..* 1
Determines-rental-charge

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


PoS Partial Domain Model
Records-sale-of

Product
Ledger Product Description
Catalog Contains
1 1..*
1 1
1
0..1 Records-
Used-by Describes
accounts-
Sales for * *
LineItem Store
Item
Stocks
1 1
* 1..*
1..*
1 Houses
Contained-in Logs-
1 completed 1..*
Sale * Register
Captured-on
0..1 1

1 1 1
Paid-by Is-for Works-on
1 1 1

CashPayment Customer Cashier

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Derived Attributes

SalesLineItem Item Each line item records a


0..1 Records-sale-of 1
separate item sale.
For example, 1 tofu package.

SalesLineItem Item
0..1 Records-sale-of 1..* Each line item can record a
group of the same kind of items.
For example, 6 tofu packages.

SalesLineItem Item
0..1 Records-sale-of 1..*
/quantity

derived attribute from


the multiplicity value

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Focus on data type attributes
Data types
Boolean
Date (or DateTime)
Number
Character
String (Text)
Time
Other common types
Address
Colour
Geometrics (Point, Rectangle)
PhoenNumber
SocialSecurityNumber
UniversalProductCOde (UPC)
SKU,
ZIP or postal code
Enumerated types

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Relate Conceptual Class with an
association, not an attribute.

Cashier
Worse not a "data type" attribute
name
currentRegister

Cashier Register
Better 1 Uses 1
name number

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Dont show complex concepts
as attributes, use associations

Flight destination is a complex


Worse concept
destination

Flight 1 Flies-to 1 Airport


Better

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Type Property of an
Object 2 representations

ItemID Address
Product 1 1 1 1 street1
OK id Store
Description street2
manufacturerCode
countryCode cityName
...

Product Store
Description
OK address : Address
itemId : ItemID

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Do not use attributes as
foreign keys

Cashier
Worse a "simple" attribute, but being
name used as a foreign key to relate to
currentRegisterNumber another object

Cashier Register
Better 1 Works-on 1
name number

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Modeling Quantities

Payment
not useful
amount : Number

Payment Quantity Unit


Has-amount Is-in
1 1
* amount : Number * ...

Payment quantities are pure data


values, so are suitable to
amount : Quantity show in attribute section better

Payment variation: Money is a


specialized Quantity whose
amount : Money unit is a currency

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


NextGen POS partial domain
model
Records-sale-of

Product
Ledger Product Description
Catalog Contains
1 itemID
1..*
description
1 1
1 price
0..1 Records-
Used-by Describes
accounts-
Sales for * *
LineItem Store
Item
Stocks
quantity 1 name 1
address * 1..*
1..*
1 Houses
Contained-in Logs-
1 completed 1..*
Sale * Register
dateTime Captured-on id
0..1 1
/ total
1
1 1
Paid-by Is-for Works-on

1 1 1

CashPayment Customer Cashier

amountTendered id

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Monopoly Game-
Partial Domain Model

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


UP use Case Model- Artifacts

Domain
Business Model
Partial artifacts,
Modeling * refined in each
* iteration.

Use-Case Model

:System

foo( x )
Requirements
bar( y )
system
text use system operations
system
use case sequence operation
cases diagrams diagrams contracts

Design Model

Design

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Thank You

The slides are based on:


Applying UML and Patterns
An Introduction to Object-Oriented Analysis and Design
and Iterative Development

By Craig Larman

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956

S-ar putea să vă placă și