Unit-1 OOMD- Inthhro- class modeling.ppt

ChiragSuresh 82 views 96 slides Jul 11, 2024
Slide 1
Slide 1 of 96
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96

About This Presentation

Hhh


Slide Content

Faculty Instructor:
Dr. kavitha sooda
Associate Professor
Dept. of CSE
B.M.S. College of engineering, Bengaluru
TB: Object oriented modelling and design with UML, 2
nd
Edition, Michael blaha, james Rumbaugh
©-PPT
Object-Oriented Modeling and Design
Course Code: 20cs6pcomd

Course Content
Units Content
1-C1,2,3 Introduction, Modeling Concepts, Class Modeling
2 –C4,5 Advanced Class Modeling, State Modeling
3 –C6,7,8 Advanced State Modeling, Interaction Modeling:
Advanced State Modeling
4 –C10-13 Process Overview, System Conception, Domain
Analysis, Application Analysis: Process Overview
5 -C14,15,17 System Design, Class Design, Implementation
Modeling
Unit-12

Course Outcomes
CO Course outcomes
CO1Ability to apply the knowledge of class, State & Interaction
Modelling using Unified Modeling Language to solve a
given problem.
CO2Ability to analyze a System for a given requirement using
Unified Modeling language
CO3Ability to design a given system using high level strategy.
CO4Ability to conduct practical experiment to solve a given
problem using Unified Modeling language.
Unit-13

Is Software Engineering the right
term?
If Engineering then it has to be constructed like Civil engineering, Electrical or
Mechanical Engineering
Unit-14

What is Software Development &
Engineering?
Software development is art of problem solving-
Just 100 years old
Software Engineering is an innovative process
Unit-15

Unit-1
6

Why projects Fail? -Complexity
Changes from requirements
Changes from Technology
Changes from People
Why Project fails?
Unit-17

Software Development life cycle
Unit-18

Software Development-Software
Construction
OOAD aids in
Structural analysis, Modeling, Design and
Implementation
Adherence to Good Practices.
UML
Unit-19

End of Class
Next Class,
Introduction, 4 Aspects of OO approach, OO
Development, Methodology, Themes
Unit-110

Content
Introduction
Four Aspects of OO Approach
OO Development
OO Themes
Unit-111

Introduction
IntentionofOOMDistolearnhowtoapplyobject-
orientedconceptstoallthestagesofthesoftware
developmentlifecycle.
Object-orientedmodellinganddesignisawayof
thinkingaboutproblemsusingmodelsorganizedaround
realworldconcepts.
Thefundamentalconstructistheobject,whichcombines
bothdatastructureandbehaviour.
Unit-112

Four Aspects of OO Approach
OOmeansthatweorganizesoftwareasacollectionof
discreteobjects.
TherearefouraspectsrequiredbyanOOapproach
Identity.
Classification.
Inheritance.
Polymorphism.
Unit-113

Identity:
Identitymeansthatdataisquantizedintodiscrete,
distinguishableentitiescalledobjects.
E.g.Personalcomputer,bicycle,queeninchess.
Objectscanbeconcreteorconceptual.Eachobject
hasitsowninherentidentity.
Classification:
Classificationmeansthatobjectswiththesame
datastructureandbehaviouraregroupedintoa
class.
E.g.paragraph,monitor,chesspiece.
Eachobjectissaidtobeaninstanceofitsclass.
Unit-114

Unit-115

Inheritance:
Itisthesharingofattributesandoperationsamong
classesbasedonahierarchicalrelationship.Asuperclass
hasgeneralinformationthatsubclassesrefineand
elaborate.
E.g.RegularCustomerandPrivilegedcustomerarethe
subclassesofCustomer.
Polymorphism:
Polymorphismmeansthatthesameoperationmaybehave
differentlyfordifferentclasses.
For E.g. move operation behaves differently for a pawn
than for the queen in a chess game.
Anoperationisaprocedure/transformationthatanobject
performsorissubjectedto.Animplementationofan
operationbyaspecificclassiscalledamethod.
Unit-116

