Sie sind auf Seite 1von 42

ObjectOrientedAnalysis, UML, UML ClassDiagrams

CSE 307 Presentation 8

Overview

Defineobjectmodelingandexplain itsbenefits. Recognizeandunderstandthebasicconceptsandconstructs ofobjectmodeling. diagrams DefinetheUMLanditsvarioustypesofdiagrams. Evolveabusinessrequirementsusecasemodelintoasystem analysisusecasemodel. Discoverobjectsandclasses,andtheirrelationships. Constructaclassdiagram.

CSE 307 Presentation 8

IntroductiontoObjectModeling
Object j orientedanalysis y ( (OOA) ) anapproach pp usedto
studyexistingobjects toseeiftheycanbereusedor adaptedfornewuses definenewormodifiedobjects thatwillbecombined withexistingobjectsintoausefulbusinesscomputing application

Objectmodeling atechniqueforidentifying objectswithinthesystemsenvironmentandthe relationshipsbetweenthoseobjects.


CSE 307 Presentation 8 3

IntroductiontotheUML
UnifiedModelingLanguage(UML) asetof modelingconventionsthatisusedtospecify ordescribeasoftwaresystemintermsof objects.
TheUMLdoesnotprescribeamethodfor developingsystemsonlyanotationthatisnow widely yaccepted p asastandardforobject j modeling.

CSE 307 Presentation 8

UMLDiagrams
UseCaseModelDiagrams StaticStructureDiagrams
Classdiagrams Objectdiagrams

InteractionDiagrams
Sequencediagrams Collaborationdiagrams g

StateDiagrams
Statechartdiagrams Activitydiagrams

ImplementationDiagrams
Componentdiagrams Deploymentdiagrams
CSE 307 Presentation 8 5

ClassDiagram:ClassvsInstance
Class name compartment Attributes compartment Operations Ope at o s co compartment pa t e t
Class
CSE 307 Presentation 8 6

Client companyAddress companyEmail companyFax companyName companyTelephone

ClassDiagram:ClassvsInstance
Object name compartment Attribute values Instances do not have operations
Instance
CSE 307 Presentation 8 7

FoodCo:Client companyAddress=Evans Farm, Norfolk companyEmail=mail@foodco.com companyFax=01589-008636 companyName=FoodCo N F dC companyTelephone=01589-008638

ClassDiagram:ClassvsInstance
ObjectInstancesoftenchangesfrequently whileclassesaregenerallypermanent. Instancescanbedestroyed destroyed. Objectinstancescanbeupdated.

CSE 307 Presentation 8

ClassDiagram:Attributes
Attributesare: Partoftheessentialdescriptionofaclass The h commonstructureof fwhat h the h class l can know Eachobjecthasitsownvalue foreach attributeinitsclass

CSE 307 Presentation 8

ClassDiagram:LinkvsAssociation
Yellow Partridge:Client

A link is a logical connection between two objects


FoodCo:Client Grace Chia:StaffMember

Soong Motor Co:Client

Carlos Moncada:StaffMember

Links
CSE 307 Presentation 8 10

ClassDiagram:LinkvsAssociation
Association role
StaffMember staffName staffNo staffStartDate staffContact liaises with companyAddress companyEmail companyFax p y companyName companyTelephone

Association
Client

Association name

Direction in which name should be read


Association
CSE 307 Presentation 8 11

ClassDiagram:LinkvsAssosiation
Anassociationdescribessetofsimilar instances. Linkedinstancesmaybeofdifferentclassor fromthesameclass. Link Li kcanconnectinstances i oitself. i lf

CSE 307 Presentation 8

12

ClassDiagram:Multiplicity
Associationshavemultiplicity Multiplicityistherangeofpermitted cardinalitiesofanassociation Represententerprise (orbusiness) rules Forexample:
Anybankcustomermayhaveoneormore accou s accounts Everyaccountisforone,andonlyone,customer

CSE 307 Presentation 8

13

ClassDiagram:Multiplicity
Multiplicities
StaffMember staffName staffNo staffStartDate 1 liaises with Client companyAddress Add 0..* companyEmail p y companyFax companyName companyTelephone

Exactly one staff member liaises with each client A staff member may liaise with zero, one or more clients
CSE 307 Presentation 8 14

