Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.

Similar presentations


Presentation on theme: "Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML."— Presentation transcript:

1 Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML

2 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 2 Overview  What is modeling?  What is UML?  Use case diagrams  Class diagrams  Sequence diagrams  Activity diagrams  Summary

3 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 3 Systems, Models, and Views  A model is an abstraction describing system or a subset of a system  A view depicts selected aspects of a model  A notation is a set of graphical or textual rules for representing views  Views and models of a single system may overlap each other

4 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 4 Systems, Models, and Views Airplane Flightsimulator Scale Model Blueprints Electrical Wiring

5 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 5 Models, Views, and Systems (UML) View * * depicted by described by SystemModel flightSimulator:Model scaleModel:Model blueprints:View airplane:System fuelSystem:ViewelectricalWiring:View

6 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6 Why model software? Software is already an abstraction: why model software?  Software is getting larger, not smaller  NT 5.0 ~ 40 million lines of code  A single programmer cannot manage this amount of code in its entirety.  Code is often not directly understandable by developers who did not participate in the development  We need simpler representations for complex systems  Modeling is a mean for dealing with complexity

7 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 7 Object-Oriented Modeling UML Package

8 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8 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

9 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 9 What is UML?  UML (Unified Modeling Language)  An emerging standard for modeling object-oriented software.  Resulted from the convergence of notations from three leading object- oriented methods:  OMT (James Rumbaugh)  OOSE (Ivar Jacobson)  Booch (Grady Booch)  Reference: “The Unified Modeling Language User Guide”, Addison Wesley, 1999.  Supported by several CASE tools  Rational ROSE  Gentleware Poseidon  Together/J ...  Release 2.0 is about to be accepted as the new UML specification

10 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10 UML and This Course  You can model 80% of most problems by using about 20% UML  In this course, we teach you those 20%

11 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 11 UML First Pass  Use case diagrams  Describe the functional behavior of the system as seen by the user.  Class diagrams  Describe the static structure of the system: Objects, Attributes, and Associations.  Sequence diagrams  Describe the dynamic behavior between actors and the system and between objects of the system.  Statechart diagrams  Describe the dynamic behavior of an individual object as a finite state machine.  Activity diagrams  Model the dynamic behavior of a system, in particular the workflow, i.e. a flowchart.

12 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 12 UML First Pass: Use Case Diagrams WatchUserWatchRepairPerson ReadTime SetTime ChangeBattery Actor Use case Package SimpleWatch Use case diagrams represent the functionality of the system from user’s point of view

13 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 13 UML First Pass: Class Diagrams Battery load() 1 2 Time now() PushButton state push() release() 1 1 1 1 1 2 blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh() LCDDisplay SimpleWatch Class Association Multiplicity Attributes Operations Class diagrams represent the structure of the system

14 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 14 UML First Pass: Sequence Diagram Object Message Activation Sequence diagrams represent the behavior as interactions blinkHours() blinkMinutes() incrementMinutes() refresh() commitNewTime() stopBlinking() pressButton1() pressButton2() pressButtons1And2() pressButton1() :WatchUser :Time:LCDDisplay:SimpleWatch

15 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 15 UML First Pass: Statechart Diagrams Statechart diagram for class Incident State Initial state Final state Transition Event

16 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 16 UML First Pass: Statechart Diagrams Statechart of the 2BWatch set time functions

17 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 17 Activity Diagram: Modeling Decisions

18 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 18 Activity diagrams: concurrency

19 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass Use Case diagrams

20 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 20 UML Second Pass: Use Case Diagrams Used during requirements elicitation to represent external behavior  Actors represent roles, that is, a type of user of the system  Use cases represent a sequence of interaction for a type of functionality  The use case model is the set of all use cases. It is a complete description of the functionality of the system and its environment Passenger PurchaseTicket

21 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 21 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 in the train  GPS satellite: Provides the system with GPS coordinates Passenger

22 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 22 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

23 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 23 Use Case 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 traveled. 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!

