1University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 1Lectures 2 & 3:Introduction to Modeling & UML Why Build Models? What types of Models to build Intro to UML Class Diagrams Relationship between UML and program code Uses of UMLUniversity of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 2Getting started Youʼve just joined an ongoing project Where do you start? (oh, BTW, the project doesnʼt really have any documentation) Reverse Engineering: Recover design information from the code Create higher level views to improve understanding E.g. Structure of the code Code Dependencies Components and couplings E.g. Behaviour of the code Execution traces State machine models of complex objects E.g. Function of the code What functions does it provide to the user?2University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 3Sometimes you donʼt need a mapUniversity of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 4Why build models? Modelling can guide your exploration: It can help you figure out what questions to ask It can help to reveal key design decisions It can help you to uncover problems Modelling can help us check our understanding Reason about the model to understand its consequences Does it have the properties we expect? Animate the model to help us visualize/validate software behaviour Modelling can help us communicate Provides useful abstractions that focus on the point you want to make… …without overwhelming people with detail Throw-away modelling? The exercise of modelling is more important than the model itself Time spent perfecting the models might be time wasted…3University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 5Maps as Abstractions6University of TorontoDepartment of Computer Science© 2008 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license.4University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 7Dealing with problem complexity Abstraction Ignore detail to see the big picture Treat objects as the same by ignoring certain differences (beware: every abstraction involves choice over what is important) Decomposition Partition a problem into independent pieces, to study separately (beware: the parts are rarely independent really) Projection Separate different concerns (views) and describe them separately Different from decomposition as it does not partition the problem space (beware: different views will be inconsistent most of the time) Modularization Choose structures that are stable over time, to localize change (beware: any structure will make some changes easier and others harder)University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 8the Unified Modelling Language (UML) Third generation OO method Booch, Rumbaugh & Jacobson are principal authors Still evolving (currently version 2.0) Attempt to standardize the proliferation of OO variants Is purely a notation No modelling method associated with it! Was intended as a design notation Has become an industry standard But is primarily promoted by IBM/Rational (who sell lots of UML tools, services) Has a standardized meta-model Use case diagrams Class diagrams Message sequence charts Activity diagrams State Diagrams Module Diagrams Platform diagrams …5University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 9Modeling NotationsActivity diagramsbusiness processes;concurrency andsynchronization;dependenciesbetween tasks;UML Sequence Diagramsindividual scenariointeractions betweenusers and systemSequence ofmessages(UML) Statechartsresponses to eventsdynamic behaviorevent ordering,reachability,deadlock, etcUML Package DiagramsOverall architectureDependenciesbetween componentsUse Casesuserʼs viewLists functionsvisual overview of themain requirementsUML Class Diagramsinformation structurerelationships betweendata itemsmodular structure forthe systemUniversity of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 10Intro: Object Classes in UML:patientNameDate of Birthphysicianhistory:in-patientRoomBedTreatmentsfood prefs:out-patientLast visitnext visitprescriptions:patientNameDate of Birthphysicianhistory:heartNatural/artif.Orig/implantnormal bpm:eyesNatural/artif.Visioncolour:kidneyNatural/artif.Orig/implantnumberSource: Adapted from Davis, 1990, p67-6810..10..21..20..1 0..1Generalization (an abstraction hierarchy)Aggregation(a partitioning hierarchy)6University of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 11:patientNameDate of BirthHeightWeight:In-patientRoomBedPhysician:Out-patientLast visitnext visitphysician:heartNormal bpmBlood type:eyeColourDiameterCorrection:kidneyOperational?generalizationaggregationClass nameattributesservices0..111..20..10..20..1multiplicities:organNatural/artif.Orig/implantdonorUniversity of TorontoDepartment of Computer Science© 2012 Steve Easterbrook. This presentation is available free for non-commercial use with attribution under a creative commons license. 12What are classes? A class describes a group of objects with similar
View Full Document