DOC PREVIEW
Toronto CSC 302 - Lecture 5 - Modeling Software Behaviour

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 1Lecture 5:Modeling Software Behaviour UML sequence Diagrams Comparing Designs Explaining Design Patterns Style tipsUniversity of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 2Things to ModelE.g. Structure of the codeCode DependenciesComponents and couplingsE.g. Behaviour of the codeExecution tracesState machines models of complex objectsE.g. Function of the codeWhat functions does it provide to the user?2University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 3Sequence Diagramsan Order an OrderLine a Product a CustomercalculatePricegetQuantitygetProductaProductgetPricingDetailscalculateBasePricecalculateDiscountsgetDiscountInfoUniversity of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 4Design Choices…an Order an OrderLine a Product a CustomercalculatePriceCalculatePricediscountedValuegetDiscountedValue(an Order)getBaseValuegetPrice(quantity)3University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 5Creating and Deleting Objectsa Handlera QueryCommanda DatabaseStatementqueryDatabasenewresultsextract resultsclosenewexecuteresultsUniversity of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 6Interaction Frames:Ordercareful:Distributorregular:Distributor:Messengerdispatchdispatchloop[for each line item]alt[value > $10,000]dispatch[else]opt[needs confirmation]confirm4University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 7Interaction Frame OperatorsSequence Diagram; used to surround the wholediagram (optional)sdReference; refers to a sequence shown on anotherdiagramrefNegative; frame shows an invalid interactionnegCritical region; only one thread can execute thisframe at a timeregionFrame executes multiple times, guard indicates howmanyloopParallel; frames execute in parallelparOptional; only executes if the guard is trueoptAlternative; only the frame whose guard is true willexecutealtMeaningOperatorUniversity of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 8When to use Sequence DiagramsComparing Design OptionsShows how objects collaborate to carry out a taskGraphical form shows alternative behavioursAssessing BottlenecksE.g. an object through which many messages passExplaining Design PatternsEnhances structural modelsGood for documenting behaviour of design featuresElaborating Use CasesShows how the user expects to interact with the systemShows how the user interface operates5University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 9Comparing Designs:user:ATM :BankInsert CardPrompt for PIN#Type PIN#Req ValidationDisplay MenuConfirm ValidRequest CashPrompt for amountEnter amountSufficient funds?Confirm fundsDispense CashDisplay MenuEnd TransactionWithdraw fundsReturn Card:ATM :BankInsert CardPrompt for PIN#Type PIN#Req ValidationDisplay MenuConfirm ValidRequest CashPrompt for amountEnter amountSufficient funds?Confirm fundsDispense CashAnother Trans?DeclineWithdraw fundsReturn CardPrint ReceiptPrint Receipt:userUniversity of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 10Modeling a Design PatternE.g. Observer PatternFor a one-to-many dependency, when you need to maintain consistencyThe subject pushes updates to all the observers Subjectattach(Observer)detach(Observer)Notify() concreteSubjectsubjectStategetState()setState() Observerupdate() concreteObserverobserverStateupdate()1*1observers subject {observerState = this.subject.getState()}{for all o in observers {o.update()} }6University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 11Sequence Diagram for Observera ConcreteSubjectx : ConcreteObservery : ConcreteObserversetState()notify()update()update()getState()getState()University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 12Style GuideSpatial LayoutStrive for left-to-right ordering of messagesPut proactive actors on the leftPut reactive actors on the rightReadabilityKeep diagrams simpleDon’t show obvious return valuesDon’t show object destructionUsageFocus on critical interactions onlyConsistencyClass names must be consistent with class diagramMessage routes must be consistent with (navigable) class


View Full Document

Toronto CSC 302 - Lecture 5 - Modeling Software Behaviour

Documents in this Course
Load more
Download Lecture 5 - Modeling Software Behaviour
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 5 - Modeling Software Behaviour and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 5 - Modeling Software Behaviour 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?