24 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 24 The > Relationship  > relationships represent exceptional or seldom invoked cases.  The exceptional event flows are factored out of the main event flow for clarity.  Use cases representing exceptional flows can extend more than one use case.  The direction of a > relationship is to the extended use case Passenger PurchaseTicketTimeOut > NoChange > OutOfOrder > Cancel >

25 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 25 Passenger PurchaseSingleTicketPurchaseMultiCardNoChange > Cancel > CollectMoney > The > Relationship  An > relationship represents behavior that is factored out of the use case.  An > represents behavior that is factored out for reuse, not because it is an exception.  The direction of a > relationship is to the using use case (unlike > relationships).

26 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 26 Other examples OpenIncident AllocateResources HelpDispatcher > OpenIncident Allocate Resources Connection Down > Authenticate WithPassword WithCard

27 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass Class diagrams

28 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 28 Class Diagrams  Class diagrams represent the structure of the system.  Class diagrams are 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) TariffSchedule * * Trip zone:Zone price:Price

29 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 29 Classes  A class represent a concept.  A class encapsulates state (attributes) and behavior (operations).  Each attribute has a type.  Each operation has a signature.  The class name is the only mandatory information zone2price getZones() getPrice() TariffSchedule Table zone2price Enumeration getZones() Price getPrice(Zone) TariffSchedule Name Attributes Operations Signature TariffSchedule

30 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 30 Attributes and operations visibility Attributes visibility  They should always be private (  information hiding)  Other classes can access an attribute value using get and set methods Operation visibility  + : public (the operation is part of the class interface)  - : private (the operation can only be accessed by the class itself)  #: protected (in abstract classes, operations that can be used by subclasses only).  This visibility constraint, in abstract classes, can also be used for attributes

31 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 31 Instances  An instance represents a phenomenon.  The name of an instance is underlined and can contain the class of the instance.  The attributes are represented with their values. zone2price = { {‘1’,.20}, {‘2’,.40}, {‘3’,.60}} tariff_1974:TarifSchedule

32 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 32 Actor vs. Instances  What is the difference between an actor and a class and an instance?  Actor:  A coherent set of roles that users of use cases play when interacting with these use cases. An actor has one role for each use case with which it communicates. (UML 1.5 definition)  An entity outside the system to be modeled, interacting with the system (“Pilot”) (text book definition)  Class:  An abstraction modeling an entity in the problem domain, inside the system to be modeled (“Cockpit”)  Object:  A specific instance of a class (“Joe, the inspector”).

33 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 33 Associations  Associations denote relationships between classes.  The multiplicity of an association end denotes how many objects the source object can legitimately reference. Enumeration getZones() Price getPrice(Zone) TarifSchedule * price zone TripLeg *

34 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 34 1-to-1 and 1-to-Many Associations 1-to-1 association 1-to-many association * draw() Polygon x:Integer y:Integer Point 1 Has-capital name:String Country name:String City 11

35 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 35 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. 1 Exhaust SystemMufflerTailpipe 0..2

36 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 36 Composition  A solid diamond denote composition, a strong form of aggregation where components cannot exist without the aggregate. 3 TicketMachine ZoneButton

37 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 37 Generalization  Generalization relationships denote inheritance between classes.  The children classes inherit the attributes and operations of the parent class.  Generalization simplifies the model by eliminating redundancy. Button ZoneButtonCancelButton

38 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 38 From Problem Statement to Code Problem Statement A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram Java Code public class StockExchange { public Vector m_Company = new Vector(); }; public class Company { public int m_tickerSymbol; public Vector m_StockExchange = new Vector(); }; * StockExchange tickerSymbol Company * lists

39 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass Sequence diagrams

40 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 40 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

41 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 41 UML Sequence Diagrams: Nested Messages  The source of an arrow indicates the activation which sent the message  An activation is as long as all nested activations selectZone() Passenger ZoneButton TarifScheduleDisplay lookupPrice(selection) displayPrice(price) price Dataflow …to be continued...

42 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 42 Sequence Diagram Observations  UML sequence diagram represent behavior in terms of interactions.  Complement the class diagrams which represent structure.  Useful to find participating objects.  Time consuming to build but worth the investment.

