Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University.

Similar presentations


Presentation on theme: "Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University."— Presentation transcript:

1

2 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 1 Modelling with UML CS223 Lecture 4 (see BD Ch. 2) Ananda Amatya Notice: Surgery Sessions (Weeks 6-10) Mon in C1.01 & Fri in C1.04 Please attend any one session convenient to you

3 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 2 Overview: modelling with UML What is modelling? What is UML? Use case diagrams Class diagrams Sequence diagrams (Collaboration diagrams) Activity diagrams StateChart diagrams

4 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 3 What is modelling? Modelling building an abstraction of reality. Abstractions simplifications: ignore irrelevant details focus on matters of concern. What is relevant and what is irrelevant? depends on the purpose of the model.

5 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 4 Example: street map that models access roads

6 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 5 Why model software? More sophisticated software means more complexity: Windows XP > 40 million lines of code; Several coders must be involved. One developers code must be understood by another developer. Complex systems must be simplified: Modelling is a way of achieving this.

7 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 6 Systems, Models and Views System: an organised set of communicating parts. Model: an abstraction describing a subset of a system. View: a selected aspect of a model. Notation: a set of graphical or textual rules for depicting views. Views and models of a single system may overlap each other. Examples: System: Aircraft Models: Flight simulator, scale model Views: All blueprints, electrical wiring, fuel system

8 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 7 Systems, Models and Views Aircraft Flightsimulator Scale Model Blueprints Electrical Wiring Fuel System

9 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 8 Models, Views and Systems (UML) SystemModel View * * Depicted by Described by Airplane: System Blueprints: View Fuel System: ViewElectrical Wiring: View Scale Model: Model Flight Simulator: Model

10 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 9 Concepts and Phenomena Phenomenon: An object in the world of a domain as you perceive it. Examples: this lecture, that wall clock Concept: An abstraction that describes phenomena with common properties. Examples: Lecture, Wall clock Concept is a 3-tuple: Name (to distinguish one concept from another) Purpose (to determine if a phenomenon belongs to a concept) Members (the set of phenomena that belong to the concept - instances )

11 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 10 Abstraction Classification of phenomena into concepts Modelling Development of abstractions to answer specific questions about a set of phenomena while ignoring irrelevant details. MembersName Clock Purpose A device that measures time. Concepts and Phenomena (contd.)

12 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 11 Concepts in software: Type and Instance Type: An abstraction in the context of programming languages Name: int, Purpose: integral number, Members: 0, -1, 1, 2, -2,... Instance: Member of a specific type The type of a variable represents all of its possible instances The following relationships ( ) are similar: type instance concept phenomenon

13 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 12 Abstract Data Types & Classes Abstract data type: Special type whose implementation is hidden from the rest of the system. Class: An abstraction in the context of object- oriented languages Like an abstract data type, a class encapsulates both state (variables) and behaviour (methods) Example Class: Watch Unlike abstract data types, classes can be defined in terms of other classes using inheritance

14 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 13 Application and Solution Domain Application Domain (Requirements Analysis): The environment in which the system is operating Solution Domain (System Design, Object Design): The available technologies to build the system

15 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 14 Object-oriented modelling Application DomainSolution Domain Application Domain Model System Model Aircraft TrafficController FlightPlan Airport MapDisplay FlightPlanDatabase SummaryDisplay TrafficControl UML Package

16 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 15 What is UML? UML (Unified modelling Language) A standard for modelling object-oriented software. Resulted from the convergence of notations from: OMT (James Rumbaugh) OOSE (Ivar Jacobson) Booch (Grady Booch) Reference: OMG (Object Management Group) Supported by several CASE tools Rational ROSE (IBM) Poseidon (ArgoUML) TogetherJ (Borland) Rhapsody (ILogix) Eclipse (IBM) …

17 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 16 UML: First Pass You can model 80% of most problems by using about 20% UML We teach you those 20%

18 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 17 UML First Pass Use case Diagrams describe a systems functional behaviour as seen by its user. Class diagrams describe a systems static structure: Classes, Associations Sequence diagrams describe a systems dynamic behaviour: actors, objects, messages Statechart diagrams describe the dynamic behaviour of individual objects of the system: states, events, transitions Activity Diagrams model a systems dynamic behaviour: activities, workflows (flowcharts)

