Você está na página 1de 24

ObjectOrientedSoftwareEngineering

UsingUML,Patterns,andJava

RequirementsAnalysis
(Part1ObjectModeling)
RequirementsAnalysis

Formalizationofrequirementselicitedfromusers
Analysismodels
Functionalmodel(usecases)
Analysisobjectmodel(classdiagrams)
Dynamicmodel(statechartandsequencediagrams)

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 2
ObjectModels

AnalysisObjectModel
Classesandobjectsthatdescribetheapplicationdomain
PartoftheRequirementsAnalysisDocument(RAD)
Examples:BoardGame,Watch
SolutionObjectModel
Classesandobjectsthatareusedtosolvetheproblem
PartoftheObjectDesignDocument(ODD)
Examples:Tree,Hashtable,Widget
DuringRequirementsAnalysis,wefocusonbuildingthe
AnalysisObjectModel

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 5
ObjectModelsandDynamicModels

Objectmodel
Focusesonindividualconceptsmanipulatedbysystem
Classdiagramsrepresentrelationshipsbetweenclassesandobjects
andpropertiesofthoseclassesandrelationships
Dynamicmodel
Focusesonbehaviorofthesystem
Sequencediagramsrepresentinteractionsbetweenobjectswithina
singleusecase
Statechartsrepresentbehaviorwithinasingleobject

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 6
AnalysisActivities

Identifyingentityobjects Object Modeling


Identifyingboundaryobjects
Identifyingcontrolobjects
Mappingusecasestoobjectswithsequencediagrams
ModelinginteractionsamongobjectswithCRCcards
Identifyingassociations Dynamic Modeling
Identifyingaggregates
Identifyingattributes
Modelingstatedependentbehaviorofindividualobjects
Modelinginheritancerelationshipsbetweenobjects
Reviewingtheanalysismodel
ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 7
ActivitiesduringObjectModeling
Maingoal:Findtheimportantabstractions
Whathappensifwefindthewrongabstractions?
Iterateandcorrectthemodel
Stepsduringobjectmodeling
1.Classidentification
Basedonthefundamentalassumptionthatwecanfindabstractions
2.Findtheattributes
3.Findthemethods
4.Findtheassociationsbetweenclasses
Orderofsteps
Goal:getthedesiredabstractions
Orderofstepssecondary,onlyaheuristic
Iterationisimportant

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 8
ClassIdentification

Identifytheboundariesofthesystem
Identifytheimportantentitiesinthesystem
Classidentificationiscrucialtoobjectorientedmodeling
Basicassumption:
1.Wecanfindtheclassesforanewsoftwaresystem(Forward
Engineering)
2.Wecanidentifytheclassesinanexistingsystem(Reverse
Engineering)
Dependingonthepurposeofthesystemdifferentobjectsmight
befound
Howcanweidentifythepurposeofasystem?
Scenariosandusecases

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 9
PiecesofanObjectModel
Classes
Associations(Relations)
Genericassociations
Canonicalassociations
PartofHierarchy(Aggregation)
KindofHierarchy(Generalization)
Attributes
Detectionofattributes
Applicationspecific
Attributesinonesystemcanbeclassesinanothersystem
Turningattributestoclasses
Operations
Detectionofoperations
Genericoperations:Get/Set,Generalworldknowledge,designpatterns
Domainoperations:Dynamicmodel,Functionalmodel

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 10
ObjectvsClass
Object(instance):Exactlyonething
Class:describesagroupofobjectswithsimilarproperties
Objectdiagram:Agraphicnotationformodelingobjects,classes
andtheirrelationships("associations"):
Classdiagram:Templatefordescribingmanyinstancesofdata.Useful
fortaxonomies,patters,schemata...
Instancediagram:Aparticularsetofobjectsrelatingtoeachother.
Usefulfordiscussingscenarios,testcasesandexamples

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 11
Mappingpartsofspeechtoobjectmodelcomponents
[Abbott,1983]
Partofspeech Modelcomponent Example
Propernoun object JimSmith
Impropernoun class Toy,doll
Doingverb method Buy,recommend
beingverb inheritance isa(kindof)
havingverb aggregation hasan
modalverb constraint mustbe
adjective attribute 3yearsold
transitiveverb method enter
intransitiveverb method(event) dependson

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 13
ObjectTypes
EntityObjects
Representthepersistentinformationtrackedbythesystem
(Applicationdomainobjects,Businessobjects)
BoundaryObjects
Representtheinteractionbetweentheuserandthesystem
ControlObjects:
Representthecontroltasksperformedbythesystem
Havingthreetypesofobjectsleadstomodelsthataremore
resilienttochange.
Theinterfaceofasystemchangesmorelikelythanthecontrol
Thecontrolofthesystemchangemorelikelythantheapplication
domain
ObjecttypesoriginatedinSmalltalk:
Model,View,Controller(MVC)

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 14
Example:2BWatchObjects

Year Button
ChangeDate