OO Development
Unit-117

Developmentreferstothesoftwarelifecycle:Analysis,
DesignandImplementation.
TheessenceofOODevelopmentistheidentificationand
organizationofapplicationconcepts.
OOdevelopmentisfundamentallyawayofthinkingand
notaprogrammingtechnique
Unit-118

OO Methodology
Theprocessconsistsofbuildingamodelofan
applicationandthenaddingdetailstoitduringdesign.
Themethodologyhasthefollowing5stages:
Systemconception:Softwaredevelopmentbegins
withbusinessanalysisorusersconceivingan
applicationandformulatingtentativerequirements.
Analysis:Theanalystscrutinizesandrigorously
restatestherequirementsfromthesystemconception
byconstructingmodels.
Unit-119

Theanalysismodelisaconcise,preciseabstractionofwhat
thedesiredsystemmustdo,nothowitwillbedone.
Theanalysismodelhastwoparts:
DomainModel-adescriptionofrealworldobjects
reflectedwithinthesystem.
ApplicationModel-adescriptionofpartsofthe
applicationsystemitselfthatarevisibletotheuser.
E.g.Incaseofstockbrokerapplication-
Domainobjectsmayinclude-stock,bond,trade&
commission.
Applicationobjectsmightcontroltheexecutionoftrades
andpresenttheresults.
Unit-120

SystemDesign:Thedevelopmentteamsdeviseahigh-
levelstrategy-TheSystemArchitecture-forsolvingthe
applicationproblem.
Thesystemdesignershoulddecidewhatperformance
characteristicstooptimize,choseastrategyofattacking
theproblem,andmaketentativeresourceallocations.
ClassDesign:Theclassdesigneraddsdetailstothe
analysismodelinaccordancewiththesystemdesign
strategy.
Implementation:Implementerstranslatetheclassesand
relationshipsdevelopedduringclassdesignintoa
particularprogramminglanguage,databaseorhardware.
Unit-121

Three models
ClassModel—fortheobjectsinthesystem&their
relationships.
Itdescribesthestaticstructureoftheobjectsinthesystemand
theirrelationships.
Classmodelcontainsclassdiagrams-agraphwhosenodesare
classesandarcsarerelationshipsamongtheclasses.
Statemodel—forthelifehistoryofobjects.
Itdescribestheaspectsofanobjectthatchangeovertime.
Itspecifiesandimplementscontrolwithstatediagrams-a
graphwhosenodesarestatesandwhosearcsaretransition
betweenstatescausedbyevents.
Unit-122

InteractionModel—fortheinteractionamong
objects.
Itdescribeshowtheobjectsinthesystemco-operateto
achievebroaderresults.
Thismodelstartswithusecasesthatarethenelaborated
withsequenceandactivitydiagrams.
Usecase–focusesonfunctionalityofasystem–i.e
whatasystemdoesforusers.
Sequencediagrams–showstheobjectthatinteractand
thetimesequenceoftheirinteractions.
Activitydiagrams–elaboratesimportantprocessing
steps.
Unit-123

OO THEMES -6
Abstraction
Abstractionletsyoufocusonessentialaspectsofan
applicationwhileignoringdetailsi.efocusingonwhatan
objectisanddoes,beforedecidinghowtoimplementit.
It’sthemostimportantskillrequiredforOOdevelopment.
Encapsulation(informationhiding)
Itseparatestheexternalaspectsofanobjectfromthe
internalimplementationdetails.
Encapsulationpreventsportionsofaprogramfrom
becomingsointerdependentthatasmallchangehas
massiverippleeffects.
Unit-124

Combiningdataandbehavior
Callerofanoperationneednotconsiderhowmany
implementationsexist.
InOOsystemthedatastructurehierarchymatches
theoperationinheritancehierarchy.
Unit-125