ClassDiagram:MultiplicityNotations
Multiplicity Exactly one Z Zero or one Zero or more One or more p Range g Specific Notations 1 blank 0 1 0..1 0..* 0 * * 1 * 1.. 0..3 Example A student studies in exactly one department Ab bed d may h have zero or one patient Student may issue for zero or more IC A course may have one or more teachers A student may y borrow at most 3 books from the library
15

CSE 307 Presentation 8

ClassDiagram:Operations
Operationsare: Anessentialpartofthedescriptionofaclass The h commonb behaviour h i shared h d b byall llobjects bj oftheclass Servicesthatobjectsofaclasscanprovideto otherobjects

CSE 307 Presentation 8

16

ClassDiagram:Operations
Operationsdescribe whatinstancesofa classcando:
Setorrevealattribute values Performcalculations Sendmessagesto otherobjects Createordestroylinks
Campaign actualCost campaignFinishDate campaignStartDate p g completionDate datePaid estimatedCost titl title checkCampaignBudget ( ) getCampaignContribution ( ) recordPayment ( ) setCompleted ( )

CSE 307 Presentation 8

17

ClassDiagram:State
Stateofaninstanceisdefinedby
Thevaluesoftheattributes Thenumberoflinks

Anobjectmayshowdifferentbehaviorin diff different tstate t t Statetransitionisinitiatedbyanevent Statecanbechangedonlybyexecutingan operation


CSE 307 Presentation 8 18

ClassDiagram:Stereotypes
WhatdoesStereotype Stereotype mean?
Ref3:Section7.3.2(page165).

Instancesofaclassstereotypehaveashared focusoncertainkindofthings. Analysisclassstereotypesdifferentiatethe rolesobjectscanplay:


Boundary yobjects j Entityobjects Controlobjects j
CSE 307 Presentation 8 19

ClassDiagram:Stereotypes
BoundaryClasses
Modelsinteractionbetweenthesystemand actors Mayincludeinterfacestoothersoftwareor devices Maintaskistomanagethetransferofinformation acrosssystem y boundaries

CSE 307 Presentation 8

20