19 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 18 UML first pass: Use case diagrams WatchUserWatchRepairPerson ReadTimeSetTime ChangeBattery Actor Use case Package Watch Use case diagrams represent the systems functionality from users point of view

20 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 19 UML first pass: Class diagrams 1 2 push() release() 1 1 blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh() LCDDisplayBattery load Time now 1 Watch Class Association Multiplicity Attribute Operations Class diagrams represent the structure of the system state PushButton

21 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 20 UML first pass: Sequence diagram :LCDDisplay blinkHours() blinkMinutes() refresh() commitNewTime() :Time incrementMinutes() stopBlinking() :Watch pressButton1() pressButton2() pressButtons1And2() pressButton1() :WatchUser Object Message Activation Sequence diagrams represent the behaviour as interactions Actor Lifeline

22 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 21 UML first pass: Statechart (diagrams) for objects with interesting dynamic behaviour Final state Transition Statecharts represent behaviour as states and transitions [button2Pressed] [button1Pressed] State Initial state Event BlinkHours BlinkMinutes IncrementHrs IncrementMin. BlinkSeconds IncrementSec. StopBlinking [button1&2Pressed] [button1Pressed] [button2Pressed] [button1&2Pressed]

23 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 22 Other UML Notations UML provide other notations Implementation diagrams Component diagrams (BD Chapter 7) Deployment diagrams (BD Chapter 7) UML includes OCL (Object constraint language) Used in Design (BD Chapter 9) And then … there is UML 2 (a major revision of UML) For a good introduction see IBM Webcast Recorded Event Feb15 Intro.itm in

24 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 23 UML Core Conventions Rectangles are classes or instances Ovals are functions or use cases Instances are denoted with underlined names Examples: myWatch:SimpleWatch, Joe:Firefighter Types are denoted with non-underlined names Examples: SimpleWatch, Firefighter Diagrams are graphs Nodes are entities Arcs are relationships between entities

25 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 24 Use Case Diagrams Used during requirements elicitation to capture a systems external behaviour An Actor represents a users role, that is, the type of a user of the system A Use case represents a sequence of interactions for a type of functionality A use case model is the set of all the use cases for a system and its environment, i.e., a complete description of all the functionalities of the system and its environment Passenger PurchaseTicket

26 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 25 Actors An actor models an external entity which communicates with the system: User External system Physical environment An actor has a unique name and an optional description. Examples: Passenger: A person using a train GPS satellite: A Provider of GPS coordinates to the system Passenger

27 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 26 Use Case A use case represents a class of functionality provided by the system as an event flow. A use case consists of: Unique name Participating actors Entry conditions Flow of events Exit conditions Special requirements PurchaseTicket

28 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 27 Use Case Diagram: Example Name: Purchase ticket Participating actor: Passenger Entry condition: Passenger standing in front of ticket distributor. Passenger has sufficient money to purchase ticket. Exit condition: Passenger has ticket. Event flow: 1. Passenger selects the number of zones to be travelled. 2. Distributor displays the amount due. 3. Passenger inserts money, of at least the amount due. 4. Distributor returns change. 5. Distributor issues ticket. Anything missing ? Exceptional cases!

29 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 28 The > Relationship > relationships represent exceptional or seldom invoked cases. The exceptional event flows are separated from the main event flow for clarity. A use case representing exceptional event flows may extend one or more use cases. The direction of a > relationship is to the extended use case Passenger PurchaseTicket TimeOut > NoChange > OutOfOrder > Cancel >

30 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 29 The > Relationship > relationship represents behaviour that is factored out of the use case. > behaviour is factored out for reuse, not because it is an exception. The direction of a > relationship is to the using use case (unlike > relationships). Passenger PurchaseSingleTicketPurchaseMultiCard NoChange > Cancel > CollectMoney >