Sharing
OOtechniquesprovidesharingatdifferentlevels.
Inheritanceofbothdatastructureandbehaviorletssub
classessharecommoncode.
OOofferstheprospectofreusingdesignsandcodeon
futureprojects.
Emphasisontheessenceofanobject
OOdevelopmentplacesagreateremphasisondata
structureandalesseremphasisonprocedurestructure
thanfunctional-decompositionmethodologies.
Synergy
Identity,classification,polymorphismandinheritance
characterizeOOlanguages.
Eachoftheseconceptscanbeusedinisolation,but
togethertheycomplementeachothersynergistically.
Unit-126

End of Chapter 1

Purpose of Modeling
Abstraction
Three models
Unit-1 29

Amodelisanabstractionofsomethingforthe
purposeofunderstandingitbeforebuildingit.
MODELLING
Designersbuildmanykindsofmodelsforvarious
purposesbeforeconstructingthings.
Modelsserveseveralpurposes–
Testingaphysicalentitybeforebuildingit:
MedievalbuiltscalemodelsofGothicCathedralsto
testtheforcesonthestructures.Engineerstestscale
modelsofairplanes,carsandboatstoimprovetheir
dynamics.
Unit-1 30

Communicationwithcustomers:Architectsandproduct
designersbuildmodelstoshowtheircustomers.
mock-upsaredemonstrationproductsthatimitatesomeof
theexternalbehaviourofasystem.
Visualization:Storyboardsofmovies,TVshowsand
advertisementsletwritersseehowtheirideasflow.
Artistssketchesletthemblockouttheirideasandmake
changesbeforecommittingthemtosoilorstone.
Reductionofcomplexity:Modelsreducecomplexityto
understanddirectlybyseparatingoutasmallnumberof
importantthingstodowithatatime.
Unit-1 31

Abstractionistheselectiveexaminationofcertain
aspectsofaproblem.
Thegoalofabstractionistoisolatethoseaspectsthat
areimportantforsomepurposeandsuppressthose
aspectsthatareunimportant.
Allabstractionsareincompleteandinaccurate.
Agoodmodelcapturesthecrucialaspectsofaproblem
andomitsothers.
Unit-1 32

ClassModel:representsthestatic,structural,“data”
aspectsofasystem.
Itdescribesthestructureofobjectsinasystem-their
identity,theirrelationshipstootherobjects,their
attributes,andtheiroperations.
Goalinconstructingclassmodelistocapturethose
conceptsfromtherealworldthatareimportanttoan
application.
Classdiagramsexpresstheclassmodel.
Unit-1 33

StateModel:representsthetemporal,behavioural,
“control”aspectsofasystem.
Statemodeldescribesthoseaspectsofobjects
concernedwithtimeandthesequencingof
operations–
Eventsthatmarkchanges,statesthatdefinethecontext
forevents,andtheorganizationofeventsandstates.
Statediagramexpressthestatemodel.
Eachstatediagramshowsthestateandevent
sequencespermittedinasystemforoneclassof
objects.
Statediagramrefertotheothermodels.
Unit-1 34

Interactionmodel–representsthecollaborationof
individualobjects,the“interaction”aspectsofa
system.
Interactionmodeldescribesinteractionsbetween
objects–howindividualobjectscollaboratetoachieve
thebehaviourofthesystemasawhole.
Usecases-documentinteractionbetweensystemand
actor.
Sequencediagrams-objectsthatinteractandtime
sequence.
Activitydiagrams–flowofcontrol.
Unit-1 35

RelationshipAmongtheModels
Theclassmodeldescribesdatastructureonwhichthe
stateandinteractionmodelsoperate.
Theoperationsintheclassmodelcorrespondtoevents
andactions.
Thestatemodeldescribesthecontrolstructureof
objects.
Theinteractionmodelfocusesontheexchanges
betweenobjects.
Thegoalistosimplifythesystemdescriptionwithout
loadingdownthemodelwithsomanyconstructsthat
itbecomesaburdenandnothelp.
Unit-1 36