Notationsforboundaryclass
<<boundary>> User Interface::AddAdvertUI startInterface( ) assignStaff( g () selectClient( ) selectCampaign( ) User Interface::AddAdvertUI

startInterface( ) g () assignStaff( selectClient( ) selectCampaign( )

User Interface::AddAdvertUI
CSE 307 Presentation 8 21

ClassDiagram:Stereotypes
EntityClasses
Modelsinformationandtheirrelatedbehavior Maybeaboutaperson person,areallifeobjectoran event Oftenrequirepersistentstorage

CSE 307 Presentation 8

22

Notationsforentityclass
<<entity>> Campaign title campaignStartDate campaignFinishDate getCampaignAdverts( ) addNewAdvert( () Campaign title campaignStartDate campaignFinishDate getCampaignAdverts( ) addNewAdvert( )

Campaign
CSE 307 Presentation 8 23

ClassDiagram:Stereotypes
ControlClasses
Modelthecoordination,sequencing,transactions andcontrolofotherobjects Oneusecaseshouldresultinonecontrolclass

CSE 307 Presentation 8

24

Notationsforcontrolclass
<<control>> Control::AddAdvert showClientCampaigns( ) showCampaignAdverts( ) createNewAdvert( ) C t l AddAd Control::AddAdvert t

showClientCampaigns( ) showCampaignAdverts( ) () createNewAdvert(

AddAvert
CSE 307 Presentation 8 25

ClassDiagram:Stereotypes
Use-case pay fee Use-case register RegisterUI

PayFeeUI PayFee Register

ShowPRUI

ShowResultUI

RegistrationFee StudentInfo St d tI f

FineInfo
CSE 307 Presentation 8

C CourseInfo I f

R lt Result
26

BuildingtheClassDiagram
Twomainwaystoproducethis:
Directlybasedonknowledgeoftheapplication domain(aDomainModel) Byproducingaseparateclassdiagramforeach usecase,thenassemblingthemintoasingle model(anAnalysisClassModel)

CSE 307 Presentation 8

27

FromUseCasetoClasses
Startwithoneusecase Identifythelikelyclassesinvolved(theuse casecollaboration) Drawacollaborationdiagramthatfulfilsthe needsoftheusecase Translatethiscollaborationintoaclass diagram Repeatforotherusecases Combinethediagrams
CSE 307 Presentation 8 28

FromUseCasetoClasses:Step1
Use Case : Assign staff to a campaign Actor Action 1. None 3. Select the client name 5. Select the relevant campaign 7. Select a staff member to assign to the campaign
CSE 307 Presentation 8

System Response 2. Display List of Client Name 4. List the titles of the campaigns related to that client 6. Display list of staff not assigned i d to t that th t campaign i 8. Present a message confirming the allocation of staff
29

FromUseCasetoClasses:Step2
Guidelinetoeliminatecandidateclasses Anumberoftestshelptocheckwhethera candidateclassisreasonable
Isitbeyondthescopeofthesystem? Does D i itrefer f tothe h systemasawhole? h l ? Doesitduplicateanotherclass? Isittoovague? (Moreonnextslide)
CSE 307 Presentation 8 30

FromUseCasetoClasses:Step2
Isittootiedupwithphysicalinputsandoutputs? Isitreallyanattribute? Isitreallyanoperation? Isitreallyanassociation?

IfanyanswerisYes Yes ,considermodellingthe potentialclassinsomeotherway(ordonot modelitatall)

CSE 307 Presentation 8

31

FromUseCasetoClasses:Step2
Theidentifiedclasses
Client Campaign StaffMember

CSE 307 Presentation 8

32

FromUseCasetoClasses:Step3
Initialcollaborationdiagram

Campaign Manager

:Client

:Campaign

:StaffMember

CSE 307 Presentation 8

33

FromUseCasetoClasses:Step3
Addingboundaryandcontrolclasses

Campaign Manager

:AssignStaffUI

:AssignStaff
5 3 4

:Client Cli t
CSE 307 Presentation 8

:Campaign C i

:StaffMember St ffM b
34

FromUseCasetoClasses:Step3
Addingmessages
1 2

Campaign Manager

:AssignStaffUI

:AssignStaff

7: AssignStaff()

:Client Cli t
CSE 307 Presentation 8

:Campaign C i

:StaffMember St ffM b
35

FromUseCasetoClasses:Step3
Finalizing
4: selectClient() 7: selectCampaign() 10: assignStaff() 5: showClientCampaign() 8: showCampaignStaff() 11: asssignStaff() 2: startInterface() ()

Campaign Manager

:AssignStaffUI

:AssignStaff

13: AssignStaff()

:Client Cli t
CSE 307 Presentation 8

:Campaign C i

:StaffMember St ffM b
36

FromUseCasetoClasses:Step4
<<boundary>> <<b d >> AssignStaffUI startInterface() assignStaff() selectClient() selectCampaign() p g () <<control>> << t l>> AssignStaff assignStaff() getClientCampaign() showCampaignStaff()

<<entity>> Client companyName companyAddress getClientCampaign() getClients()

<<entity>> Campaign site campaignStartDate getCampaignStaff() assignStaff()


CSE 307 Presentation 8

<<entity>> StaffMemver staffNo staffName getStaff() assignStaff() getStaffDetails()


37

AssigningOperations:CRCCards
ClassResponsibilityCollaboration Class Responsibility Collaborationcardshelp tomodelinteractionbetweenobjects Foragivenscenario(orusecase):
Brainstormtheobjects Allocate All toteammembers b Roleplaytheinteraction

CSE 307 Presentation 8

38

CRCCards
Class Name: Responsibilities Responsibilities of a class are listed in this section. Collaborations Collaborations C ll b i with i h other h classes are listed here, together with a brief description of the purpose of the collaboration.

CSE 307 Presentation 8

39

Class Name R Responsibilities ibiliti Provide client information. Provide list of campaigns. Class Name Responsibilities

Client C ll b ti Collaborations

Campaign provides campaign details. Campaign Collaborations

Provide campaign information. Provide list of adverts. adverts Add a new advert. Class Name Responsibilities Provide advert details. Construct adverts. Advert

Advert provides advert details details. Advert constructs new object.

Collaborations

CSE 307 Presentation 8

40

CRCCards
Effectiveroleplaydependsonanexplicit strategyfordistributingresponsibilityamong classes Forexample:
Each E hrole l player l t tries i t tob bel lazy Persuadesotherplayerstheir classshouldaccept responsibilityforagiventask

MayusePaperCASEtodocumentthe associations i ti and dli links k


CSE 307 Presentation 8 41

ThankYou & KeepSmiling

CSE 307 Presentation 8

42

Das könnte Ihnen auch gefallen