Month
LCDDisplay

Day

Entity Objects Control Objects Interface Objects

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 15
NamingofObjectTypesinUML

UMLprovidesseveralmechanismstoextendthelanguage
UMLprovidesthestereotypemechanismtopresentnewmodelingelements

<<Entity>> <<Boundary>>
Year <<Control>> Button
ChangeDate
<<Entitity>>
Month <<Boundary>>
LCDDisplay
<<Entity>>
Day

Entity Objects Control Objects Boundary Objects

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 16
RecommendedNamingConventionforObjectTypes

Todistinguishthedifferentobjecttypesonasyntacticalbasis,we
recommendsuffixes:
Objectsendingwiththe_Boundarysuffixareboundaryobjects
Objectsendingwiththe_Controlsuffixarecontrolobjects
Entityobjectsdonothaveanysuffixappendedtotheirname.

Year Button_Boundary
ChangeDate_
Control
Month

LCDDisplay_Boundary

Day

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 17
IdentifyingEntityObjects

Entityobjects
Persistentinformationtrackedbysystem
Heuristics
Termsthatdevelopersorusersneedtoclarifyinorderto
understandtheusecase
Recurringnounsintheusecase
Realworldentitiesthatthesystemneedstotrack
Realworldactivitiesthatthesystemneedstotrack
Datasourcesorsinks

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 19
IdentifyingBoundaryObjects

Boundaryobjects
Interactionsbetweenactorsandsystem
Heuristics
Identifyuserinterfacecontrolsthattheuserneedstoinitiatethe
usecase
Identifyformstheuserneedstoenterdataintothesystem
Identifynoticesandmessagesthesystemneedstorespondtothe
user
Identifyactorterminalstorefertotheuserinterfaceunder
consideration
Donotmodelthevisualaspectsoftheuserinterface
Useendusersterms

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 20
IdentifyingControlObjects

Controlobjects
Realizeusecases,encapsulatesthebehavioroftheusecase
Usuallynotpersistent,existsinthelifetimeoftheusecase
Helpsclarifytheentryandexitconditionsoftheusecase
Heuristics
Identifyonecontrolobjectperusecase
Identifyonecontrolobjectperactorintheusecase

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 21
IdentifyingAssociations

Association
Arelationshipbetweentwoormoreclasses
Properties
Namedescribeswhattherelationshipisallabout
Rolethefunctionofeachclassintheassociation
Multiplicitynumberofpossibleinstances
Heuristics
Examineverbphrases
Nameassociationsandrolesprecisely
Usequalifierstoidentifynamespacesandkeys
Eliminateassociationsthatcanbederivedfromotherassociations
Worryaboutmultiplicitylater
Minimizethenumberofassociations

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 22
Qualifiers

Without qualification
1 * File
Directory
filename

With qualification
1 01
Directory filename File

Qualifierscanbeusedtoreducethemultiplicityofan
association.

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 23
IdentifyingAggregates

Aggregate
Anassociationdenotingwholepartrelationship
Compositionaggregate
Wholeandpartscannotexistwithouteachother
Denotesispartofrelationship
Sharedaggregate
Wholeandpartscanexistindependently
Denotesbelongstorelationship
Heuristics
1tomanyrelationshipscouldpotentiallybewholepart
relationships

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 24
Aggregation
Anaggregationisaspecialcaseofassociationdenotingaconsistsof
hierarchy.
Theaggregateistheparentclass,thecomponentsarethechildrenclass.
Exhaust system Exhaust system

1 0..2 1 0..2
Muffler Tailpipe Muffler Tailpipe

diameter diameter diameter diameter

Asoliddiamonddenotescomposition,astrongformofaggregationwhere
componentscannotexistwithouttheaggregate.(BillofMaterial)
TicketMachine

3
ZoneButton

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 25
IdentifyingAttributes

Attributes
Propertiesofindividualobjects
Properties
Name
Type
Heuristics
Examinepossessivephrases
Representstoredstateasanattribute
Describeeachattribute

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 26
ModelingInheritanceRelationships

Generalization
Identificationofabstractconceptsfromlowerlevelones
Specialization
Identificationofmorespecificconceptsfromahighlevelone
Heuristics
Lookforclassesthatsharesimilarities
Lookforgroupsofclassesthatappeartobeataxonomy

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 27
AStrategyforBuildingObjectModels

Explicitlyschedulemeetingsforobjectidentification
Firstjustfindobjects
Thentrytodifferentiatethembetweenentity,interfaceand
controlobjects
Findassociationsandtheirmultiplicity
Unusualmultiplicitiesusuallyleadtonewobjectsorcategories
IdentifyInheritance:LookforaTaxonomy,Categorize
IdentifyAggregation

Allowtimeforbrainstorming,Iterate,iterate

ModifiedfromoriginalsofBruegge&Dutoit ObjectOrientedSoftwareEngineering:UsingUML,Patterns,andJava 33

Você também pode gostar