Sept. 25, 2003CS WPI1 CS 509 Design of Software Systems Lecture #4 Thursday, Sept. 25, 2003
Sept. 25, 2003CS WPI2 §Term Project administration §Questions §Quiz #2 §Review Chapter 2 §UML Exercise Class Format for Today
Sept. 25, 2003CS WPI3 Meeting Coordinator Project §Return Phase 1 (Requirements) document l Job well done! l Grading criteria §Group evaluation forms l No major issues l Is this a worthwhile activity?
Sept. 25, 2003CS WPI4 Questions? §About Phase 2 §From last week’s class §From the reading §Anything else?
Sept. 25, 2003CS WPI5 Quiz #2 Choose 5 questions to answer Or answer 6 for extra credit
Sept. 25, 2003CS WPI6 Chapter 2 – UML Unified Modeling Language
Sept. 25, 2003CS WPI7 What is UML? §Unified Modeling Language comes from a number of places (see 1 st ¶ of Intro., p. 24) §Different notations combined into one standard §Now most commonly used standard in Software Engineering
Sept. 25, 2003CS WPI8 Why do we need notation? §Ability to articulate complex ideas succinctly & precisely §Conventions provide accuracy & clarity §Leaves less room for misinterpretation & ambiguity
Sept. 25, 2003CS WPI9 What does notation provide? §Well defined semantics §Well suited for representing a given aspect of a system l Easy to draw by hand §Well understood among project participants
Sept. 25, 2003CS WPI10 Overview of UML §Subset of UML diagrams covered in book: l Use Case diagrams l Class diagrams l Sequence diagrams l Statechart diagrams l Activity diagrams
Sept. 25, 2003CS WPI11 Use Case Diagrams WatchUser ReadTime SetTime ChangeBattery SimpleWatch Figure 2-1 (page 25). A UML use case diagram describing the functionality of a simple watch. WatchRepairPerson
Sept. 25, 2003CS WPI12 Class Diagrams Battery load() 1 2 Time now() PushButton state push() release() blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh() LCDDisplay SimpleWatch Figure 2-2 (page 26). An expanded UML class diagram describing the elements of a simple watch
Sept. 25, 2003CS WPI13 Sequence Diagrams :SimpleWatch:Time:Display pressButton1() blinkHours() blinkMinutes() pressButton2() incrementMinutes() refresh() pressButtons1And2() commitNewTime() stopBlinking() pressButton1() :WatchUser Figure 2-3 (page 27). A UML sequence diagram for a simple watch
Sept. 25, 2003CS WPI14 Statechart Diagrams button1&2Pressed button1Pressed button2Pressed button1Pressed button1&2Pressed Increment Minutes Increment Hours Blink Hours Blink Seconds Blink Minutes Increment Seconds Stop Blinking Figure 2-4 (page 27). A UML statechart diagram for a simple watch.
Sept. 25, 2003CS WPI15 Activity Diagrams Open Incident Allocate Resources Coordinate Resources Document Incident Archive Incident Figure 2-5 (page 28). An example of a UML activity diagram.
Sept. 25, 2003CS WPI16 Modeling Concepts §Systems §Models §Views §Phenomena §Concepts §Abstraction
Sept. 25, 2003CS WPI17 Systems §Organized set of communicating parts designed for a specific purpose §Parts can be broken down into simpler subsystems §Decomposition is recursively applied to subsystems until we get to objects §Objects are small enough to be fully comprehended without further decomposition
Sept. 25, 2003CS WPI18 Modeling §Abstraction for dealing with complexity §Complex systems described by >1 model §Each model focuses on a different aspect §What’s interesting, what’s irrelevant? l Depends on what you’re trying to model §Rule of thumb: each entity should contain at most 7 2 parts (Why?)
Sept. 25, 2003CS WPI19 Modeling Example §Airplane models: l Scale model of exterior surface allows investigation of aerodynamics l Flight simulator models layout & behavior of flight instruments §Both models are less complex than the real life concept (airplane) they represent
Sept. 25, 2003CS WPI20 Views §Decomposition of a model into smaller parts §Focus on a subset of a model to make it more understandable §Views may overlap §Different notations can be used to represent the same view View Model System ** describes depicts 11 Figure 2-8 (page 31). A System can be described by many different Models, each of which can be depicted by many different Views
Sept. 25, 2003CS WPI21 Phenomena & Concepts §A Phenomenon is an object as it is perceived in the world l An instance of a concept §A Concept is a generalization (abstraction) for some group of phenomena l Describes properties that are common across a set of phenomena
Sept. 25, 2003CS WPI22 Concepts & Abstraction §A Concept is defined as a 3-tuple: l Name l Purpose (intent) l Members (extent) §Abstraction: l Classification of phenomena into concepts l Simpler to manipulate & examine (less info) l Irrelevant details are “abstracted away”
Sept. 25, 2003CS WPI23 Modeling Revisited §Abstractions that can answer specific questions about phenomena §May exist prior to the phenomena it represents l UML model of system not yet implemented l Theory derived from model prior to discovery (black hole, top quark, dark matter, etc.) §Used to communicate about the system l Notation describes model l Views show aspects of model for specific need
Sept. 25, 2003CS WPI24 More Modeling Concepts §Data Types §Abstract Data Types (ADTs) §Instances, Classes and Inheritance §Abstract Classes §Objects §Events & Messages §Falsification & Prototyping
Sept. 25, 2003CS WPI25 Data Types §Abstraction in the context of a programming language §Describes a set of instances that share common characteristics: Name distinguishes it from other data types (e.g. int, char, etc.) l Purpose defines structure & operations valid on all members of the type l Members comprise the extent of the type
Sept. 25, 2003CS WPI26 Abstract Data Types Defines a data type at a higher level of abstraction ( LinkedList, Stack ) §Defines operations & behavior, but not internal structure: Exposes API only (e.g. push, pop, etc.) l Hides implementation details l Changes to internal representation should not effect use by caller
Sept. 25, 2003CS WPI27 Instances §An Instance is any member of a specific data type (abstract or not) l Can be manipulated with operations defined by the type l Internal structure may or may not be hidden §A data type is similar to a concept §An instance is similar to a phenomenon
Sept. 25, 2003CS WPI28 Classes §Abstraction in the context of an object-oriented programming language §Like ADT, encapsulates structure & behavior §Unlike ADT, defined in terms of other classes in an inheritance hierarchy: l Base, Super or Parent class is a generalization l Sub or Child class is a more specific refinement
Sept. 25, 2003CS WPI29 Inheritance §Classes define operations and attributes that can be applied to instances §Operations/attributes defined in base class are inherited by subclass §Operations/attributes which are defined only in subclass are not accessible in base class
Sept. 25, 2003CS WPI30 Abstract Classes § Generalization l Purpose is to model shared attributes & behavior § Represents generalized concepts § Never instantiated l Does not correspond to any existing concept § Used to reduce complexity, promote reuse § Examples?
Sept. 25, 2003CS WPI31 Objects §Instances of a class l Unique identity, stores attribute values (state) l Each object belongs to exactly one class §Instance names are underlined in UML l Distinguish from type/class that defines them § Attributes may not be visible to entire system l Type modifiers specify visibility l Examples?
Sept. 25, 2003CS WPI32 Events and Messages §Event Class: an abstraction for a kind of event §Event: instance of an Event Class l Can be a Message sent from one object to another §Message: l Usually a request or notification l Name and some arguments l Corresponds to some operation
Sept. 25, 2003CS WPI33 Object-oriented Modeling §Used in both analysis and design §Analysis focuses on application domain l Represents aspects of the user’s environment l Helps developers understand the problem(s) §Design focuses on solution domain l Richer space of all possible solutions l Changes with technology (Figure 2-14, page 37)
Sept. 25, 2003CS WPI34 Figure The application domain model represents entities of the environment which are relevant to an air traffic control system (e.g., aircraft, traffic controllers). The system model represents entities that are part of the system (e.g., map display, flight plan database). In object-oriented analysis and design, the application domain model is also part of the system model. An example in this figure is the TrafficControl package that appears in both models.
Sept. 25, 2003CS WPI35 Falsification and Prototyping §Falsification: l Process of identifying defects in the model Details missing or incorrectly represented Model doesn’t correspond to reality §Prototype: l Simulate some aspect of solution (often UI) l Users may falsify prototype §Easier to demonstrate that a model is incorrect than to prove it is correct – why?
Sept. 25, 2003CS WPI36 UML Exercise – Diagrams Vending Machine Problem §Discussion: define problem l How would you model a vending machine? l What is the process of making a purchase? §Create Diagrams l Which type of diagram l Model some piece of problem l Present to class
Sept. 25, 2003CS WPI37 For Next Time Chapter 3 Project Communication