31 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 30 Use Case Diagrams: Summary Use case diagrams represent external behavior Use case diagrams are useful as an index into the use cases Use case descriptions (flow of events) provide meat of model, not the use case diagrams. All use cases need to be described (flow of events) for the model to be useful.

32 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 31 Class Diagrams Class diagrams represent the structure of the system. Used during requirements analysis to model problem domain concepts during system design to model subsystems and interfaces during object design to model classes. Enumeration getZones() Price getPrice(Zone) TarifSchedule * * Trip zone:Zone Price: Price

33 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 32 Classes A class represent a concept A class encapsulates state (attributes) and behaviour (operations). Each attribute has a type. Each operation has a signature. The class name is the only mandatory information. zone2price getZones() getPrice() TarifSchedule Table zone2price Enumeration getZones() Price getPrice(Zone) TarifSchedule Name Attributes Operations Signature TarifSchedule

34 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 33 Instances An instance represents a phenomenon. Instance name is underlined and can show its class. The attributes are shown with their values. No operation is shown as it is the same as for its class. zone2price = { {1,.20}, {2,.40}, {3,.60}} tarif_2004:TarifSchedule

35 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 34 Actor vs Instances Difference between actor, class and instance: Actor: external to the system interacts with the system E.g., Passenger Class: models an entity in the problem domain modelled inside the system E.g., TariffSchedule Instance: A specific instance of a class E.g., tarif_2004, the specific TariffSchedule being used by the passenger for purchasing a ticket from the ticket distributor

36 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 35 Price Zone Associations Associations denote relationships between classes. The multiplicity at an association end denotes how many objects the source object can legitimately reference. Enumeration getZones() Price getPrice(Zone) TarifScheduleTripLeg * *

37 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 36 1-to-1 and 1-to-many Associations Country name:String CapitalCity name:String Has-capital Polygon draw() Point x: Integer y: Integer One-to-one association One-to-many association * Has-vertex

38 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 37 Many-to-Many Associations StockExchange Company tickerSymbol Lists ** StockExchange Company Lists 1* tickerSymbol

39 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 38 From Problem Statement To Object Model Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol Class Diagram: StockExchange Company tickerSymbol Lists **

40 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 39 From Problem Statement to Code public class StockExchange { private Vector m_Company = new Vector(); }; public class Company { public int m_tickerSymbol; private Vector m_StockExchange = new Vector(); }; Problem Statement: A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram: Java Code: StockExchange Company tickerSymbol Lists * *

41 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 40 Aggregation An aggregation is a special case of association denoting a consists of hierarchy. The aggregate is the parent class, the components are the children class. A solid diamond denotes composition, a strong form of aggregation where components cannot exist without the aggregate. TicketMachineZoneButton 3 Exhaust system Muffler diameter Tailpipe diameter Exhaust system Muffler diameter Tailpipe diameter

42 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 41 Qualifiers Qualifiers can be used to reduce the multiplicity of an association. Directory uses filename to make the association 1:1 Directory File filename Without qualification 1* With qualification DirectoryFile 0…1 1 filename

43 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 42 Inheritance The children classes inherit the attributes and operations of the parent class. Inheritance simplifies the model by eliminating redundancy. Button ZoneButtonCancelButton

44 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 43 Object modelling in Practice: Class Identification Foo Quantity CustomerId Deposit() Withdraw() GetBalance() Class Identification: Name of Class, Attributes and Methods

45 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 44 Object modelling in Practice: Encourage Brainstorming Foo CustomerId Deposit() Withdraw() GetBalance() Account CustomerId Deposit() Withdraw() GetBalance() Naming is important! Is Foo the right name? Quantity

46 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 45 Object modelling in Practice contd. Account Quantity Deposit() Withdraw() GetBalance() Customer Name CustomerId 1) Find New Objects CustomerId AccountId 2) Iterate on Names, Attributes and Methods Bank Name

47 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 46 Object modelling in Practice: A Banking System CustomerId AccountId Account Quantity Deposit() Withdraw() GetBalance() Customer Name CustomerId Bank Name 1) Find New Objects 2) Iterate on Names, Attributes and Methods 3) Find Associations between Objects Has 4) Label the associations 5) Determine the multiplicity of the associations *

