Object-Oriented Databases Object Oriented Databases - ODBMS.org
Chap 5 - Object Oriented Design
-
Upload
sreenu-kaki -
Category
Documents
-
view
223 -
download
0
Transcript of Chap 5 - Object Oriented Design
-
8/17/2019 Chap 5 - Object Oriented Design
1/134
Object Oriented Analysis and Design 1
Chapter 5 Object Oriented Design OO Design Overview
Architectural Design Use Case Design Subsystem Design
Class Design
-
8/17/2019 Chap 5 - Object Oriented Design
2/134
-
8/17/2019 Chap 5 - Object Oriented Design
3/134
Object Oriented Analysis and Design 3
5.1 OO Design Overview Understanding Design
Analysis Versus Design Object Oriented Design
-
8/17/2019 Chap 5 - Object Oriented Design
4/134
Object Oriented Analysis and Design 4
Understanding Design A process that uses the products of
analysis to produce a specification forimplementing a system. A logical description of how a system willwor .
!mphasi"es a conceptual solution #insoftware and hardware$ that fulfills there%uirements& rather than itsimplementation.'do the right thing #analysis$& and do thething right #design$(.
-
8/17/2019 Chap 5 - Object Oriented Design
5/134
Object Oriented Analysis and Design 5
Analysis Versus Design Analysis
Focus on understandingthe problemIdealized design
eha!ior
"ystem structureFunctional re#uirements
A small model
Design
Focus on understandingthe solutionOperations and
Attributes$er%ormance&lose to real codeObject li%ecycles'on(%unctionalre#uirements
A large model
-
8/17/2019 Chap 5 - Object Oriented Design
6/134
-
8/17/2019 Chap 5 - Object Oriented Design
7/134Object Oriented Analysis and Design 0
Architectural Design
-
8/17/2019 Chap 5 - Object Oriented Design
8/134Object Oriented Analysis and Design
5.2 Architectural Design Architectural )atterns
*esolution of Architectural +actors ,dentify Design !lementsOrgani"ing the design model pac ages
-
8/17/2019 Chap 5 - Object Oriented Design
9/134
-
8/17/2019 Chap 5 - Object Oriented Design
10/134
Object Oriented Analysis and Design 19
"ypical #ayering Appr$ach
Generalfunctionality
Specific
functionality
-
8/17/2019 Chap 5 - Object Oriented Design
11/134
Object Oriented Analysis and Design 11
%&a'ples $( Architectural atterns ) #ayers1) Pattern Name: Layers2) Context A large system that requires decomposition.3) Pro lem
A system !hich must handle issues at di""erent le#els o"a straction. $or example: hard!are control issues%common ser#ices issues and domain&speci"ic issues. 't!ould e extremely undesira le to !rite #ertical
components that handle issues at all le#els. (he same issue!ould ha#e to e handled possi ly inconsistently) multipletimes in di""erent components.
-
8/17/2019 Chap 5 - Object Oriented Design
12/134
-
8/17/2019 Chap 5 - Object Oriented Design
13/134
-
8/17/2019 Chap 5 - Object Oriented Design
14/134
Object Oriented Analysis and Design 14
*$deling Architectural #ayers Architectural layers can be modeled using
stereotyped pac8ages::layer;; stereotype
$ac8age 'ame::layer;;
-
8/17/2019 Chap 5 - Object Oriented Design
15/134
Object Oriented Analysis and Design 15
#ayer + ,euse driving
layerApplication
layerusiness&+peci"ic
layeriddle!are
-
8/17/2019 Chap 5 - Object Oriented Design
16/134
Object Oriented Analysis and Design 1)
%&a'ple + Applicati$n #ayer
-
8/17/2019 Chap 5 - Object Oriented Design
17/134
Object Oriented Analysis and Design 10
%&a'ple + -usiness peci(ic #ayer
-
8/17/2019 Chap 5 - Object Oriented Design
18/134
Object Oriented Analysis and Design 1
%&a'ples $( Architectural atterns ) #ayers
-
8/17/2019 Chap 5 - Object Oriented Design
19/134
Object Oriented Analysis and Design 1
artial l$gical view $( layers in the /e&t0en applicati$n
-
8/17/2019 Chap 5 - Object Oriented Design
20/134
Object Oriented Analysis and Design 29
yste' Operati$ns and #ayers
-
8/17/2019 Chap 5 - Object Oriented Design
21/134
Object Oriented Analysis and Design 21
Upward C$llab$rati$n with Observer=I +indo+s-
-
8/17/2019 Chap 5 - Object Oriented Design
22/134
Object Oriented Analysis and Design 22
Upward C$llab$rati$n with Observer
-
8/17/2019 Chap 5 - Object Oriented Design
23/134
-
8/17/2019 Chap 5 - Object Oriented Design
24/134
-
8/17/2019 Chap 5 - Object Oriented Design
25/134
Object Oriented Analysis and Design 25
"er'in$l$gy "iers #ayers and artiti$ns*he original notion o% a tier in architecture +asa logical layer, not a physical node, but the+ord has become +idely used to mean aphysical processing node .or cluster o% nodes/
such as the client tier .the client computer/--
*he layers o% an architecture are said torepresent the !ertical slices*he partitions represent a horizontal di!isiono% relati!ely parallel subsystems o% a layer-
-
8/17/2019 Chap 5 - Object Oriented Design
26/134
Object Oriented Analysis and Design 2)
#ayers and partiti$ns
-
8/17/2019 Chap 5 - Object Oriented Design
27/134
Object Oriented Analysis and Design 20
#ayer ) /)"ier 3C4
+er#er
Client A Client N4...
-
8/17/2019 Chap 5 - Object Oriented Design
28/134
Object Oriented Analysis and Design 2
#ayer ) /)"ier 36 tier
5elational 6ata ase+er#er s)
Client C 777 ro!ser
7e+er#er
8( LC9' A+P a#a
usiness ;
-
8/17/2019 Chap 5 - Object Oriented Design
29/134
Object Oriented Analysis and Design 2
#ayer ) /)"ier 3n)tier
HTML, Script Languages, ...
JS , Servlets, !G", ...
#J$, !O%$A, !OM&
'ative languages
Client> ro!ser
7e +er#er
Application +er#er
Legen(Syste)
Data*aseServer
-
8/17/2019 Chap 5 - Object Oriented Design
30/134
Object Oriented Analysis and Design 39
Architectural attern ) *VC? Nam e: @C odel&@ie!&Controller)? Context and force s: !e ha#e a data model and se#eral representations o" the
data 7e !ant to modulari,e the system 6ata representation must e /ept up to date? Proble m: ho! to modulari,e the system? Solutio n: the model holds the data and does data modi"ication)% the #ie! representsthe data% the controller handles user input
-
8/17/2019 Chap 5 - Object Oriented Design
31/134
-
8/17/2019 Chap 5 - Object Oriented Design
32/134
Object Oriented Analysis and Design 32
%&a'ples $( Architectural atterns ) -lac7b$ard1) Pattern Name
lac/ oard2) ContextA domain in !hich no closed algorithmic) approach tosol#ing a pro lem is /no!n or "easi le. =xamples are A'
systems% #oice recognition% and sur#eillance systems.3) Pro lem
ultiple pro lem&sol#ing agents /no!ledge agents) mustcooperate to sol#e a pro lem that cannot e sol#ed y any
o" the indi#idual agents. (he results o" the !or/ o" theindi#idual agents must e accessi le to all the otheragents so they can e#aluate !hether they can contri uteto "inding a solution and post results o" their !or/.
$ $
-
8/17/2019 Chap 5 - Object Oriented Design
33/134
Object Oriented Analysis and Design 33
%&a'ples $( Architectural atterns ) -lac7b$ard*) $orces+equence in !hich /no!ledge agents can contri ute to sol#ing thepro lem is not deterministic and may depend on pro lem sol#ingstrategies. 'nput "rom di""erent agents results or partial solutions)may ha#e di""erent representations. Agents do not /no! o" eachotherBs existence directly ut can e#aluate each otherBs posted
contri utions-) +olutionA num er o" no!ledge Agents ha#e access to a shared data storecalled the lac/ oard. (he lac/ oard pro#ides an inter"ace to
inspect and update its content. (he Control module>o
-
8/17/2019 Chap 5 - Object Oriented Design
34/134
Object Oriented Analysis and Design 34
%&a'ples $( Architectural atterns ) -lac7b$ard
-
8/17/2019 Chap 5 - Object Oriented Design
35/134
$l i$ $( A hi l 8 $
-
8/17/2019 Chap 5 - Object Oriented Design
36/134
Object Oriented Analysis and Design 3)
,es$luti$n $( Architectural 8act$rsBecording Architectural Alternati!es, Decisions,and 6oti!ation ( technical memos C ample o% *echnical 6emo
D i *$d l O i
-
8/17/2019 Chap 5 - Object Oriented Design
37/134
Object Oriented Analysis and Design 30
Design *$del Overview
Dse case reali,ation
Special Applicationlayer--
General Applicationlayer--
General Serviceslayer--
Syste) Serviceslayer--
Layered Architecture
Architecture echanism
6esign odel
Dse case
se case report
Glossary
Supple)entarySpecification
5equirement odel
" h i l * '$
-
8/17/2019 Chap 5 - Object Oriented Design
38/134
Object Oriented Analysis and Design 3
"echnical *e'$ All architectural methods recommend 8eeping arecord o% alternati!e solutions, decisions, in%luential%actors, and moti!ations %or the note+orthy issues anddecisions-"uch records ha!e been called technical memos ,issue cards, and architectural approach documents,+ith !arying degrees o% %ormality and sophistication-
In some methods, these memos are the basis %or yetanother step o% re!ie+ and re%inement-
In the =$, the memos should be recorded in the "AD-
An important aspect o% the technical memo is themoti!ation or rationale-C plaining the rationale o% rejecting the alternati!es isimportant-
%& ' l $( " h i l * '$
-
8/17/2019 Chap 5 - Object Oriented Design
39/134
Object Oriented Analysis and Design 3
%&a'ple $( "echnical *e'$
A hi l 9 ($ ' i$ i h U A i(
-
8/17/2019 Chap 5 - Object Oriented Design
40/134
Object Oriented Analysis and Design 49
Architectural 9n($r'ati$n in the U Arti(acts *he architectural decisions are recorded in the
"AD #Software Architecture Document$ -*his includes the technical memos anddescriptions o% the architectural !ie+s-
-
8/17/2019 Chap 5 - Object Oriented Design
41/134
-
8/17/2019 Chap 5 - Object Oriented Design
42/134
Object Oriented Analysis and Design 42
"(entify Design #le)ents
-
8/17/2019 Chap 5 - Object Oriented Design
43/134
9d ti( D ig %l ' t
-
8/17/2019 Chap 5 - Object Oriented Design
44/134
Object Oriented Analysis and Design 44
9denti(y Design %le'ents
classes& to represent a set o% rather %ine(grainedresponsibilities@subsystems , to represent a set o% coarse(grainedresponsibilities, perhaps composed o% a %urther set o%subsystems, but ultimately a set o% classes@active classes , to represent threads o% control in thesystem@interfaces& to represent abstract declarations o%responsibilities pro!ided by a class or subsystem-
analysis classes represent conceptual things which can perfor)*ehavior."n (esign, analysis classes evolve into a nu)*er of (ifferent0in(s of (esign ele)ents1
-
8/17/2019 Chap 5 - Object Oriented Design
45/134
ac7ages versus ubsyste's
-
8/17/2019 Chap 5 - Object Oriented Design
46/134
Object Oriented Analysis and Design 4)Encapsulation is the key!
ac7ages versus ubsyste's"ubsystems
$ro!ide beha!ior &ompletelyencapsulate theircontents
Are easily replaced
Su*syste) Asu*syste)--
ac0age $!lass$2
!lass$3
!lient !lass
ac0agesDon4t provi(e*ehaviorDon4t co)pletely
encapsulate theircontentsMay not *e easilyreplace(
ubsyste' e&a'ple
-
8/17/2019 Chap 5 - Object Oriented Design
47/134
Object Oriented Analysis and Design 40
ubsyste' e&a'ple
9denti(ying ubsyste's
-
8/17/2019 Chap 5 - Object Oriented Design
48/134
Object Oriented Analysis and Design 4
5Super)an !lass6
9denti(ying ubsyste s&lassA
D./E./
789:89
"nterface--
Su*syste) ;su*syste)--
%&a'ple Design ubsyste's and 9nter(aces
-
8/17/2019 Chap 5 - Object Oriented Design
49/134
Object Oriented Analysis and Design 4
Analysis Design
%&a ple Design ubsyste s and 9nter(aces
illing"ystem
FFsubmit bill./
::boundary;; $illing Syste)su*syste)--
"$illingSyste)
su*)it$ill8forTuition 1 Dou*le, forStu(ent 1 Stu(ent9
!ourse!atalogSyste)
-
8/17/2019 Chap 5 - Object Oriented Design
50/134
Object Oriented Analysis and Design 59
Interfaces start with an “I”
package
class
*$deling C$nventi$n ubsyste s and 9nter(aces
!ourse!atalogSyste)
su*syste)--
"!ourse!atalogSyste)
!ourse!atalogSyste)
get!ourseOfferings89initiali/e89
su*syste) pro=y--
"!ourse!atalogSyste)
get!ourseOfferings8forSe)ester 1 Se)ester, forStu(ent 1 Stu(ent9 1 !ourseOfferingListinitiali/e89
8a:ade in subsyste'
-
8/17/2019 Chap 5 - Object Oriented Design
51/134
Object Oriented Analysis and Design 51
8a:ade in subsysteFor subsystems, the most common pattern o% access isFacade, a >oF design pattern-
a public %acade object de%ines the ser!ices %or the subsystem,and clients collaborate +ith the %acade, not internalsubsystemcomponents
*he Facade pattern is commonly used %or do+n+ardcollaboration %rom a higher to a lo+er layer, or %oraccess to ser!ices in another subsystem o% the samelayer- *he %acade should not normally e pose many lo+(le!eloperations-
Bather, to e pose a small number o% high(le!el operationsGthe coarse(grained ser!ices-
A %acade does not normally do its o+n +or8-Bather, it is consolidator or mediator to the underlyingsubsystem objects, +hich do the +or8-
-
8/17/2019 Chap 5 - Object Oriented Design
52/134
-
8/17/2019 Chap 5 - Object Oriented Design
53/134
Object Oriented Analysis and Design 53
Organi/ing the Design Mo(el ac0ages
eview What 9s a ac7age!
-
8/17/2019 Chap 5 - Object Oriented Design
54/134
Object Oriented Analysis and Design 54
A pac8age is a general purpose mechanism %ororganizing elements into groups-
It is a model element that can contain other modelelements-
A pac8age can be used*o organize the model under de!elopment-
As a unit o% con%iguration management-
,eview What 9s a ac7age!
niversityArtifacts
ac7age elati$nships Dependency
-
8/17/2019 Chap 5 - Object Oriented Design
55/134
Object Oriented Analysis and Design 55
$ac8ages can be related to one another usinga dependency relationship
Dependency ImplicationsH &hanges to the "upplier pac8age may a%%ect the &lient pac8ageH *he &lient pac8age cannot be reused independently because it
depends on the "upplier pac8age
ac7age ,elati$nships Dependency
!lient ac0age Supplierac0age
Depen(ency relationship
Av$iding Circular Dependencies
-
8/17/2019 Chap 5 - Object Oriented Design
56/134
Object Oriented Analysis and Design 5)
!
A
$
Hierarchyshould beacyclic
A
$
!
A>
ircular dependencies make it impossible to reuse one
package without the other
Av$iding Circular Dependencies
A
$
-
8/17/2019 Chap 5 - Object Oriented Design
57/134
ac7aging "ips 8uncti$nally elated Classes
-
8/17/2019 Chap 5 - Object Oriented Design
58/134
Object Oriented Analysis and Design 5
ac7aging ips 8uncti$nally ,elated Classes&riteria %or determining i% classes are %unctionallyrelated
&hanges in one classJ beha!ior and or structure necessitate changes inanother classBemo!al o% one class impacts the other class*+o objects interact +ith a large number o% messages or ha!e acomple intercommunication
A boundary class can be %unctionally related to a particular entity class i%the %unction o% the boundary class is to present the entity class*+o classes interact +ith, or are a%%ected by changes in the same actor*+o classes ha!e relationships bet+een each other One class creates instances o% another class
&riteria %or determining +hen t+o classes should NOT be placed in the same pac8age*+o classes that are related to di%%erent actors should not be placed inthe same pac8age
An optional and a mandatory class should not be placed in the samepac8age
ac7age Dependencies ac7age %le'ent Visibility
-
8/17/2019 Chap 5 - Object Oriented Design
59/134
Object Oriented Analysis and Design 5
ac0age$
ac0ageA
ublic "isibility
ri"ate "isibility
#nly public classescan be referencedoutside of the owning package
OO Principle: Encapsulation
ac7age Dependencies ac7age %le ent Visibility
A
$
!lass A2
!lass A3
!lass A?
&!lass $2
@!lass $3
ac7age C$upling "ips
-
8/17/2019 Chap 5 - Object Oriented Design
60/134
Object Oriented Analysis and Design )9
A
$ $ $
ac7age C$upling ips
$ac8ages should
not be cross(coupled$ac8ages in lo+erlayers should not bedependent uponpac8ages in upperlayersIn general,dependenciesshould not s8iplayers
A $
$ $ pper
Layer
LowerLayer
!
$ $
$ $ !oupling violation
*$st esp$nsible Are *$st table
-
8/17/2019 Chap 5 - Object Oriented Design
61/134
Object Oriented Analysis and Design )1
$st ,esp$nsible Are $st table
8act$r $ut 9ndependent "ypes
-
8/17/2019 Chap 5 - Object Oriented Design
62/134
Object Oriented Analysis and Design )2
8act$r $ut 9ndependent ypes
Use 8act$ries t$ ,educe Dependency $n C$ncrete ac7ages
-
8/17/2019 Chap 5 - Object Oriented Design
63/134
Object Oriented Analysis and Design )3
$ $ , p y $ $ g
-
8/17/2019 Chap 5 - Object Oriented Design
64/134
-
8/17/2019 Chap 5 - Object Oriented Design
65/134
-
8/17/2019 Chap 5 - Object Oriented Design
66/134
Object Oriented Analysis and Design ))
Su*syste) Design
5.6 ubsyste' Design teps
-
8/17/2019 Chap 5 - Object Oriented Design
67/134
Object Oriented Analysis and Design )0
5.6 ubsyste Design teps"ubsystem Design O!er!ie+
"ubsystem >uidelines"ubsystem Design "teps&hec8points
-
8/17/2019 Chap 5 - Object Oriented Design
68/134
ubsyste' Design ) urp$se
-
8/17/2019 Chap 5 - Object Oriented Design
69/134
Object Oriented Analysis and Design )
y g ) p$-o define the behaviors specified in thesubsystem6s interfaces in terms ofcollaborations of contained classes -o document the internal structure of thesubsystem -o define reali"ations between thesubsystem6s interfaces and containedclasses -o determine the dependencies uponother subsystems
,eview ubsyste's and 9nter(aces
-
8/17/2019 Chap 5 - Object Oriented Design
70/134
Object Oriented Analysis and Design 09
A "ubsystemK
Is a Lcross bet+eenM a pac8age and a classBealizes one or more inter%aces +hich de%ineits beha!ior
su*syste)--Su*syste) 'a)e
Interface%ubsystem
su*syste)--Su*syste) 'a)e"nterface
&eali'ation ( anonical form)
&eali'ation (Elided form )
interface--"nterface
, y (
ubsyste' 0uidelines
-
8/17/2019 Chap 5 - Object Oriented Design
71/134
Object Oriented Analysis and Design 01
*ey is abstraction and encapsulation
Asu*syste)--
$su*syste)--
!su*syste)--
y>oals
oose coupling$ortability, plug(and(play compatibilityInsulation %rom changeIndependent e!olution
"trong "uggestionsDonNt e pose details, only inter%acesOnly depend on other inter%aces
,eview *$deling C$nventi$n ($r ubsyste's and 9nter(aces
-
8/17/2019 Chap 5 - Object Oriented Design
72/134
Object Oriented Analysis and Design 02
!ourse!atalogSyste)
su*syste)--
"!ourse!atalogSyste)
"!ourse!atalogSyste)
!ourse!atalogSyste)su*syste) pro=y--
!ourse!atalogSyste)su*syste)--Interfaces start with an “I”
package
class
ubsyste' Design teps
-
8/17/2019 Chap 5 - Object Oriented Design
73/134
Object Oriented Analysis and Design 03
y g pDistribute subsystem beha!ior tosubsystem elementsDocument subsystem elementsDescribe subsystem dependencies
ubsyste' ,esp$nsibilities
-
8/17/2019 Chap 5 - Object Oriented Design
74/134
Object Oriented Analysis and Design 04
!ourse!atalogSyste)su*syste)--"!ourse!atalogSyste)
get!ourseOfferings89
interface--
subsystem responsibility
y , p"ubsystem responsibilities de%ined byinter%ace operations
6odel inter%ace realizations
Inter%ace operations may be realized byInternal class operationsInternal subsystem operations
Distributing ubsyste' ,esp$nsibilities
-
8/17/2019 Chap 5 - Object Oriented Design
75/134
Object Oriented Analysis and Design 05
g y , pIdenti%y ne+, or reuse e isting, design elements .e-g-,classes and or subsystems/
Allocate subsystem responsibilities to design elementsIncorporate applicable mechanisms .e-g-, persistence,distribution, etc-/Document design element collaborations in Linter%acerealizationsM
One or more interaction diagrams per inter%aceoperation&lass diagram.s/ containing the re#uired designelement relationships
Be!isit L Identify Design lements M Adjust subsystem boundaries and or dependencies,as needed
ubsyste' Dependencies 0uidelines
-
8/17/2019 Chap 5 - Object Oriented Design
76/134
Object Oriented Analysis and Design 0)
"ubsystem dependency on a subsystem
"ubsystem dependency on a pac8age
y p
+lexible,referred
Server
!lient Supportsu*syste)--
Server Supportsu*syste)--
-se with care!lient Support
su*syste)-- SupportingTypes
-
8/17/2019 Chap 5 - Object Oriented Design
77/134
Object Oriented Analysis and Design 00
se !ase Design
5.< Use Case Design
-
8/17/2019 Chap 5 - Object Oriented Design
78/134
Object Oriented Analysis and Design 0
g =se &ase Design O!er!ie+
=se &ase Design "teps
-
8/17/2019 Chap 5 - Object Oriented Design
79/134
Use Case Design ) urp$se
-
8/17/2019 Chap 5 - Object Oriented Design
80/134
Object Oriented Analysis and Design 9
-o refine use3case reali"ations in terms ofinteractions -o refine re%uirements on the operationsof design classes
-o refine re%uirements on the operationsof subsystems and7or their interfaces.
Use)Case Design teps
-
8/17/2019 Chap 5 - Object Oriented Design
81/134
Object Oriented Analysis and Design 1
Describe interaction bet+een design objects
"impli%y se#uence diagrams using subsystemsDescribe persistence related beha!ior Be%ine the %lo+ o% e!ents description
=ni%y classes and subsystems
-
8/17/2019 Chap 5 - Object Oriented Design
82/134
Object Oriented Analysis and Design 2
!lass Design
5.5 Class Design
-
8/17/2019 Chap 5 - Object Oriented Design
83/134
Object Oriented Analysis and Design 3
&reate Initial Design &lasses
De%ine OperationsDe%ine 6ethodsDe%ine "tates
De%ine AttributesDe%ine DependenciesDe%ine Associations
Class Design C$nsiderati$ns
-
8/17/2019 Chap 5 - Object Oriented Design
84/134
Object Oriented Analysis and Design 4
&lass stereotypeoundary
Cntity&ontrol
Applicable design patterns Architectural mechanisms
$ersistenceDistributionetc-
-
8/17/2019 Chap 5 - Object Oriented Design
85/134
-
8/17/2019 Chap 5 - Object Oriented Design
86/134
trategies ($r Designing %ntity Classes
-
8/17/2019 Chap 5 - Object Oriented Design
87/134
Object Oriented Analysis and Design 0
Analysis
+at!lassLa/yDataHelper0rarely se(Att?0rarely se(AttC
Design
+at!lass0transient$oo0eeping
& get!o))only se(Att289& get!o))only se(Att389& get%arely se(Att?89& get%arely se(AttC89
+at!lassDataHelper0co))only se(Att20co))only se(Att3
2 2
+at!lass@ transient$oo0eeping0co))only se(Att20co))only se(Att30rarely se(Att?0rarely se(AttC
entity --
Cntity objects are o%ten passi!e and persistent$er%ormance re#uirements may %orce some re(%actoring"ee Identi%y $ersistent &lasses step
trategies ($r Designing C$ntr$l Classes
-
8/17/2019 Chap 5 - Object Oriented Design
88/134
Object Oriented Analysis and Design
-
8/17/2019 Chap 5 - Object Oriented Design
89/134
/a'e and Describe the Operati$ns
-
8/17/2019 Chap 5 - Object Oriented Design
90/134
Object Oriented Analysis and Design 9
Appropriate operation namesIndicate the outcome=se client perspecti!e&onsistent across classes
De%ine operation signaturesoperation'ame.parameter K class,--/ Kreturn*ype
$ro!ide short description, including
meaning o% all parameters
0uidelines Designing Operati$n ignatures
-
8/17/2019 Chap 5 - Object Oriented Design
91/134
Object Oriented Analysis and Design 1
-
8/17/2019 Chap 5 - Object Oriented Design
92/134
Object Oriented Analysis and Design 2
u*licoperations
rotecte(operations
rivate operations
7isibility is used to en%orce encapsulation
6ay be public, protected, or pri!ate
-
8/17/2019 Chap 5 - Object Oriented Design
93/134
c$pe
-
8/17/2019 Chap 5 - Object Oriented Design
94/134
Object Oriented Analysis and Design 4
!lass@ classifierScopeAttri*ute
classifierScopeOperation89
@ instanceScopeAttri*ute
instanceScopeOperation89
Determines number o% instances o% theattribute operation
InstanceK one instance %or each class instance&lassi%ierK one instance %or all class instances
&lassi%ier scope is denoted by underlining theattribute operation name
%&a'ple c$pe
-
8/17/2019 Chap 5 - Object Oriented Design
95/134
Object Oriented Analysis and Design 5
Stu(ent
@ na)e@ a((ress
@ ne=tAvail"D 1 int
& a((Sche(ule8theSche(ule 1 Sche(ule, forSe)ester 1 Se)ester9& getSche(ule8forSe)ester 1 Se)ester9 1 Sche(ule& has rereEuisites8for!ourseOffering 1 !ourseOffering9 1 *oolean
passe(8the!ourseOffering 1 !ourseOffering9 1 *oolean& get'e=tAvail"D89 1 int
entity--
@ stu(ent"D
%&a'ple De(ine Operati$ns
-
8/17/2019 Chap 5 - Object Oriented Design
96/134
Object Oriented Analysis and Design )
!ourseOffering8fro) niversity Artifacts9
entity--
Stu(ent .
& getTuition89 1 (ou*le& a((Sche(ule8theSche(ule 1 Sche(ule9
& getSche(ule8forSe)ester 1 Se)ester9 1 Sche(ule& (eleteSche(ule8forSe)ester 1 Se)ester9& has rereEuisites8for!ourseOffering 1 !ourseOffering9 1 *oolean
passe(8the!ourseOffering 1 !ourseOffering9 1 *ooleanclass-- & get'e=tAvail"D89 1 int
& getStu(ent"D89 1 int& get'a)e89 1 string& getA((ress89 1 string
8fro) niversity Artifacts9
entity--
%egistration!ontroller
& su*)itSche(ule89& saveSche(ule89& get!ourseOfferings89 1 !ourseOfferingList& get!urrentSche(ule8forStu(ent 1 Stu(ent, forSe)ester 1 Se)ester9 1 Sche(ule& (elete!urrentSche(ule89
class-- & new8forStu(ent 1 string9& getStu(ent8with"D 1 string9 1 Stu(ent
8fro) %egistration9
control--
Sche(ule8fro) niversity Artifacts9
entity--
F..2
F..2®istrant
F..
2
F..2
F..2
¤tSche(ule
F..
F..
&pri)ary!ourses
F..C
&alternate!ourses
F..3
"!ourse!atalogSyste)
& get!ourseOfferings89
& initiali/e89
8fro) #=ternal Syste) "nterfaces9
"nterface--
2F..
De(ine *eth$ds
-
8/17/2019 Chap 5 - Object Oriented Design
97/134
Object Oriented Analysis and Design 0
-
8/17/2019 Chap 5 - Object Oriented Design
98/134
Object Oriented Analysis and Design
$urposeDesign ho+ an objectNs state a%%ects its beha!ior De!elop statecharts to model this beha!ior
*hings to consider K
-
8/17/2019 Chap 5 - Object Oriented Design
99/134
Object Oriented Analysis and Design
State 'a)e
state ar 1 type value
entry< entry action(o< activitye=it< e=it action
event8args9Iguar( con(ition< operation8args9 Ktarget.sen(#vent8args9
%tate E"ent
1ransition
.ction
.cti"ity
A directed graph o% states .nodes/ connectedby transitions.directed arcs/Describes the li%e history o% a reacti!e object
pecial tates
-
8/17/2019 Chap 5 - Object Oriented Design
100/134
Object Oriented Analysis and Design 199
Initial state*he state entered +hen an object is created6andatory&an only ha!e one initial state
Final stateIndicates the objectNs end o% li%eOptional6ay ha!e more than one +inal state
"nitial state
-
8/17/2019 Chap 5 - Object Oriented Design
101/134
-
8/17/2019 Chap 5 - Object Oriented Design
102/134
9denti(y the "ransiti$ns
-
8/17/2019 Chap 5 - Object Oriented Design
103/134
Object Oriented Analysis and Design 193
nassigne(
Assigne(
re)ove rofessor
a(( rofessor
For each state, determine +hat e!ents cause transitionsto +hat states, including guard conditions, +hen needed
*ransitions describe +hat happens in response to thereceipt o% an e!ent
!ourseOffering2 add rofessor()2 remo"e rofessor()
entity--
F..
&instructorrofessorentity--F..2
Add Activities and Acti$ns
-
8/17/2019 Chap 5 - Object Oriented Design
104/134
Object Oriented Analysis and Design 194
Acti!ities Associated +ith a state"tart +hen the state is entered*a8e time to completeInterruptible
Actions Associated +ith a transition*a8e an insigni%icant amount o% time to complete
'on(interruptible
State A
State $(o1 activity
eventI con(ition < action
State !acti"ity
action
entry1 action
%&a'ple tatechart
-
8/17/2019 Chap 5 - Object Oriented Design
105/134
Object Oriented Analysis and Design 195
a(( stu(ent < nu)Stu(ents nu)Stu(ents & 2
nassigne(
Assigne(
+ull
!ancelle((o1 Sen( cancellation notices
!o))itte(
(o1 Generate class roster
close%egistration I has rofessor assigne(
close
< nu)Stu(ents F
a(( rofessor
close%egistration
re)ove stu(ent < nu)Stu(ents nu)Stu(ents @ 2
cancel
re)ove rofessor
I nu)Stu(ents 2F
closeI nu)Stu(ents ?
close%egistrationI nu)Stu(ents - ?
closeI nu)Stu(ents - ?
a(( stu(ent <
nu)Stu(ents nu)Stu(ents & 2
cancel
re)ove stu(ent < nu)Stu(ents nu)Stu(ents @ 2
close
I nu)St u(ents 2F cancel
%&a'ple tatechart With /ested tates and =ist$ry
-
8/17/2019 Chap 5 - Object Oriented Design
106/134
Object Oriented Analysis and Design 19)
superstate
substate
a(( stu(ent
-
8/17/2019 Chap 5 - Object Oriented Design
107/134
Object Oriented Analysis and Design 190
Objects +hose role is clari%ied by statetransitions&omple use cases that are state(controlledIt is not necessary to model all objects
Objects +ith straight%or+ard mapping toimplementationObjects that are not state(controlledObjects +ith only one computational state
=$w D$ tatecharts *ap t$ the ,est $( the *$del!
-
8/17/2019 Chap 5 - Object Oriented Design
108/134
Object Oriented Analysis and Design 19
Open +ull
a(( stu(ent <nu)Stu(ents nu)Stu(ents & 2
Inu)Stu(ents 2F
!ourseOffering
$u 8ind "he'!
-
8/17/2019 Chap 5 - Object Oriented Design
109/134
Object Oriented Analysis and Design 19
C amine method descriptionsC amine states
Any in%ormation the class itsel% needs tomaintain
Attribute ,epresentati$ns" i% d i l d % l ! l
-
8/17/2019 Chap 5 - Object Oriented Design
110/134
Object Oriented Analysis and Design 119
"peci%y name, type, and optional de%ault !alueattribute'ame K *ype R De%ault
Follo+ naming con!entions o% implementationlanguage and project*ype should be an elementary data type inimplementation language
uilt(in data type, user(de%ined data type, oruser(de%ined class"peci%y !isibility
$ublicK SPN
$ri!ateK S(N$rotectedK SQN
Derived Attributesh d d b
-
8/17/2019 Chap 5 - Object Oriented Design
111/134
Object Oriented Analysis and Design 111
-
8/17/2019 Chap 5 - Object Oriented Design
112/134
h I D d
De(ine Dependency
-
8/17/2019 Chap 5 - Object Oriented Design
113/134
Object Oriented Analysis and Design 113
-
8/17/2019 Chap 5 - Object Oriented Design
114/134
Object Oriented Analysis and Design 114
Associations are structural relationshipsDependencies are non(structuralrelationshipsIn order %or objects to L8no+ each otherMthey must be !isible
ocal !ariable re%erence$arameter re%erence>lobal re%erence
Field re%erence .ssociation!lientSupplier2
Supplier3
3ependency
Ass$ciati$ns vs. Dependencies in C$llab$rati$nsA i % i i i li 8
-
8/17/2019 Chap 5 - Object Oriented Design
115/134
Object Oriented Analysis and Design 115
An instance o% an association is a lin8 All lin8s become associations unless they ha!eglobal, local or parameter !isibility&onte t dependent relationship
Dependencies are transient lin8sa!e a limited duration
&onte t independent relationship"ummary relationship
-
8/17/2019 Chap 5 - Object Oriented Design
116/134
%&a'ple De(ine Dependencies 3be($re" f
-
8/17/2019 Chap 5 - Object Oriented Design
117/134
Object Oriented Analysis and Design 110
"!ourse!atalogSyste)
& get!ourseOfferings8forSe)ester 1 Se)ester9 1 !ourseOfferingList
8fro) #=ternal Syste) "nterfaces9
"nterface--
Stu(ent
@ na)e@ a((ress@ Stu(ent"D 1 int
& a((Sche(ule8theSche(ule 1 Sche(ule, forSe)ester 1 Se)ester9& getSche(ule8forSe)ester 1 Se)ester9 1 Sche(ule& has rereEuisites8for!ourseOffering 1 !ourseOffering9 1 *oolean
passe(8the!ourseOffering 1 !ourseOffering9 1 *oolean
8fro) niversity Artifacts9
entity--
%egistration!ontroller
&
-
8/17/2019 Chap 5 - Object Oriented Design
118/134
Object Oriented Analysis and Design 11
4lobal "isibility
arameter "isibility
"!ourse!atalogSyste)
& get!ourseOfferings8forSe)ester 1 Se)ester9 1 !ourseOfferingList
8fro) #=ternal Syste) "nterfaces9
"nterface--
Stu(ent
@ na)e@ a((ress@ Stu(ent"D 1 int
& a((Sche(ule8theSche(ule 1 Sche(ule, forSe)ester 1 Se)ester9& getSche(ule8forSe)ester 1 Se)ester9 1 Sche(ule& has rereEuisites8for!ourseOffering 1 !ourseOffering9 1 *oolean
passe(8the!ourseOffering 1 !ourseOffering9 1 *oolean
8fro) niversity Artifacts9
entity--
%egistration!ontroller
&
-
8/17/2019 Chap 5 - Object Oriented Design
119/134
Object Oriented Analysis and Design 11
$urposeBe%ine remaining associations
*hings to loo8 %or K Association !s- Aggregation Aggregation !s- &omposition Attribute !s- Association'a!igability
Association class design
6ultiplicity design
What is C$'p$siti$n!A % % gg g ti +ith t g
-
8/17/2019 Chap 5 - Object Oriented Design
120/134
Object Oriented Analysis and Design 129
Bhole art
7hole
Composition
Part
A %orm o% aggregation +ith strongo+nership and coincident li%etimes
*he parts cannot sur!i!e the +hole aggregate
Aggregati$n hared Vs. /$n)shared
-
8/17/2019 Chap 5 - Object Oriented Design
121/134
Object Oriented Analysis and Design 121
"hared Aggregation
'on(shared Aggregation
5y definition, composition is non0shared aggregation
Bhole art2.. F..
6ultiplicity > 7
6ultiplicity 8 7 6ultiplicity 8 7
2Bhole art2 F.. Bhole artF..
omposition
Aggregati$n $r C$'p$siti$n!&onsideration
-
8/17/2019 Chap 5 - Object Oriented Design
122/134
Object Oriented Analysis and Design 122
aggregation
composition
!lass2
!lass2
!lass3
!lass3
&onsiderationi%etimes o% &lass1 and &lass2
%&a'ple C$'p$siti$n
-
8/17/2019 Chap 5 - Object Oriented Design
123/134
Object Oriented Analysis and Design 123
Stu(ent Sche(ule2 F..
2 2 %egister+or!ourses+or) %egistration!ontroller
Attributes Vs C$'p$siti$n=se composition +hen
-
8/17/2019 Chap 5 - Object Oriented Design
124/134
Object Oriented Analysis and Design 124
=se composition +hen$roperties need independent identities6ultiple classes ha!e the same properties$roperties ha!e a comple structure andproperties o% their o+n
$roperties ha!e comple beha!ior o% their o+n$roperties ha!e relationships o% their o+n
Other+ise use attributes
%&a'ple Attributes Vs C$'p$siti$n
-
8/17/2019 Chap 5 - Object Oriented Design
125/134
Object Oriented Analysis and Design 125
omposition ofseparate class
.ttributes
F..22
Stu(ent@ na)e@ a((ress
classifier scope-- @ ne=tAvail"D 1 int@ Stu(ent"D 1 int@ (ateof$irth 1 Date
& a((Sche(ule89& getSche(ule89& (elete sche(ule89& has rereEuisites89
passe(89
entity--
Sche(ule
& su*)it89&
-
8/17/2019 Chap 5 - Object Oriented Design
126/134
-
8/17/2019 Chap 5 - Object Oriented Design
127/134
-
8/17/2019 Chap 5 - Object Oriented Design
128/134
6ultiplicity R 1 or 6ultiplicity R 9--1*ultiplicity Design
-
8/17/2019 Chap 5 - Object Oriented Design
129/134
Object Oriented Analysis and Design 12
6ultiplicity R 1, or 6ultiplicity R 9--16ay be implemented directly as a simple!alue or pointer 'o %urther LdesignM is re#uired
6ultiplicity ; 1&annot use a simple !alue or pointer Further LdesignM may be re#uired
F..F..2
instructor !ourseOfferingrofessor
F..F..2
instructor9eeds acontainer
rofessor !ourseOffering
*ultiplicity Design Opti$nsC plicit modeling o% a container class
-
8/17/2019 Chap 5 - Object Oriented Design
130/134
Object Oriented Analysis and Design 139
C plicit modeling o% a container class
'ote
instructorrofessor !ourseOffering
F..F..2
!ourseOfferingentity--
rofessorentity--
!ourseOfferingList
& new89& a((89
2
F..
F..2F..2
&instructor
!ourseOffering
F..F..2
instructor
List
rofessor
What is a ara'eteri;ed Class 3te'plate !A class de%inition +hich de%ines other
-
8/17/2019 Chap 5 - Object Oriented Design
131/134
Object Oriented Analysis and Design 131
"te)
Listara)eteri/e(
!lass
+or)alargu)ents
A class de%inition +hich de%ines otherclassesO%ten used %or container classes
"ome common container classesKH"ets, lists, dictionaries, stac8s, #ueues, T
9nstantiating a ara'eteri;ed Class
-
8/17/2019 Chap 5 - Object Oriented Design
132/134
Object Oriented Analysis and Design 132
"nstantiate( !lass actual argu)ents-
*in(-- actual argu)ents-
ara)eteri/e(!lass
+or)alargu)ents
"nstantiate( !lass
O%
Implicit bindingExplicit binding
%&a'ple 9nstantiating a ara'eteri;ed Class
-
8/17/2019 Chap 5 - Object Oriented Design
133/134
Object Oriented Analysis and Design 133
!ourseOfferingentity--
!ourseOfferingList2 F..
5efore
.fter
*in(-- !ourseOffering-
List
"te)
!ourseOfferingList !ourseOffering
List !ourseOffering- !ourseOfferingO%
*ultiplicity Design Opti$nalityI% a lin8 is optional ma8e sure to include an
-
8/17/2019 Chap 5 - Object Oriented Design
134/134
!ourseOfferingrofessor
isTeaching8 9 1 $oolean F..2 F.. has"nstructor8 9 1 $oolean
I% a lin8 is optional, ma8e sure to include anoperation to test %or the e istence o% the lin8