Presentation on theme: "249 Conceptual Design: UML Sequence Diagrams. 250 Object Responsibilities n Attributes - What I know about myself n Relationships - What I know about."— Presentation transcript:
249 Conceptual Design: UML Sequence Diagrams
250 Object Responsibilities n Attributes - What I know about myself n Relationships - What I know about other Classes and Objects n Operations - What I do
251 Operations n Synonyms: methods, functions & services n Definition: Actions performed to fulfill the purpose of the information system and meet the needs of the user. n Respond to an event that happens: n External events - business activities n Internal events - messages sent to accomplish an operations intended purpose
252 Types of Operations n Basic - implied or implicit (not listed) n create a new object n search for an object n get and set attribute values n connect and disconnect object associations n delete an object n Problem domain – specific to the domain being studied
253 Template ClassName operations attributes ClassName 1) basic operations 2) problem domain specific operations - inherited - local attributes - inherited - local you think.... Thinking…
254 Problem Domain Operations Example Student registerForCourse dropCourse requestTranscript payStudentFees etc... studentIDNumber studentName etc... next....Basic Services Examples...
255 NEW Operation Example Student attributes operations Student 1 Student 2 Student 3 Student attributes operations Student 1 Student 2 Student 3 Student 4 new Student before after Note: All basic operation examples are for illustration only as each implementation language handles them differently
259 SET Operation Example Student attributes operations Student 1 Student 2 Student 3 set[Student, telephone,(619) ] telephone: (619) Student attributes operations Student 1 Student 2 Student 3 telephone: (619) before after
260 CONNECT Operation Example StudentClub attributes operations ACM Club Beta Sigma Pi Club AITP Club connect[StudentClub=AITP Club, ClubMember=AITP-Student N] ClubMember attributes operations ACM-Student 1 ACM-Student N BSP-Student 1 BSP-Student N AITP-Student 1 AITP-Student N
261 DISCONNECT Operation Example StudentClub attributes operations ACM Club Beta Sigma Pi Club AITP Club disconnect[StudentClub=AITP Club, ClubMember=AITP-Student N] ClubMember attributes operations ACM-Student 1 ACM-Student N BSP-Student 1 BSP-Student N AITP-Student 1 AITP-Student N
262 DELETE Operation Example Student attributes operations Student 1 Student 2 Student 3 Student attributes operations Student 1 Student 3 delete[Student 2] before after
263 Problem Domain Operations n Come in all sizes and shapes n May be unique to the problem domain n Consider encapsulation and reuse when designing n Some respond to external events... n Others respond to internal events n Details of each operation are documented via UML diagrams and other techniques
265 Problem Domain Operation Example #2 Automobile rentalCharge salesTaxOwed salesTaxOwed[VIN = 12345, taxRate, totalTax] VIN: $ salesTaxOwed totalTax = rentalCharge X taxRate (sample): $21.62 = X.0775
266 Problem Domain Operation Example #3 Report vehiclesOverdueReport message sent to Automobiles checkReturnDate operation Automobile scheduledReturnDate checkReturnDate checkReturnDate[listOfVehicles] checkReturnDate For each Automobile If scheduledReturnDate less than Today send vehicle information message to overdueVehicleReport Endif End For Each (sample): VIN: scheduledReturnDate: 05/05/95 Todays Date: 04/30/95 overdue: No VIN: scheduledReturnDate: 04/28/95 Todays Date: 04/30/95 overdue: Yes (will be on report) etc....
267 Encapsulation and Reuse Operation Example Student addCourse NOTE: The addCourse service requests the assistance of each of the other services (which are either part of the Student Class or some other Class within the information system) in order to carry out its intended purpose. SomeOtherClass(es) enterStudentIDNumber validateIDNumber enterClassScheduleNumber validateClassScheduleNumber checkSeatAvailability checkStudentRestrictions reserveSeatInClass addCourse responds to external event; others respond to internal event
268 Finding Operations n Identifying events and associated operations n Identify Class states - attribute values n Identify needed messages n Specifying details of known operations
269 Describing Operation Details n UML Sequence Diagram n UML Collaboration Diagram n UML State Diagram n UML Activity Diagram n Structured English or Pseudocode n Decision Tables and Decision Trees
270 UML Sequence Diagram n Is an interaction diagram that emphasizes the time ordering of messages n Also referred to as a Scenario - how a use case is realized (enacted) n Graphically, it is a 2-dimensional table that shows objects arranged along the X-axis and messages, ordered in increasing time, along the Y-axis. Object1Object2ObjectN Message1() Message2() Message3() Message4()
272 Classes from the UML Sequence Diagram OrderEntryWindow Order OrderLineItem StockItem ReorderItem DeliveryItem Boundary Class Problem Domain Classes new() etc… prepare() etc… prepare() etc… check() remove() needToReorder() etc… new() etc… new() etc…
273 UML Collaboration Diagram n Is an interaction diagram that emphasizes the structural organization of the objects that send and receive messages n Graphically, it is a collection of vertices and arcs n First, place objects as vertices; second, render the links that connect the objects as arcs; third, adorn the links with the numbered messages that objects send and receive n Optionally, can contain a path ( >, >, etc.) Object1 Object2ObjectN 1: Message() 2: Message() 3: Message() 4: Message()
274 UML Collaboration Diagram Create one of these and the other is Automatically created Collaboration Diagram
275 UML State Diagram UML State Diagram Template State 1 State 2 State 3 State n condition action (note: each arrow should be labeled condition - action)
276 UML State Diagram Example #1 A telephone answering machine example (incomplete) Idle Recording Outgoing Message Answering a Call Recording Incoming Message Rewinding Tape Playing Messages Record Button Pushed Phone Rings Caller Speaks End of message Play Messages Button Pushed
277 UML State Diagram Example #2 FlightLeg Seat AvailableLockedSold lock timed out unlock sold
278 UML Activity Diagram n Shows the flow from one activity to another. Activities result in actions n Can be attached to classes, interfaces, component nodes, use cases, collaborations, and operations n Is similar to a Data Flow Diagram (DFD) n Used mainly when behavior is complex n Approximates a visual programming language for the UML
UML Activity Diagram Example pick show schedule show publicize show sell tickets buy scripts and music hire artists build sets design lighting make costumes (fork) (activity) rehearse dress rehearsal perform (completion transition) (join) Adapted from: Rumbaugh, J, Jacobson, I. and Booch, G., The Unified Modeling Language Reference Guide, Addison-Wesley, 1999, p. 32
280 For each Automobile If scheduledReturnDate less than Today send vehicle information message to overdueVehicleReport Endif End For Each Structured English Example Automobile checkReturnDate checkReturnDate operation Structured English scheduledReturnDate Note: Structured English is often referred to as Pseudocode
282 Decision Table Example #1 Rules Conditions Actions Percent >=90% 89% >= Percent >= 80% 79% >= Percent >= 70% 69% >= Percent >= 60% 59% >= Percent Grade = A Grade = B Grade = C Grade = D Grade = F YXYX YXYX YXYX YXYX YXYX Do the conditions cover all possible cases?
283 Decision Table Example #2 Rules Conditions Actions Registration Fee = 0? Payment Type Credit Card # Input? C.C. Expire Date Input? C.C. Cardholder Name Input? Bank Check Number Input? Remarks by User Input? Activate POST Button Deactivate POST Button ……... Y-----YXY-----YX N Cash - X N Check - Y - X N CrCd Y - X X……..
284 Decision Trees Decision Tree template condition 1 rule 1 rule 2 rule n condition 2 rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n condition n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n rule 1 rule 2 rule n action(s)
285 Decision Tree Example Percent >= 90%? YesGrade = A No 89% >= Percent >= 80%? YesGrade = B No 79% >= Percent >= 70%? Yes Grade = C No Etc... Do the conditions cover all possible cases?
286 When to use O-O Analysis, Design, & Programming? Graphical User Interfaces (GUI) Event-Driven Programming Heterogeneous Environments Distributed Environments More sophisticated applications Persistent Data requires: Audio Video Graphics Other non-row/column data Higher utilization of REUSE practice Etc...
287 Alternative O-O A, D, & P Strategies ANALYSIS DESIGN PROGRAMMING Structured Object Structured Object Structured Object Conventional 3-4GL Mixture - Conv/Obj. Object There are all kinds of variations on these or other strategies ODBMS, Relational, and Extended-Relational DBMS are options
288 Simula - late 1960s Smalltalk since 1970s; Xerox Star in 1981 Eiffel - Bertrand Meyer Delphi (Borland.Com or Inprise) Java (Sun) & Visual J Languages C++ (Borland, Microsoft) Objective C Ada Object Pascal Object COBOL Visual FoxPro Powerbuilder Visual Basic etc... OO PROGRAMMING: ROCK SOLID! Pure Enhanced Pure OOP versus enhanced deterministic languages