48 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 47 Customer Name CustomerId Practice Object modelling: Iterate, Categorize! CustomerId() Account Amount Deposit() Withdraw() GetBalance() AccountId Bank Name Has * * Savings Account Withdraw() Checking Account Withdraw() Mortgage Account Withdraw()

49 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 48 Packages A package is a UML mechanism for organizing elements into groups (usually not an application domain concept) Packages are the basic grouping constructs with which you may organise UML models to increase their readability. A complex system can be decomposed into subsystems, where each subsystem is modelled as a package DispatcherInterface Notification IncidentManagement

50 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 49 Class Diagrams: Summary Class diagrams: system structure Class: name, attributes (types), operations (signatures) Instances: underlined names, attribute values Associations between classes, multiplicities Qualified Associations: from many:many to 1:1 Aggregation, composition Inheritance Iterate udring class identification, naming, attributes and methods, associations Packages

51 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 50 UML sequence diagrams Used during requirements analysis To refine use case descriptions to find additional objects (participating objects) Used during system design to refine subsystem interfaces Classes are represented by columns Messages are represented by arrows Activations are represented by narrow rectangles Lifelines are represented by dashed lines selectZone() pickupChange() pickUpTicket() insertCoins() Passenger TicketMachine

52 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 51 Nested messages The source of an arrow indicates the activation which sent the message An activation is as long as all nested activations Horizontal dashed arrows indicate data flow Vertical dashed lines indicate lifelines selectZone() Passenger ZoneButton TarifScheduleDisplay lookupPrice(selection) displayPrice(price) price Dataflow …to be continued...

53 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 52 Iteration & condition Iteration is denoted by a * preceding the message name Condition is denoted by boolean expression in [ ] before the message name Passenger ChangeProcessor insertChange(coin) CoinIdentifierDisplayCoinDrop displayPrice(owedAmount) lookupCoin(coin) price [owedAmount<0] returnChange(-owedAmount) Iteration Condition …to be continued... …continued from previous slide... *

54 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 53 Creation and destruction Creation is denoted by a message arrow pointing to the object. Destruction is denoted by an X mark at the end of the destruction activation. In garbage collection environments, destruction can be used to denote the end of the useful life of an object. Passenger ChangeProcessor …continued from previous slide... Ticket createTicket(selection) free() Creation Destruction print()

55 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 54 Sequence Diagram Summary UML sequence diagram represent behaviour in terms of interactions. Useful to find missing objects. Time consuming to build but worth the investment. Complements the class diagrams (which represent structure).

56 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 55 State Chart Diagrams Final state Transition Represent behaviour as states and transitions [button2Pressed] [button1Pressed] State Initial state Event BlinkHours BlinkMinutes IncrementHrs IncrementMin. BlinkSeconds IncrementSec. StopBlinking [button1&2Pressed] [button1Pressed] [button2Pressed] [button1&2Pressed]

57 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 56 Activity Diagrams An activity diagram shows flow control within a system An activity diagram is a special case of a state chart diagram in which states are activities (functions) Two types of states: Action state: Cannot be decomposed any further Happens instantaneously with respect to the level of abstraction used in the model Activity state: Can be decomposed further The activity is modelled by another activity diagram Note: UML 2 uses rounded rectangles for action and activity nodes.

58 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 57 Statechart Diagram vs. Activity Diagram Active Inactive Closed Archived Incident- Handled Incident- Documented Incident- Archived Statechart Diagram for Incident (similar to Mealy Automaton) (State: Attribute or Collection of Attributes of object of type Incident) Activity Diagram for Incident (similar to Moore) (State: Operation or Collection of Operations) Triggerless Transition Completion of activity causes state transition Event causes State transition

59 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 58 Activity Diagram: modelling Decisions

60 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University of Warwick) 59 Activity Diagrams: modelling Concurrency Synchronisation of multiple activities Splitting the flow of control into multiple threads Synchronisation Splitting Now Read BD Chapter 2


Download ppt "Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java L4 (Adapted For ISE 2005/6 By Ananda Amatya, University."

Similar presentations


Ads by Google