Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Object Oriented Analysis and Design with UML UNIT 3.

Similar presentations


Presentation on theme: "1 Object Oriented Analysis and Design with UML UNIT 3."— Presentation transcript:

1 1 Object Oriented Analysis and Design with UML UNIT 3

2 2 Summary Unit 2... 4 UML Overview –Model systems using OO concepts Information systems, technical systems, system software, real time, distributed system,… –UML is a modeling language –Based on the notion of views Use case, logical, component, concurrency, deployment view

3 3 Summary Unit 2... –UML Diagrams –Extensibility of the UML Stereotypes, tagged values, constraints 4 Use-Case diagram 4 Class diagram 4 Object diagram 4 State diagram 4 Sequence diagram 4 Collaboration diagram 4 Activity diagram 4 Component diagram 4 Deployment diagram

4 4 Summary Unit 2... 4 Static Modeling with UML –Use Case Diagrams to capture the functional requirements of a system informally stated in natural language focus on what the system is supposed to do –Class Diagrams A view of the system in terms of classes and relationships Behaviour as well as information in the system is modeled –This static model of the system is built in a dynamic way !!

5 5 Use-Case Diagram CustomerOperator Return Item Print Daily Report Change Item Data

6 6 Steps for Building a Use Case Model 4 Define the boundaries of the system 4 Find the actors and use cases 4 Define the relationships between the use cases 4 Validate and verify the model –Highly interactive with the end users ! –Should include discussions Be Creative !

7 7 Class Diagram

8 8 Relationships Between Classes 4 An association is a connection between classes 4 A generalization is a relationship between a more general and a more specific element 4 A dependency is a relationship between elements, one independent another dependent 4 A refinement is a relationship between two descriptions of the same thing but at different levels of abstraction

9 9 Object Diagram

10 10 The Unified Modelling Language (continued) UNIT 3

11 11 Unit 3 : Outline 4 Dynamic Modelling –State Diagrams –Sequence Diagrams –Collaboration Diagrams –Activity Diagrams

12 12 Dynamic Modeling... 4 Describes what happens at run-time –Objects vs Classes 4 How do elements of static diagrams : –Cooperate to manage their tasks –Communicate with each other –Change their state –Provide the functionality of the system 4 Method outline and messages flow 4 For capturing difficult to understand aspects Complements Static Diagrams

13 13 Dynamic Modeling. 4 Focus on communicating one aspect of a system’s dynamics 4 Model only those elements that are essential 4 Provide detail consistent with the level of abstraction 4 Sometimes a piece of code says more than lines, rectangles,...

14 14 Different Dynamic Diagrams 4 Sequence Diagrams –Focus on time aspect of interaction and communication 4 Collaboration Diagrams –Focus on space aspect of interaction and communication 4 State Diagrams –Focus on state, behaviour and events 4 Activity Diagrams –Focus on work aspect of interaction and communication Inter-object relation Intra-object relation

15 15 Unit 3 : Outline 4 Dynamic Modelling –State Diagrams –Sequence Diagrams –Collaboration Diagrams –Activity Diagrams

16 16 State Diagram Symbols

17 17 Focus on 4 The possible states of the instances of a class 4 The possible transitions from one state to another one 4 The events firing transitions 4 The operations which are executed within states or during a transition Intra-object relation

18 18 Purpose of State diagrams 4 To document classes that have : –Clearly identifiable states State = {ongoing_behaviour, attributes,...} –Complex behaviour –Many events (signals)

19 19 Notation State Diagrams. State State Transition Initial State Final State

20 20 Parts of a State Diagram Name State Variables Activities State Box State Transition Initial StateFinal State

21 21 Example State Diagram State Diagram for the Elevator Class On first floor Moving up Idle Moving down Moving to first floor go up(floor) Arrive at floor Arrive at first floor go up(floor) go down(floor) time-out

22 22 Parts of a State Box Login Login time = Current time Entry/type “login” Exit/login (user name, password) Do/get user name Do/get password Help/display Help State Name State Variables Activity Actions Atomic Can be further decomposed

23 23 Login Login time = Current time Entry/type “login” Exit/login (user name, password) Do/get user name Do/get password Help/display Help Activities Part of a State Box... 4 Describes the actions undertaken when the object is in a particular state 4 These actions are guided by events Event-name argument-list ‘/’ action-expression