Next Chapter : Class Modeling

CHAPTER 3

A class model captures the static structure of a system by
characterizing the objects in the system, the relationships
between the objects, and the attributes and operations for
each class of objects.
Object-generally Proper noun
Purpose of class modeling is to describe objects.
An object is a concept, abstraction or thing with identity
that has meaning for an application.
Ex: Joe Smith, Infosys Company, process number 7648
and top window are objects.
Unit-1 39

Someobjectsarereal-worldentities,conceptualetc.,
Thechoiceofobjectdependsonjudgmentandthenatureof
aproblem.
Allobjectshaveidentityandaredistinguishable.
Thetermidentitymeansthattheobjectsaredistinguished
bytheirinherentexistenceandnotbydescriptiveproperties
thattheymayhave.
Example:Twoappleswiththesamecolor,shapeand
texturearestillindividuals.
Identicaltwinsaretwodistinctpersonseventhoughthey
lookthesame
Unit-1 40

Class–CommonNoun
Anobjectisaninstanceoroccurrenceofaclass.
Aclassdescribesagroupofobjectswiththesame
properties(attributes),behaviour(operations),kinds
ofrelationshipsandsemantics.
Ex:Person,company,processandwindoware
classes.
Objectsinaclasshavethesameattributesandforms
ofbehavior.
Theobjectsinaclassshareacommonsemantic
purpose.
Unit-1 41

A barn and horse may have cost and age .
If considered as financial assets they both
could belong to same class.
If developer takes into consideration that a
person paints a barn and feeds a horse, they
would be modeled as distinct classes.
The interpretation of semantics depends on
the purpose of each application and is a
matter of judgment
Unit-1 42

ClassDiagrams
Classdiagramsprovideagraphicnotationformodeling
classesandtheirrelationships,therebydescribing
possibleobjects.
Classdiagramsareusefulbothforabstractmodelingand
fordesigningactualprograms.
Aclassdiagramcorrespondstoinfinitesetofobject
diagrams.
Anobjectdiagramshowsindividualobjectsandtheir
relationships.
Usefulfordocumentingtestcasesanddiscussing
examples.
Unit-1 43

Conventionsused(UML):
UMLsymbolforbothclassesandobjectsisbox.
Objectsaremodelledusingboxwithobjectname
followedbycolonfollowedbyclassname.
Useboldfacetolistclassname,centrethenameinthe
boxandcapitalizethefirstletter.Usesingularnounsfor
namesofclasses.
Toruntogethermultiwordnames(suchasJoeSmith),
separatethewordswithinterveningcapitalletter.
Unit-1 44

ValuesandAttributes
Valueisapieceofdata.
Attributeisanamedpropertyofaclassthatdescribesa
valueheldbyeachobjectoftheclass.
Objectistoclassasvalueistoattribute.
E.g.Attributes:Name,bdate,weight.
Values:JoeSmith,21October1983,64
Color,modelyearandweightareattributesofCarobjects.
Eachattributehasavalueforeachobject.
Differentobjectsmayhavethesameordifferentvaluesfor
agivenattribute.
Eachattributenameisuniquewithinaclass.
Unit-1 45

Conventionsused(UML):
•Listattributesinthe2ndcompartmentoftheclassbox.Optional
details(likedefaultvalue)mayfolloweachattribute.
•Acolonprecedesthetype,anequalsignprecedesdefaultvalue.
•Showattributenameinregularface,leftalignthenameinthe
boxandusesmallcaseforthefirstletter.
•Similarlywemayalsoincludeattributevaluesinthe2nd
compartmentofobjectboxeswithsameconventions.
Unit-1 46

