The Domain Model - University of Iowa

Transcription

The Domain Model - University of Iowa
TheUni
v
e
r
s
i
t
yofI
o
wa
CS:2820 (22C:22)
Object-Oriented Software Development
S
pr
i
ng2
01
5
TheDomai
nMode
l
by
Mauricio Monsalve
De
s
i
g
nr
oad
●
●
●
●
Be
g
i
nni
ngt
hede
s
i
g
n
Domai
nMode
l
de
s
c
r
i
be
st
he
domai
n(
c
ont
e
x
t
)
I
ti
sf
ol
l
owe
db
yt
he
S
y
s
t
e
mS
y
s
t
e
m
Di
ag
r
am(
s
)
The
nf
ol
l
owst
heOO
De
s
i
g
nMode
l
(
s
)
Domai
nMode
l
Vi
s
ualr
epr
es
ent
at
i
onofc
onc
ept
ual
c
l
as
s
esorr
eal
s
i
t
uat
i
onobj
ec
t
si
na
domai
n
●
●
Theobj
e
c
t
s(
c
onc
e
pt
ual
c
l
as
s
e
s
)oft
he
domai
nar
enots
of
t
war
eobj
e
c
t
s(
c
l
as
s
e
s
)
I
nUML,t
heDomai
nMode
li
si
l
l
us
t
r
a
t
e
dwi
t
ha
s
etofc
l
as
sdi
ag
r
amswi
t
houtmet
hods
●
Al
s
oknownasVi
s
u
a
lDi
c
t
i
o
n
a
r
y
●
P
e
r
hapsmos
te
s
s
e
nt
i
al
di
ag
r
am
Domai
nMode
l
●
●
Conc
ept
ualc
l
as
s
:i
de
a,t
hi
ng
,obj
e
c
t
I
tma
ybec
ons
i
de
r
e
di
nt
e
r
msof
– S
ymbol
—wor
dsori
mag
e
sr
e
pr
e
s
e
nt
i
ngt
he
c
onc
e
pt
ual
c
l
as
s
●
–
I
nt
ens
i
on—t
hede
ni
t
i
onoft
hec
onc
e
pt
ual
c
l
as
s
●
–
Vi
s
u
a
ld
e
pi
c
t
i
o
n
,d
i
a
g
r
a
m
Co
mpr
e
h
e
n
s
i
v
ed
e
⇠
n
i
t
i
o
n
Ext
ens
i
on—t
hes
e
tofe
x
ampl
e
st
owhi
c
ht
he
c
onc
e
pt
ual
c
l
as
sappl
i
e
s
●
Ex
t
e
n
s
i
v
ed
e
⇠
n
i
t
i
o
n
Domai
nMode
l
Domai
nMode
l
●
●
Conc
ept
ualc
l
as
s
esonl
y!
Noti
ndomai
nmode
l
– S
of
t
war
ear
t
i
f
ac
t
s
–
●
Wi
n
d
o
ws
,d
a
t
a
b
a
s
e
s
,e
t
c
.
●
Un
l
e
s
sd
o
ma
i
ni
ss
o
f
t
wa
r
e
Re
s
pons
i
bi
l
i
t
i
e
sorme
t
hods
●
Th
e
ya
r
epa
r
to
ft
h
ed
e
s
i
g
na
n
dt
h
es
o
f
t
wa
r
e
Dr
a
wi
ngt
heDM
Conc
ept
shave
namesand
at
t
r
i
but
es
(
s
omet
i
mes
)
,but
notmet
hods
Dr
a
wi
ngt
heDM
Dr
a
wi
ngt
heDM
*
1..*
1..40
5
3, 5, 8
T
zero or more;
"many"
T
one or more
T
one to 40
T
exactly 5
T
exactly 3, 5, or 8
As
s
oc
i
at
i
onss
houl
dhave
s
pec
i
$cnames
—ands
oc
l
as
s
es
“
h
a
s
”i
sab
a
dn
a
me
!
Mul
t
i
pl
i
c
i
t
ys
houl
dbekept
s
i
mpl
eatt
hi
ss
t
ag
et
houg
h;
c
onc
ept
ualmodel
i
ngdœsnot
needt
obeaspr
ec
i
s
e
Dr
a
wi
ngt
heDM
Cl
as
s
esal
s
oi
nc
l
udeat
t
r
i
but
esr
el
evantt
ot
hedomai
n
At
t
r
i
but
eds
houl
dha
ves
i
mpl
et
ypes(
number
s
,t
ext
,bool
eans
,et
c
.
)
—t
h
i
si
sn
o
ts
or
e
l
e
v
a
n
ta
tt
h
i
ss
t
a
g
e
,t
h
o
u
g
h
Theys
omet
i
mesc
anbe“
der
i
ved”
,meani
ngt
hatt
heyc
anbei
nf
er
r
ed,by
meansofaf
or
mul
a,f
r
om ot
herat
t
r
i
but
esoras
s
oc
i
at
i
ons
Sale
- dateTime : Date
- / total : Money
Private visibility
attributes
Math
+ pi : Real = 3.14 {readOnly}
Public visibility readonly
attribute with initialization
Person
firstName
middleName : [0..1]
lastName
Optional value
Dr
a
wi
ngt
heDM
Exampl
eofas
s
oc
i
at
i
onandder
i
vedat
t
r
i
but
e
SalesLineItem
SalesLineItem
SalesLineItem
Item
Each line item records a
separate item sale.
For example, 1 tofu package.
1..*
Item
Each line item can record a
group of the same kind of items.
For example, 6 tofu packages.
1..*
Item
0..1
Records-sale-of
1
0..1
Records-sale-of
0..1
Records-sale-of
/quantity
derived attribute from
the multiplicity value
Dr
a
wi
ngt
heDM
●
Pi
c
kex
ac
t
,s
pe
c
i
cnamesf
orobj
ec
t
s
,as
s
oc
i
a
t
i
ons
,e
t
c
●
At
t
r
i
but
ess
houl
dha
v
et
r
i
v
i
al
t
y
pes(
number
s
,t
e
x
t
,e
t
c
)
●
Kee
pt
hemos
tr
el
e
v
antas
s
oc
i
a
t
i
onsi
nt
heDM
●
Enc
aps
ul
at
i
on—don'
tc
onne
c
te
v
er
y
t
hi
ngt
o
e
v
e
r
y
t
hi
ng
!
– Ob
j
ec
t
ss
houl
dha
v
es
t
r
ongi
nt
er
nal
c
ohes
i
on
(
a
t
t
r
i
but
e
s
)
–
●
Obj
ec
t
ss
houl
dbeas
s
oc
i
a
t
edt
of
e
wot
herobj
e
c
t
s
(
l
o
wc
oupl
i
ng
)
Pr
obl
em:wher
edoweg
etourobj
ec
t
sf
r
om?
Ge
t
t
i
ngt
hec
onc
e
pt
s
●
Re
us
ee
x
i
s
t
i
ngmode
l
s
– C
op
yoradapte
x
i
s
t
i
ng
,we
l
lac
c
e
pt
e
dmode
l
s
–
●
●
Us
ee
x
i
s
t
i
ngDM whe
nmodi
f
y
i
ngas
y
s
t
e
m
Ca
t
e
g
or
yl
i
s
t
s
– T
abl
e9.
1i
nbook
I
de
nt
i
f
ynounphr
as
e
s(
e
as
y
!
)
– P
i
c
knouns
,e
v
e
nt
s
–
F
ul
l
ydr
e
s
s
e
dus
ec
as
e
sar
eg
r
e
a
ts
our
c
e
–
Bewar
e:na
t
ur
all
ang
uag
ei
si
mpr
ec
i
s
e
Ge
t
t
i
ngt
hec
onc
e
pt
s
Cl
as
sl
i
s
t
sc
ons
i
s
tof
c
ommont
ax
onomi
e
s
Thebookhasone
,but
t
he
r
ear
eot
he
rl
i
s
t
s
—
a
r
et
h
e
yf
o
rt
h
eDM?
●
Bus
i
ne
s
st
r
ans
ac
t
i
ons
●
Phy
s
i
c
alobj
e
c
t
s
●
De
s
c
r
i
pt
i
onsoft
hi
ng
s
●
Ca
t
al
og
s
●
Cont
ai
ne
r
soft
hi
ng
s
●
Thi
ng
si
nac
ont
ai
ne
r
●
Ot
he
rr
e
l
a
t
e
ds
y
s
t
e
ms
●
●
T
r
ans
ac
t
i
onl
i
nei
t
e
ms
●
Pr
oduc
t
s
,s
e
r
v
i
c
e
s
●
●
Pl
ac
eoft
r
a
ns
ac
t
i
on
●
●
Not
e
wor
t
h
ye
v
e
nt
s
F
i
duc
i
ar
yr
e
c
or
ds(
wor
k,
c
ont
r
ac
t
s
,nanc
e
s
,e
t
c
)
F
i
nanc
i
ali
ns
t
r
ume
nt
s
Re
f
e
r
e
nc
edoc
ume
nt
s
(
s
c
he
dul
e
s
,manual
s
,e
t
c
)
Ge
t
t
i
ngt
hec
onc
e
pt
s
Mai
nS
uc
c
e
s
sS
c
e
nar
i
o(
orBas
i
cF
l
o
w)
:
1
)Cus
t
ome
rar
r
i
v
e
sa
taPOSc
he
c
k
outwi
t
hg
oodsand/
ors
e
r
v
i
c
e
st
opur
c
has
e
.
2
)Cas
hi
e
rs
t
ar
t
sane
ws
al
e
.
3
)Cas
hi
e
re
nt
e
r
si
t
e
mi
de
nt
i
e
r
.
4)S
y
s
t
e
mr
e
c
or
dss
al
el
i
nei
t
e
m andpr
e
s
e
nt
si
t
e
m de
s
c
r
i
pt
i
on,pr
i
c
e
,andr
unni
ngt
ot
al
.
Pr
i
c
ec
al
c
ul
a
t
e
df
r
om as
e
tofpr
i
c
er
ul
e
s
.
Ca
s
h
i
e
rr
e
pe
a
t
ss
t
e
ps2
3u
n
t
i
li
n
d
i
c
a
t
e
sd
o
n
e
.
5
)S
y
s
t
e
m pr
e
s
e
nt
st
ot
alwi
t
ht
ax
e
sc
al
c
ul
a
t
e
d.
6)Cas
hi
e
rt
e
l
l
sCus
t
ome
rt
het
ot
al
,andas
ksf
orpa
y
me
nt
.
7
)Cus
t
ome
rpa
y
sandS
y
s
t
e
m handl
e
spa
y
me
nt
.
8)S
y
s
t
e
ml
og
st
hec
ompl
e
t
e
ds
al
eands
e
ndss
al
eandpa
y
me
nti
nf
or
ma
t
i
ont
ot
he
e
x
t
e
r
nalAc
c
ount
i
ng(
f
orac
c
ount
i
ngandc
ommi
s
s
i
ons
)andI
n
v
e
nt
or
ys
y
s
t
e
ms(
t
o
upda
t
ei
n
v
e
nt
or
y
)
.
9)S
y
s
t
e
m pr
e
s
e
nt
sr
e
c
e
i
pt
.
1
0)Cus
t
ome
rl
e
a
v
e
swi
t
hr
e
c
e
i
ptandg
oods(
i
fan
y
)
.
Ge
t
t
i
ngt
hec
onc
e
pt
s
Mai
nS
uc
c
e
s
sS
c
e
nar
i
o(
orBas
i
cF
l
o
w)
:
1
)Cus
t
ome
rar
r
i
v
e
sa
taPOSc
he
c
k
outwi
t
hg
oodsand/
ors
e
r
v
i
c
e
st
opur
c
has
e
.
2
)Cas
hi
e
rs
t
ar
t
sane
ws
al
e.
3
)Cas
hi
e
re
nt
e
r
si
t
e
mi
de
nt
i
e
r
.
4)S
y
s
t
e
mr
e
c
or
dss
al
el
i
nei
t
e
m andpr
e
s
e
nt
si
t
e
m de
s
c
r
i
pt
i
on,pr
i
c
e,andr
unni
ngt
ot
al
.
Pr
i
c
ec
al
c
ul
a
t
e
df
r
om as
e
tofpr
i
c
er
ul
e
s
.
Ca
s
h
i
e
rr
e
pe
a
t
ss
t
e
ps2
3u
n
t
i
li
n
d
i
c
a
t
e
sd
o
n
e
.
5
)S
y
s
t
e
m pr
e
s
e
nt
st
ot
alwi
t
ht
ax
e
sc
al
c
ul
a
t
e
d.
6)Cas
hi
e
rt
e
l
l
sCus
t
ome
rt
het
ot
al
,andas
ksf
orpa
y
me
nt
.
7
)Cus
t
ome
rpa
y
sandS
y
s
t
e
m handl
e
spa
y
me
nt
.
8)S
y
s
t
e
ml
og
st
hec
ompl
e
t
e
ds
al
eands
e
ndss
al
eandpa
y
me
nti
nf
or
ma
t
i
ont
ot
he
e
x
t
e
r
nalAc
c
ount
i
ng(
f
orac
c
ount
i
ngandc
ommi
s
s
i
ons
)andI
n
v
e
nt
or
ys
y
s
t
e
ms(
t
o
upda
t
ei
n
v
e
nt
or
y
)
.
9)S
y
s
t
e
m pr
e
s
e
nt
sr
e
c
e
i
pt
.
1
0)Cus
t
ome
rl
e
a
v
e
swi
t
hr
e
c
e
i
ptandg
oods(
i
fan
y
)
.
Ge
t
t
i
ngt
hec
onc
e
pt
s
●
●
●
●
Us
i
ngnounsornounphr
as
eshas[
al
mos
t
]no
l
ear
ni
ngc
ur
v
e(
eas
y
!
)
Ver
bsof
t
eni
mpl
yas
s
oc
i
a
t
i
ons
Thi
sme
t
hodi
sasi
mper
f
ec
tasna
t
ur
all
ang
uag
e
– Al
s
os
er
v
est
oc
hec
kus
ec
as
esandr
equi
r
ement
s
t
houg
h
S
ol
ut
i
ons
– R
ef
ert
oc
l
as
sl
i
s
t
–
●
T
al
kt
odomai
nex
per
t
Butwec
anpat
c
hourappr
oxi
mat
i
ons
!
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Wema
yi
nf
ermor
ec
onc
ept
sf
r
om wha
tweha
v
e
●
Pat
c
ht
hehol
es
—ar
et
her
eh
o
l
e
si
nt
hede
s
i
g
n?
●
S
pec
i
al
i
z
e—ar
et
he
r
ei
nt
er
es
t
i
ngs
ubc
l
as
s
es
?
●
Gener
al
i
z
e—ar
et
he
r
ei
nt
e
r
e
s
t
i
ngs
upe
r
c
l
as
s
e
s
?
●
●
●
Dec
ompos
e—c
ananobj
e
c
tbede
s
c
r
i
be
di
nt
er
ms
ofot
he
r
,c
ont
ai
ne
dobj
ec
t
s
?(
Ma
n
yme
a
n
i
n
g
st
ot
h
i
s
)
Compos
e—i
sac
ol
l
e
c
t
i
onofg
i
v
e
nobj
ec
t
s
r
e
l
e
v
ant
?
Fi
xi
mper
f
ec
t
i
ons
—nex
ts
l
i
de
s
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Cashier
Worse
a "simple" attribute, but being
used as a foreign key to relate to
another object
name
currentRegisterNumber
Cashier
Better
name
1
Works-on
1
Register
number
“
F
or
ei
g
nk
eys
”i
dent
i
f
yot
herc
onc
ept
s
.“
Keys
”ar
ei
dent
i
$er
s
;t
heyhol
da
1
t
o1r
el
at
i
onwi
t
hanobj
ec
t
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Item
Worse
description
price
serial number
itemID
Anot
herf
or
ei
g
nkeyexampl
e
ProductDescription
description
price
itemID
Item
Describes
1
*
serial number
Better
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Flight
date
number
time
Airport
Flies-to
1
*
Worse
name
As
s
oc
i
at
i
onss
houl
dnothaveat
t
r
i
but
es
;i
fonedœs
have,t
henc
hanc
esar
ei
ti
sanobj
ec
t
Flight
date
time
FlightDescription
Described-by
*
1
Better
number
*
Describes-flights-to
1
Airport
name
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Address
ItemID
OK
OK
Product
Description
Product
Description
itemId : ItemID
1
1
id
manufacturerCode
countryCode
Store
1
1
street1
street2
cityName
...
Store
address : Address
New obj
ec
t
sar
ec
ondi
t
i
onalt
ot
her
el
evanc
et
o
t
hemodel
Al
s
o,c
ompos
i
t
edat
at
ypesmaybeobj
ec
t
s
Ge
t
t
i
ngmor
ec
onc
e
pt
s
Payment
not useful
amount : Number
Payment
Has-amount
*
Payment
amount : Quantity
Payment
amount : Money
Quantity
1
amount : Number
quantities are pure data
values, so are suitable to
show in attribute section
variation: Money is a
specialized Quantity whose
unit is a currency
Is-in
*
Unit
1
...
better
Ne
x
t
Ge
ne
x
ampl
e
Records-sale-of
Ledger
Product
Description
Product
Catalog
Contains
1
1
1
Sales
LineItem
1
1..*
Contained-in
amountTendered
*
Item
Stocks
name
address
*
1
1
1..*
Houses
1..*
Register
Captured-on
1
0..1
dateTime
/ total
CashPayment
Describes
*
*
Sale
1
Used-by
Logscompleted
1
Paid-by
itemID
description
price
Store
quantity
1
1
Recordsaccountsfor
0..1
1..*
id
1
1
Is-for
 Works-on
