Object-Oriented Analysis and Design Understanding System Development with UML 2.0 Mike O’Docherty Object-Oriented Analysis and Design Object-Oriented Analysis and Design Understanding System Development with UML 2.0 Mike O’Docherty Copyright2005 JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester, WestSussexPO198SQ,England Telephone(+44)1243779777 Email(forordersandcustomerserviceenquiries):[email protected] VisitourHomePageonwww.wiley.com AllRightsReserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystemor transmittedinanyformorbyanymeans,electronic,mechanical,photocopying,recording,scanningor otherwise,exceptunderthetermsoftheCopyright,DesignsandPatentsAct1988orunderthetermsofa licenceissuedbytheCopyrightLicensingAgencyLtd,90TottenhamCourtRoad,LondonW1T4LP,UK, withoutthepermissioninwritingofthePublisher.RequeststothePublishershouldbeaddressedtothe PermissionsDepartment,JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester,WestSussex PO198SQ,England,[email protected],orfaxedto(+44)1243770620. Thispublicationisdesignedtoprovideaccurateandauthoritativeinformationinregardtothesubject mattercovered.ItissoldontheunderstandingthatthePublisherisnotengagedinrenderingprofessional services.Ifprofessionaladviceorotherexpertassistanceisrequired,theservicesofacompetent professionalshouldbesought. OtherWileyEditorialOffices JohnWiley&SonsInc.,111RiverStreet,Hoboken,NJ07030,USA Jossey-Bass,989MarketStreet,SanFrancisco,CA94103-1741,USA Wiley-VCHVerlagGmbH,Boschstr.12,D-69469Weinheim,Germany JohnWiley&SonsAustraliaLtd,33ParkRoad,Milton,Queensland4064,Australia JohnWiley&Sons(Asia)PteLtd,2ClementiLoop#02-01,JinXingDistripark,Singapore129809 JohnWiley&SonsCanadaLtd,22WorcesterRoad,Etobicoke,Ontario,CanadaM9W1L1 Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappears inprintmaynotbeavailableinelectronicbooks. LibraryofCongressCataloging-in-PublicationData O’Docherty,Mike. Object-orientedanalysisanddesign:understandingsystemdevelopment withUML2.0/MikeO’Docherty. p.cm. Includesbibliographicalreferencesandindex. ISBN-13978-0-470-09240-8 ISBN-100-470-09240-8(pbk.:alk.paper) 1.Object-orientedprogramming(Computerscience)2.Computer software–Development.I.Title. QA76.64.O352005 005.1(cid:1)17–dc22 2005004182 BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary ISBN-13978-0-470-09240-8 ISBN-100-470-09240-8 Typesetin10/14Berkeley-MediumbyLaserwordsPrivateLimited,Chennai,India PrintedandboundinGreatBritainbyBiddlesLtd,King’sLynn Thisbookisprintedonacid-freepaperresponsiblymanufacturedfromsustainableforestry inwhichatleasttwotreesareplantedforeachoneusedforpaperproduction. ForAlice andGeorge Contents 1 Introduction 2 1.1 Background 4 1.2 ABriefHistoryofProgramming 4 1.3 Methodologies 5 1.4 AboutthisBook 5 1.4.1 ContentOverview 6 1.4.2 CaseStudies 7 1.4.3 Navigation 7 Part I Setting the Scene 9 2 ObjectConcepts 10 2.1 Introduction 12 2.2 WhatIsanObject? 13 2.3 IdenticalorEqual? 16 2.4 DepictingObjects 19 2.5 Encapsulation 20 2.6 AssociationandAggregation 21 2.7 GraphsandTrees 23 2.8 LinksandNavigability 25 2.9 Messages 27 2.10 InvokinganOperation 28 2.11 AnExampleCollaboration 30 2.12 HowanObject-OrientedProgramWorks 32 2.13 GarbageCollection 32 2.14 Classes 34 2.15 WhatDoesaClassDefine? 37 2.16 SharedDataandSharedOperations 39 2.17 Types 40 2.18 Terminology 41 2.19 ReusingCode 43