Operations and Methods
Anoperationisafunctionorprocedurethatmaybeapplied
toorbyobjectsinaclass.
E.g.Hire,fireandpaydividendareoperationsonclass
Company.
Objectidentifiersnottobelistedintheclass,theyare
implicitinmodels
Open,close,hideandredisplayareoperationsonclass
Window.
Donotlistobjectidentifiers;theyareimplicitin
models.
Unit-1 47

Sameoperationmayapplytomanydifferentclasses.
Suchanoperationispolymorphic.
Amethodistheimplementationofanoperationfora
class.
E.g.Inclassfile,printisanoperationyoucould
implementdifferentmethodstoprintASCIIfiles,print
binaryfiles,printdigitizedpicturefiles.
Whenanoperationhasmethodsonseveralclasses,itis
importantthatthemethodsallhavethesamesignature.
Ex:printshouldnothavefilenameasanargumentfor
onemethodandfilepointerasanargumentfortheother
method.
Unit-1 48

Featureisagenericwordforeitheranattributeoroperations.
UMLconventionsused–
Listoperationsin3rdcompartmentofclassbox.
Listoperationnameinregularface,leftalignanduselowercaseforfirst
letter.
Optionaldetailslikeargumentlistandreturntypemayfolloweachoperation
name.
Parenthesisencloseanargumentlist,commasseparatethearguments.Acolon
precedestheresulttype.
Directions:in,out,inout(Tomodify)
Unit-1 49

Summary of Notation for classes
Unit-1 50

Alinkisaphysicalorconceptualconnectionamong
objects.
E.g.JoeSmithWorksForSimplexCompany.
Mathematically,wedefinealinkasatuple–thatis,alistof
objects.
Alinkisaninstanceofanassociationgenerallyappears
asVerb.
Anassociationisadescriptionofagroupoflinkswith
commonstructureandcommonsemantics.
E.g.apersonWorksForacompany.
Anassociationdescribesasetofpotentiallinksinthesame
waythataclassdescribesasetofpotentialobjects.
Unit-1 51

Unit-1 52

Conventionsused(UML):
Linkisalinebetweenobjects;alinemayconsistofseveral
linesegments.
Ifthelinkhasthename,itisunderlined.
Associationconnectsrelatedclassesandisalsodenotedby
aline.
Showlinkandassociationnamesinitalics.
Associationnameisoptional,ifthemodelisunambiguous.
Ambiguityariseswhenamodelhasmultipleassociations
amongsameclasses.
Associationsareinherentlybidirectional.
ForExample:WorksForconnectsapersontoacompany.
Employsconnectsacompanytoaperson
Unit-1 53

Developersoftenimplementassociationsin
programminglanguagesasreferencesfromoneobject
toanother.
Areferenceisanattributeinoneobjectthatrefersto
anotherobject.
ForExample:adatastructureforPersonmightcontain
anattributeemployerthatreferstoaCompanyobject,
andaCompanyobjectmightcontainanattribute
employeesthatreferstoasetofPersonobjects.
Unit-1 54

Multiplicity
Multiplicityspecifiesthenumberofinstancesofoneclass
thatmayrelatetoasingleinstanceofanassociatedclass.
Multiplicityconstrainsthenumberofrelatedobjects.
UMLconventions:
UMLdiagramsexplicitlylistsmultiplicityattheendsof
associationlines.
UMLspecifiesmultiplicitywithaninterval,suchas
◦“1”(exactlyone).
◦“1..”(oneormore).
◦“3..5”(threetofive,inclusive).
◦“*”(many,i.ezeroormore).
Unit-1 55

One-to One Multiplicity
Unit-1 56

Zero-to-One Multiplicity
Workstation may have one of its windows
designated as the console to receive general
error messages.
Unit-1 57

Unit-1 58

One can use the symbol “arrow( )” to make the
direction of the name clear.
Unit-1 59