43 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass State diagrams

44 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 44 State Diagrams  A state is a condition that an object satisfies  A state can be thought of as an abstraction of the attribute values of a class  A state diagram can be used to describe:  The life of a class  The life of a system/subsystem referred to as a whole  The navigational paths among the different windows of an application GUI

45 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 45 State Diagram (from UML 1.5 pag. 537)

46 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 46 State internal actions/activities (from UML 1.5 pag. 538) Reserved action labels: Internal actions syntax: event-name ‘(’ comma-separated-parameter-list ‘)’ ‘[’ guard-condition‘]’ ‘/’action-expression Example: click on button X [var_y=1]/ do_something

47 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 47 Composite state Guard Condition

48 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass Activity diagrams

49 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 49 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 (also called subactivity in UML 1.5)  Can be decomposed further  The activity is modeled by another activity diagram

50 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 50 Activity diagrams key concepts  In an activity diagram:  states represent the performance of actions or subactivities  transitions are triggered by the completion of the actions or subactivities.  A subactivity state invokes an activity graph. When a subactivity state is entered, the activity graph “nested” in it is executed as any activity graph would be.  Action definition (from UML 1.5):  The specification of an executable statement that is part of a computational procedure.  An action typically results in a change in the state of the system, and can be realized by sending a message to an object or modifying a link or a value of an attribute.

51 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 51 Activity Diagram: Modeling Decisions

52 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 52 Activity Diagrams: Modeling Concurrency  Synchronization of multiple activities  Splitting the flow of control into multiple threads Synchronization Splitting Archive Incident Open Incident Document Incident Allocate Resources Coordinate Resources

53 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 53 Activity Diagrams: Swimlanes  Actions may be grouped into swimlanes to denote the object or subsystem that implements the actions. Archive Incident Dispatcher FieldOfficer Open Incident Document Incident Allocate Resources Coordinate Resources

54 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 54 Activity diagram (from UML 1.5 pag.557)

55 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 55 Activity diagram (from UML 1.5 pag.562)

56 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 56 Activity diagram (from UML 1.5 pag.562)

57 Conquering Complex and Changing Systems Object-Oriented Software Engineering UML second pass Component and Deployment diagrams

58 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 58 Other UML Notations UML provide other notations that we will be introduced in subsequent lectures, as needed.  Implementation diagrams  Component diagrams  Deployment diagrams  Object Constraint Language (OCL)  Introduced in lecture on Object Design

59 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 59 Component diagrams key concepts  A component represents a modular, deployable, and replaceable part of a system that encapsulates implementation and exposes a set of interfaces.  A component conforms to the interfaces that it exposes, where the interfaces represent services provided by elements that reside on the component.  A component may be implemented by one or more artifacts, such as binary, executable, or script files.  A component may be deployed on a node.

60 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 60 Component diagrams Component Interface Components typically expose a set of interfaces, which represent the services provided by the elements that reside on the component.

61 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 61 Component and Deployment diagrams key concepts  A node is a physical object that represents a processing resource, generally, having at least a memory and often processing capability as well.  Nodes include computing devices but also human resources or mechanical processing resources.  Run time computational instances, both objects and component instances, may reside on node instances.

62 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 62 Deployment Diagrams

63 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 63 UML Core Conventions  Rectangles are classes or instances  Ovals are functions or use cases  Instances are denoted with an underlined names  myWatch:SimpleWatch  Joe:Firefighter  Types are denoted with nonunderlined names  SimpleWatch  Firefighter  Diagrams are graphs  Nodes are entities  Arcs are relationships between entities

64 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 64 Summary  UML provides a wide variety of notations for representing many aspects of software development  Powerful, but complex language  Can be misused to generate unreadable models  Can be misunderstood when using too many exotic features  We concentrate only on a few notations:  Functional model: use case diagram  Object model: class diagram  Dynamic model: sequence diagrams, statechart and activity diagrams


Download ppt "Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML."

Similar presentations


Ads by Google