24 24 Activities Part of a State Box. 4 Standard events : Entry / Action Exit / Action Do / Activity event / Action Action is executed when entering the state Action is executed when leaving the state Activity is executed, parameters are allowed Event is handled within the state

25 25 State Transition Events… 4 Four kinds of events in UML : Change Event A condition becoming true shown as a guard condition on a state transition Receipt of a message shown as an event signature on state transitions Call Event

26 26 State Transition Events… Time Event A relative or absolute point in time shown as a time expression on state transition Signal Event Signal Event : The receipt of a signal > out_of_memory keyPressed, …

27 27 State Transition Events… Messages vs Events modeButton() Display do/display current time Set hours do/display hours Set minutes do/display minutes modeButton() inc/minutes := minutes +1inc/hours := hours +1 DigitalWatch modeButton() inc()

28 28 State Transition Labels (all optional) event-signature '[' guard-condition ']' '/' action-expression '^' send-clause event-signature = event-name '(' parameter ',',... ')' 4 Examples : –draw(f : Figure, c : Color) –redraw –redraw() –print(invoice)

29 29 State Transition Labels… event-signature '[' guard-condition ']' '/' action-expression '^' send-clause Guard-condition = A boolean expression placed on a state transition 4 Examples : –[t = 15sec] –[number of invoices > n] –[withdrawal (amount) && balance >= amount ] 4 Guards are mutual exclusive

30 30 State Transition Labels… event-signature '[' guard-condition ']' '/' action-expression '^' send-clause Action-expression = Is executed when the transition fires 4 Examples : –increase () / n := n + 1 –add (n) / sum := sum + n No nesting or recursion allowed

31 31 State Transition Labels. event-signature '[' guard-condition ']' '/' action-expression '^' send-clause Send-clause = Explicit syntax for sending a message during a transition between two states 4 Examples : –^ pen.set(color) –[timer = Time-out] ^ self.go down (first floor)

32 32 Example : Digital Watch modeButton() Display do/display current time Set hours do/display hours Set minutes do/display minutes modeButton() inc/minutes := minutes +1 modulo 60 inc/hours := hours +1 modulo 24

33 33 Communication between Diagrams OffOn OffOn/StopOn/Play On() Off() On() Stop() Play() On()Off()Stop() Play() Off()/Stop() Stop() Play() CD Player Remote Control

34 34 Substates… AND-STATES States that may be true at the same time ForwardBackward Running Low speedHigh speed

35 35 Substates. OR-STATES States that may not be true at the same time ForwardBackward Running

36 36 Unit 3 : Outline 4 Dynamic Modelling –State Diagrams –Sequence Diagrams –Collaboration Diagrams –Activity Diagrams

37 37 Sequence diagram Symbols Object 1Object 2Object 3

38 38 Focus on 4 The interaction and communication between objects 4 Specify the realization of an operation or use case 4 Message sequences 4 Time aspect 4 Cfr Collaboration diagram

39 39 Two Available Forms 4 Generic form –documents all possible alternatives in a scenario –conditions, loops, branches are possible –cfr class diagram 4 Instance form –documents one possible interaction –no conditions, loops, or branches –cfr object diagram :Computer C1:Computer or C1

40 40 Different Message Types 4 Only means of communication with objects are messages Synchronous Asynchronous Simple Synchronous with Immediate return

41 41 Notation Sequence Diagrams… :Computer:PrintServer:Printer Print(ps-file) [no queue] Print(ps-file)

42 42 Notation Sequence Diagrams. :Computer Print(ps-file) [no queue] Print(ps-file) Object Message send Lifeline Activation Return Guard condition

43 43 Labels for Iteration C1:CD1:DD2:D message1() message2()send message2 until … message3()

44 44 Labels for Constraints :Computer:PrintServer:Printer Print(ps-file) a b b’ {b’ – b < 1 sec} {b - a < 5 sec} If PrinterServer receives a file, it should transmit this file to the Printer within 5 sec Communicating the file from the PrinterServer to the Printer should take less than 1 sec

45 45 Object creation :CustomerWindow :Customer NewCustomer(Data) Customer(Data)

46 46 Object Destruction :CustomerWindow :Customer RemoveCustomer( ) DeleteCustomer( )