Association end names
Multiplicityimplicitlyreferstotheendsof
associations.ForE.g.Aone-to-manyassociationhas
twoends–
◦anendwithamultiplicityof“one”
◦anendwithamultiplicityof“many”
Youcannotonlyassignamultiplicitytoan
associationend,butyoucangiveitanameaswell.
Unit-1 60

Apersonisanemployeewithrespecttocompany.
Acompanyisanemployerwithrespecttoaperson.
Associationendnamesareoptional.
Associationendnamesarenecessaryforassociationsbetween
twoobjectsofthesameclass.Theycanalsodistinguish
multipleassociationsbetweenapairofclasses.
Unit-1 61

Associationendnamesarenecessaryforassociationsbetween
twoobjectsofthesameclass.
Containerandcontentsdistinguishthetwousagesof
Directoryintheself-association.
Eachdirectoryhasexactlyoneuserwhoisanownerandmany
userswhoareauthorizedtousethedirectory.
Unit-1 62

Associationendnamesunifymultiplereferencestothe
sameclass.
Whenconstructingclassdiagramsyoushouldproperly
useassociationendnamesandnotintroduceaseparate
classforeachreferenceasbelowfigshows.
Unit-1 63

Objectson“many”associationendhavenoexplicitorderandcanbe
consideredasasetbutsometimesobjectshaveanexplicitorder
Orderingisaninherentpartofassociation.Youcanindicateanorderedset
ofobjectsbywriting“{ordered}”nexttotheappropriateassociationend.
Workstationscreencontaininganumberofoverlappingwindows.
Eachwindowonascreenoccursatmostonceandhaveanexplicitorder
thatisonlythetopmostwindowisvisibleatanypointonthescreen
Orderingsometimesoccursfor“many”multiplicity.
Unit-1 64

Bags and Sequences
Normally,abinaryassociationhasatmostonelinkforapairof
objects.
Multiplelinksforapairofobjectsispermittedbyannotatingan
associationendwith{bag}or{sequence}
Abagisacollectionofelementswithduplicatesallowed.
Asequenceisanorderedcollectionofelementswithduplicates
allowed.
Itineraryisasequenceofairportsandthesameairportcanbe
visitedmorethanonce,soyoushoulduse{sequence}andnot
{ordered}.
{ordered}and{sequence}annotationsaresame,exceptthatthe
firstdisallowsduplicatesandtheotherallowsthem.
Unit-1 65

Association Classes-Adverbs
Anassociationclassisanassociationthatisalsoa
class.
Likethelinksofanassociation,theinstancesofan
associationclassderiveidentityfrominstancesofthe
constituentclasses.
Likeaclass,anassociationclasscanhaveattributes
andoperationsandparticipateinassociations.
accessPermissionisanattributeofAccessibleBy.
UMLnotationforassociationclassisaboxattachedto
theassociationbyadashedline.
Unit-1 66

Important in many-to-many associations.
Attributesforassociationclassunmistakablybelongto
thelinkandcannotbeascribedtoeitherobject.
accessPermissionisajointpropertyofFileanduser
cannotbeattachedtoeitherfileoruseralonewithout
losinginformation.
Unit-1 67

Figureshowsattributesfortwoone-to-many
relationships.
Eachpersonworkingforacompanyreceivesasalary
andhasjobtitle.
Thebossevaluatestheperformanceofeachworker.
Attributesmayalsooccurforone-to-oneassociations.
Unit-1 68

•Figureshowshowit’spossibletofoldattributesforone-to-one
andone-to-manyassociationsintotheclassoppositea“one”
end.
Unit-1 69

Anassociationclassparticipatinginanassociation.
Usersmaybeauthorizedonmanyworkstations.Each
authorizationcarriesapriorityandaccessprivileges.
Auserhasahomedirectoryforeachauthorized
workstation,butseveralworkstationsandusercan
sharethesamehomedirectory.
Unit-1 70

