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

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 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 8 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 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 1 Lecture 5:!Modeling Software Behaviour" (briefly: making UML abstractions…)" UML sequence Diagrams" Comparing Traces" Explaining Design Patterns" Style tips"University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 2 Uses of UML"As a sketch"Very selective - informal and dynamic"Forward engineering: describe some concept you need to implement"Reverse engineering: explain how some part of the program works"As a blueprint"Emphasis on completeness"Forward engineering: model as a detailed spec for the programmer"Reverse engineering: model as a code browser"Roundtrip: tools provide both forward and reverse engineering to move back and forth between program and code"As a Programming language"UML models are automatically compiled into working code"Requires sophisticated tools"“tripless” - the model is the code"2!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 3 Package Decomposition"Source: from Egyed “Automated Abstraction of Class Diagrams, TSE 2002 University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 4 Class Abstraction"Source: from Egyed “Automated Abstraction of Class Diagrams, TSE 20023!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 5 Finding Dependencies"Source: from Egyed “Automated Abstraction of Class Diagrams, TSE 2002 University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 6 Things to Model"E.g. Structure of the code"Code Dependencies"Components and couplings"E.g. Behaviour of the code"Execution traces"State machines models of complex objects"E.g. Function of the code"What functions does it provide to the user?"4!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 7 Sequence Diagrams"an Order" an OrderLine" a Product" a Customer"calculatePrice"getQuantity"getProduct"aProduct"getPricingDetails"calculateBasePrice"calculateDiscounts"getDiscountInfo"University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 8 Design Choices…"an Order" an OrderLine" a Product" a Customer"calculatePrice"CalculatePrice"discountedValue"getDiscountedValue(an Order)"getBaseValue"getPrice(quantity)"5!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 9 Creating and Deleting Objects"a Handler"a Query"Command"a Database"Statement"queryDatabase"new"results"extract results"close"new"execute"results"University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 10 Interaction Frames":Order"careful:"Distributor"regular:"Distributor":Messenger"dispatch"dispatch"loop"[for each line item]"alt"[value > $10,000]"dispatch"[else]"opt"[needs confirmation]"confirm"6!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 11 Interaction Frame Operators"Operator" Meaning"alt" Alternative; only the frame whose guard is true will execute"opt" Optional; only executes if the guard is true"par" Parallel; frames execute in parallel"loop" Frame executes multiple times, guard indicates how many"region" Critical region; only one thread can execute this frame at a time"neg" Negative; frame shows an invalid interaction"ref" Reference; refers to a sequence shown on another diagram"sd" Sequence Diagram; used to surround the whole diagram (optional)"University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 12 When to use Sequence Diagrams"Comparing Design Options"Shows how objects collaborate to carry out a task"Graphical form shows alternative behaviours"Assessing Bottlenecks"E.g. an object through which many messages pass"Explaining Design Patterns"Enhances structural models"Good for documenting behaviour of design features"Elaborating Use Cases"Shows how the user expects to interact with the system"Shows how the user interface operates"7!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 13 Modeling a Design Pattern"E.g. Observer Pattern"For a one-to-many dependency, when you need to maintain consistency"The subject pushes updates to all the observers" Subject""attach(Observer)"detach(Observer)"Notify() " concreteSubject"subjectState"getState()"setState() " Observer""update() " concreteObserver"observerState"update()"1"*"1"observers "subject "{observerState = "this.subject.getState()}"{for all o in observers" {o.update()} }"University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 14 Sequence Diagram for Observer"a Concrete"Subject"x : Concrete"Observer"y : Concrete"Observer"setState()"notify()"update()"update()"getState()"getState()"par"8!University of Toronto Department of Computer Science © 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons


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?