47 47 Unit 3 : Outline 4 Dynamic Modelling –State Diagrams –Sequence Diagrams –Collaboration Diagrams –Activity Diagrams

48 48 Collaboration Diagram Symbols

49 49 Focus on 4 The interaction and communication between objects 4 Shows the static and dynamic relationships between objects – the context aspect 4 Space aspect (time is no dimension on its own) 4 Sequence indicated with numbers

50 50 Example Collaboration Diagram :PrinterServer [printer free] 1.1:Print(ps-file) :Printer :Computer Print(ps-file) 1:Print(ps-file)

51 51 Message Flow Labels… predecessor guard-condition sequence-expression return-value predecessor = sequence-number ‘,’ … ‘/’ 4 Indicates the assumed message flow before this message may happen 4 Examples : –1,2,5 / –3 / 4 Only specify if not implicitly available !

52 52 Message Flow Labels… guard-condition = ‘[‘ condition-clause ‘]’ predecessor guard-condition sequence-expression return-value 4 Examples : –1,2,5 / [t = 15sec] –[number of invoices > n] –[withdrawal (amount) && balance >= amount]

53 53 Message Flow Labels. predecessor guard-condition sequence-expression return-value sequence-expression = [integer | name][recurrence] ‘:’ recurrence = ‘*’ ‘[‘ iteration-clause ‘]’ recurrence = ‘[‘ condition-clause ‘]’ 4 Indicates that a message is a part of the actions undertaken in response to another message (referred to with the predecessor number) 4 Examples : –1.1 *[x = 1..10]: doSomething() –1 [time-out]: display()

54 54 Role Names 4 Role Names indicate how the objects know about each other {Global} {Local} {Parameter} {Self} The object is known throughout the entire system The object is known locally (temporary object) The object is known since it was passed as an argument The object is referencing itself {Association} The object is known as an attribute (default)

55 55 Constraints 4 Constraints indicate the objects’ existence during interaction {New} {Destroyed} {Transient} The object is created during the interaction The object is destroyed during the interaction The object will be created and destroyed Nothing specified The object was available before the interaction took place

56 56 Example : Role names & Constraints

57 57 Unit 3 : Outline 4 Dynamic Modelling –State Diagrams –Sequence Diagrams –Collaboration Diagrams –Activity Diagrams

58 58 Activity Diagram Symbols

59 59 Focus on 4 Actions and their results 4 How and when actions are taken 4 What actions actually do 4 Where actions take place (swimlanes) 4 Work aspect 4 Flowcharts featuring parallelism

60 60 Purpose of Activity Diagrams 4 To document : –The actions performed by an operation –The internal working of an object –Make parallelism explicit –A use case How is it performed in terms of actions and states? –Workflow

61 61 Notation Activity Diagrams. Action/Activity Object Flow Start StateEnd State Control Flow ConcurrencyDecision State

62 62 Example Activity Diagram Action/Activity Decision Initial event Control Flow (Same label notation as transitions State Diagram) Show MessageBox “Disk full” on screen Show MessageBox “Printing” on screen Remove MessageBox Create Postscript file [disk full] [free disk space] ^Printer.print(file) printFile()

63 63 Control Flow 4 Indicates the order of actions and activities 4 Represented by transition arrows 4 No events on arrow : –As soon as the execution of the predecessor is finished, the successor is started 4 Guard conditions are allowed

64 64 Decision State / Concurrency 4 Decision State –Makes alternative sequences explicit –Complex decisions can be visualized by decision trees –Outgoing transitions must have mutually exclusive guards 4 Concurrency –Fork/Join denotes starting/ending point of concurrent execution –Combined with guard conditions it forms an alternative to the decision state

65 65 Swimlanes Objects that are responsible can be assigned to actions and activities Initiate Measuring Updating Displayer Sampler.Run(channel, frequency) DisplayerSampler

66 66 Course Overview. 4 UML Diagrams 4 Use-Case diagram 4 Class diagram 4 Object diagram 4 State diagram 4 Sequence diagram 4 Collaboration diagram 4 Activity diagram 4 Component diagram 4 Deployment diagram Last Unit


Download ppt "1 Object Oriented Analysis and Design with UML UNIT 3."

Similar presentations


Ads by Google