Theassociationclasshasonlyoneoccurrenceforeachpairing
ofPersonandCompany.
Incontrasttherecanbeanynumberofoccurrencesofa
PurchaseforeachPersonandCompany.Eachpurchaseis
distinctandhasitsownquantity,dateandcost.
Unit-1 71

Qualified Associations
AQualifiedAssociationisanassociationinwhichan
attributecalledthequalifierdisambiguatestheobjects
fora“many”associationends.
Itispossibletodefinequalifiersforone-to-manyand
many-to-manyassociations.
Aqualifierselectsamongthetargetobjects,reducing
theeffectivemultiplicityfrom“many”to“one”.
Unit-1 72

Abankservicesmultipleaccounts.Anaccountbelongsto
singlebank.
Withinthecontextofabank,theAccountNumberspecifies
auniqueaccount.Bankandaccountareclasses,and
AccountNumberisaqualifier.
Qualificationreduceseffectivemultiplicityofthis
associationfromone-to-manytoone-to-one.
qualificationincreasestheprecisionofamodel.
Unit-1 73

Thenotationofaqualifierisasmallboxontheend
oftheassociationlinenearthesourceclass.
Thequalifierboxmaygrowoutofanyside(top,
bottom,left,right)ofthesourceclass.
Thesourceclassplusthequalifieryieldsthetarget
class.
Bank+accountNumberyieldsanAccount,therefore
accountNumberislistedinaboxcontiguoustoBank.
Unit-1 74

Astockexchangelistsmanycompanies.However,it
listsonlyonecompanywithagiventickersymbol.
Acompanymaybelistedonmanystockexchanges,
possiblyunderdifferentsymbols.
Unit-1 75

Next Class :
Generalization, Example, OCL
Unit-1 76

Generalizationistherelationshipbetweenaclass(the
superclass)andoneormorevariationsoftheclass(the
subclasses).
Generalization(is-a)organizesclassesbytheirsimilarities
anddifferences,structuringthedescriptionofobjects.
Thesuperclassholdscommonattributes,operationsand
associations;thesubclassesaddspecificattributes,
operationsandassociations.
Eachsubclassissaidtoinheritthefeaturesofitssuperclass.
Unit-1 77

Unit-1 78

Generalizationistransitiveacrossanarbitrarynumberof
levels.
Thetermancestoranddescendentreferstogeneralization
ofclassesacrossmultiplelevels.
Aninstanceofasubclassissimultaneouslyaninstanceof
allitsancestorclasses.
Aninstanceincludesavalueforeveryattributeofevery
ancestorclass.
Aninstancecaninvokeanyoperationonanyancestorclass.
Eachsubclassnotonlyinheritsallthefeaturesofits
ancestorsbutaddsitsownspecificfeaturesaswell.
Ex:PumpaddsattributessuctionPressure,
dischargePressureandflowratewhichotherkindsof
equipmentdonotshare.
Unit-1 79

Unit-1 80

‘move’,‘select’,‘rotate’,and‘display’areoperations
thatallsubclassesinherit.
‘scale’appliestoone-dimensionalandtwo-dimensional
figures.
‘fill’appliesonlytotwo-dimensionalfigures.
Ageneralizationsetnameisanenumeratedattribute
thatindicateswhichaspectofanobjectisbeing
abstractedbyaparticulargeneralization.
Thewordwrittennexttothegeneralizationline
diagram-dimensionality-isageneralizationsetname.
Unit-1 81

Therecanbemultiplelevelsofgeneralization.
Eachobjectinheritsfeaturesfromoneclassateach
levelofgeneralization.
UMLconventionused:
Uselargehollowarrowheadtodenotegeneralization.
Thearrowheadpointstosuperclass.
Unit-1 82