1
1
Customer
Cashier
id
Domai
nMode
lv
/
sDe
s
i
g
nMode
l
UP Domain Model
Stakeholder's view of the noteworthy concepts in the domain.
A Payment in the Domain Model
is a concept, but a Payment in
the Design Model is a software
class. They are not the same
thing, but the former inspired the
naming and definition of the
latter.
Payment
1
1
date
time
amount
inspires
objects
and
names in
This reduces the representational
gap.
This is one of the big ideas in
object technology.
Pays-for
Sale
Sale
Payment
amount: Money
getBalance(): Money
1
Pays-for
1
date: Date
startTime: Time
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.
De
s
i
g
nMode
l(
l
a
t
e
r
)
●
●
Wewi
l
lus
eade
t
ai
l
e
dCl
as
sDi
ag
r
am t
o
de
s
c
r
i
bet
heDe
s
i
g
nMode
l
Wewi
l
le
v
ol
v
eandi
nf
e
rOOc
l
as
s
e
sf
r
om t
he
c
onc
e
pt
s
●
Wemi
g
htdr
opc
onc
e
pt
saswe
l
l
●
Ot
he
rc
l
as
s
e
swi
l
lc
omef
r
om s
y
s
t
e
m ne
e
ds
●
Theas
s
oc
i
a
t
i
onswi
l
lbemuc
hmor
es
pe
c
i
c
●
Codec
anbepar
t
i
al
l
yi
nf
e
r
r
e
df
r
om De
s
i
g
n
Mode
l
Thoug
ht
s
●
Nos
i
ng
l
ec
or
r
e
c
tans
we
r
—n
oe
x
a
c
ts
c
i
e
n
c
ee
i
t
h
e
r
!
●
I
tmi
g
htt
ak
et
obe
c
omef
ami
l
i
arwi
t
ht
hei
de
as
●
I
tma
ybeg
oodt
os
t
ar
twi
t
has
i
mpl
edomai
n
mode
l
●
The
n,c
he
c
kwha
ti
swr
ong
—x
●
F
i
x
i
ngma
yaddc
ompone
nt
s
●
I
t
e
r
a
t
eunt
i
l
g
oodqual
i
t
y
●
Don'
tc
onne
c
tal
l
t
oal
l
!
Cr
e
di
t
s
Not
e
sandg
ur
e
sadapt
e
df
r
om
Appl
y
i
n
gUMLa
n
dP
a
t
t
e
r
n
s
:AnI
n
t
r
o
d
u
c
t
i
o
nt
o
Ob
j
e
c
t
Or
i
e
n
t
e
dAn
a
l
y
s
i
sa
n
dDe
s
i
g
na
n
d
I
t
e
r
a
t
i
v
eDe
v
e
l
o
pme
n
tbyC.Lar
man.3
r
d
e
di
t
i
on.Pr
e
nt
i
c
eHal
l
/
P
e
ar
s
on,2
005
.