Useofgeneralization–3purposes
Tosupportpolymorphism:Youcancallanoperation
atthesuperclasslevel,andtheOOlanguagecomplier
automaticallyresolvesthecalltothemethodthat
matchesthecallingobject’sclass.
Tostructurethedescriptionofobjects:i.e.toforma
taxonomyandorganizingobjectsonthebasisoftheir
similaritiesanddifferences.
Toenablereuseofcode:Inheritcodefromthe
previousapplicationaswellasfrompreviouswork.
Reuseismoreproductivethanrepeatedlywritingcode
fromscratch.
Unit-1 83

Thetermsgeneralization,specializationandinheritance
allrefertoaspectsofthesameidea.
Generalizationderivesfromthefactthatthesuperclass
generalizesthesubclasses.
Specializationreferstothefactthatthesubclassrefine
orspecializethesuperclasses.
Inheritanceisthemechanismforsharingattributes,
operations,and associationsvia the
generalization/specializationrelationship.
Unit-1 84

Overridingfeatures
Asubclassmayoverrideasuperclassfeaturebydefininga
featurewiththesamename.Theoverridingfeature
(subclassfeature)refinesandreplacestheoverridden
feature(superclassfeature).
Whyoverridefeature?
Tospecifybehaviorthatdependsonsubclass.
Totightenthespecificationofafeature.
Toimproveperformance.
Intheexample:”Figure”eachleafsubclasseshad
overridden‘display’feature.
Youmayoverridemethodsanddefaultvaluesofattributes.
Youshouldneveroverridethesignature,orformofa
feature.
Unit-1 85

3. 4 A Sample Class model
Unit-1 86

Unit-1 87

Unit-1 88

Expressing the behavior of navigating among classes.
Navigation is important because it lets you exercise a
model and uncover hidden flaws and omissions so that
you can repair them.
Example:
An institution may issue many credit card accounts, each
identified by an account number. Each account has a
maximum credit limit, a current balance, and a mailing
address. The account serves one or more customers
who reside at the mailing address. The institution
periodically issues a statement for each account. The
statement lists a payment due date, finance charge, and
minimum payment.
Unit-1 89

What transactions occurred for a credit card
account within a time interval?
What volume of transactions were handled by
an institution in the last year?
What customers patronized a merchant in the
last year by any kind of credit card?
How many credit card accounts does a
customer currently have?
What is the total maximum credit for a customer,
for all accounts?
Unit-1 90

Unit-1 91

Attributes. The syntax is the source object, followed by
a dot, and then the attribute name.
For example, the expression
aCreditCardAccount.maximumCredit takes a
CreditCardAccount object and finds the value of
maximumCredit.
Operations. An operation must be followed by
parentheses, even if it has no arguments
Simple associations. The target end may be indicated
by an association end name or, where there is no
ambiguity, a class name. In the example,
aCustomer.MailingAddress yields a set of addresses for
a customer.
Unit-1 92

Qualified associations. A qualifier lets you make a
more precise traversal. The expression
aCreditCardAccount.Statement[30 November 1999]
finds the statement for a credit card account with the
statement date of 30 November 1999.
Association classes. Given a link of an association
class, you can find the constituent objects. Alternatively,
given a constituent object, you can find the multiple links
of an association class.
Generalizations. Traversal of a generalization hierarchy
is implicit for the OCL notation.
Filters. There is often a need to filter the objects in a set.
The OCL has several kinds of filters, the most common
of which is the select operation.
Unit-1 93

Unit-1 94

What transactions occurred for a credit card account
within a time interval?
aCreditCardAccount.Statement.Transaction->
select(aStartDate <= transactionDate and
transactionDate <= anEndDate)
What volume of transactions were handled by an
institution in the last year?
anInstitution.CreditCardAccount.Statement.Transaction-
> select(aStartDate <= transactionDate and
transactionDate <= anEndDate).amount->sum()
What is the total maximum credit for a customer, for all
accounts?
aCustomer.MailingAddress.CreditCardAccount.
maximumCredit->sum()
Unit-1 95

End of Unit-1
Next Class –Advanced Class Modeling,
Chapter 4
Tags