OOAD with UML (Interaction Diagramming)

3,284 views

Published on

Presentation on how to relate use cases to (UML) interaction diagrams, and using aggregation/composition relationships.

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,284
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

OOAD with UML (Interaction Diagramming)

  1. 1. OOAD with the UML: Analyzing the System <ul><li>Dynamic Modeling </li></ul><ul><li>Aggregation relationships </li></ul><ul><li>Composition relationships </li></ul>
  2. 2. Introduction <ul><li>The purpose of the presentation is to explain how to analyze the system using object interaction diagramming and depicting relationships between objects and classes </li></ul><ul><li>My name is Jerry Myong </li></ul>
  3. 3. The origin of UML (now 2.0)
  4. 4. UML: Best of the “3 Amigos” <ul><li>OMT (Rumbaugh) was really strong in Analysis, but weaker in design </li></ul><ul><li>Booch Methodology was stronger in design, weaker in analysis </li></ul><ul><li>Jacobson’s Objectory was good with user-experience (ala use-cases) </li></ul><ul><li>The “method war” finally ended when UML came into being </li></ul>
  5. 5. Topics of Discussion <ul><li>Object Interaction Diagramming </li></ul><ul><li>Depicting associations </li></ul><ul><li>Modeling aggregation/composition </li></ul><ul><li>Adding multiplicity to relationships </li></ul>
  6. 6. Sequence Diagramming <ul><li>For analysts or designers who want to model dynamic object behavior </li></ul><ul><li>How to build a sequence diagram </li></ul><ul><ul><li>Define the components </li></ul></ul><ul><ul><li>Relate the objects using messages </li></ul></ul>
  7. 7. Sequence Diagramming <ul><ul><li>The constructs </li></ul></ul><ul><ul><ul><li>Actors </li></ul></ul></ul><ul><ul><ul><li>Objects </li></ul></ul></ul><ul><ul><ul><ul><li>Boundary </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Control </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Entity </li></ul></ul></ul></ul><ul><ul><ul><li>Messages </li></ul></ul></ul><ul><ul><ul><ul><li>Simple (open-arrowhead; object-to-object, self) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Synchronous (solid-arrowhead; client/supplier in same thread) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Asynchronous (half-arrowhead; client/supplier have separate threads) </li></ul></ul></ul></ul><ul><ul><ul><li>X-axis (Actors, Objects) </li></ul></ul></ul><ul><ul><ul><li>Y-axis (Timeline) </li></ul></ul></ul>
  8. 8. Sequence Diagramming <ul><li>Use a consistent naming convention </li></ul><ul><ul><li>Underline the Objectname or Objectname:Class </li></ul></ul><ul><ul><li>Use the “stick-man” figure for an actor and rectangle for objects </li></ul></ul><ul><ul><ul><li>I prefer to use the “stick-man” for a user, application or system </li></ul></ul></ul><ul><ul><ul><li>I prefer to use the rectangle (object) for the objects created in the proposed system </li></ul></ul></ul>
  9. 9. Sequence Diagramming <ul><ul><li>Objects are related by passing or receiving messages </li></ul></ul><ul><ul><li>In analysis, the level of abstraction can be just a high-level message </li></ul></ul><ul><ul><ul><li>The message may be conceptual or a proposed method name </li></ul></ul></ul><ul><ul><li>In design, the details of the message will usu. be available </li></ul></ul><ul><ul><ul><li>So the actual method name with parameters may be used </li></ul></ul></ul>
  10. 10. Sequence Diagramming <ul><li>Analyze the use-case scenario </li></ul><ul><ul><li>Identify the candidate objects </li></ul></ul><ul><ul><ul><li>Realize the objects from the candidate list </li></ul></ul></ul><ul><ul><ul><li>Analyze the grammar of the scenario and identify the verbs </li></ul></ul></ul><ul><ul><ul><li>Construct the messages from the verbs </li></ul></ul></ul><ul><ul><ul><ul><li>Choose level of abstraction </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>If high-level, then conceptual messages </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>If detailed-level, then actual messages with parameters, return values, etc. </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Level of detail is discretionary </li></ul></ul></ul></ul></ul>
  11. 11. Sequence Diagramming <ul><li>Identify the most active objects and place them to the left </li></ul><ul><li>Numbering of each object-message call is not necessary, since the top-down sequencing implies order </li></ul><ul><li>In collaboration diagrams, numbering is necessary </li></ul><ul><li>The diagram will be easier to understand if messaging is to neighboring objects </li></ul><ul><ul><li>Objects with less messaging can be moved to the right-side </li></ul></ul><ul><ul><li>Btw, this is an advantage of using the collaboration diagram </li></ul></ul>
  12. 12. Sequence Diagramming <ul><li>Analyze the sequence diagram and determine if the messaging is balanced across the objects </li></ul><ul><li>Identify the objects that have too much responsibility </li></ul><ul><ul><li>Determine the need to shift responsibility to existing objects or create new objects </li></ul></ul><ul><ul><li>Use timeline axis to identify the relative time an object needs to perform all responsibilities (focus of control) </li></ul></ul><ul><ul><ul><li>Too much time for one object could indicate the need to redistribute some responsibility (to existing or new objects) </li></ul></ul></ul>
  13. 13. Sequence Diagramming – Administer New Employee Actor Lifeline Messages Focus of Control Self-call
  14. 14. Sequence Diagramming – Report CD Sales Driver Create “CDSalesReport” “ Setter” methods
  15. 15. Sequence Diagramming – Model Generate Form (1098) <ul><li>Use case starts when Loan Specialist receives a Lotus notes for a duplicate MIS from a CSR </li></ul><ul><li>User Launches the MIS application </li></ul><ul><li>User enters the loan number in the loan selection screen </li></ul><ul><li>System generates the 1098 form and display it to user. The form contains following information: </li></ul><ul><ul><li>Statement Year </li></ul></ul><ul><ul><li>Lender’s name and address </li></ul></ul><ul><ul><li>Borrower’s name and address </li></ul></ul><ul><ul><li>Points paid last year </li></ul></ul><ul><ul><li>Interest paid last year </li></ul></ul><ul><li>User verifies Borrower’s name and address(A1) </li></ul><ul><li>User clicks the Print button </li></ul><ul><li>System prints the 1098 form </li></ul><ul><li>User sends the printed from to the mailing department to be mailed out to the borrower </li></ul><ul><li>Use case ends </li></ul>Requirements (Use case – Main Flow)
  16. 16. Sequence Diagram – Model Generate Form (1098)
  17. 17. Collaboration Diagramming – Different View of Sequence Diagram <ul><li>Focus on the relationships between objects </li></ul><ul><li>Very useful for visualizing how several objects interact with each other to get a job done </li></ul><ul><li>Useful for comparing against a class diagram </li></ul><ul><li>Interplay between the static and dynamic models </li></ul><ul><li>A different view of the same information </li></ul><ul><ul><li>Notation differences </li></ul></ul><ul><ul><ul><li>Link w/o arrowhead is a bi-directional </li></ul></ul></ul><ul><ul><ul><li>Link w/ arrowhead = unidirectional </li></ul></ul></ul><ul><ul><ul><li>Self-calls are displayed as “loops” </li></ul></ul></ul><ul><ul><ul><li>Messages are shown as labels next to the relationship lines </li></ul></ul></ul><ul><ul><ul><li>Nested messages follow a “decimal” numbering convention (similar to outline numbering) </li></ul></ul></ul><ul><ul><ul><li>Conditions are in square brackets right before the message </li></ul></ul></ul><ul><ul><ul><li>Stack objects (multiple-objects) </li></ul></ul></ul><ul><ul><ul><li>Follow object name with {new}, {destroyed}, {transient-both} </li></ul></ul></ul>
  18. 18. Collaboration Diagramming – Identify the objects from use-case Make a phone call <ul><ul><li>Should number the sequence of steps since objects are in a spatial display </li></ul></ul><ul><ul><li>Let’s analyze the use-case, identify our objects and their relationships </li></ul></ul><ul><ul><ul><li>Button, Dialer, Speaker, Display, Send:Button, CellularRadio </li></ul></ul></ul>
  19. 19. Collaboration Diagramming – Identify the object messaging * - Loop for digits
  20. 20. <ul><li>Lines connecting objects are “links” </li></ul><ul><li>A “link” represents an instance of an association (aggregation, composition, etc.) </li></ul><ul><ul><ul><li>Must have a corresponding assoc. on a class diagram </li></ul></ul></ul><ul><li>Each object has its own intelligence and is not highly coupled with the other objects </li></ul><ul><li>Try to avoid designing a “god” object </li></ul><ul><ul><li>Not trying to be “theological” </li></ul></ul><ul><ul><li>It knows about all others; and all the others know about it </li></ul></ul><ul><ul><li>Too highly interconnected to other objects, causing a “ripple effect” to other objects, when it changes </li></ul></ul>Collaboration Diagram – Different Angle of Sequence Diagram
  21. 21. Collaboration Diagramming: Model Generate Form (1098) <ul><li>Use case starts when Loan Specialist receives a Lotus notes for a duplicate MIS from a CSR </li></ul><ul><li>User Launches the MIS application </li></ul><ul><li>User enters the loan number in the loan selection screen </li></ul><ul><li>System generates the 1098 form and display it to user. The form contains following information: </li></ul><ul><ul><li>Statement Year </li></ul></ul><ul><ul><li>Lender’s name and address </li></ul></ul><ul><ul><li>Borrower’s name and address </li></ul></ul><ul><ul><li>Points paid last year </li></ul></ul><ul><ul><li>Interest paid last year </li></ul></ul><ul><li>User verifies Borrower’s name and address(A1) </li></ul><ul><li>User clicks the Print button </li></ul><ul><li>System prints the 1098 form </li></ul><ul><li>User sends the printed from to the mailing department to be mailed out to the borrower </li></ul><ul><li>Use case ends </li></ul>Requirements (Use case – Main Flow)
  22. 22. Collaboration Diagram – Model Generate Form (1098)
  23. 23. Depicting associations <ul><li>Types of associations </li></ul><ul><ul><li>Simple </li></ul></ul><ul><ul><li>Aggregation/Composition </li></ul></ul><ul><li>Associations shows that a collaboration exists between two classes of objects </li></ul><ul><ul><ul><li>PayrollManager needs info from SalariedEmployee and sends employee info to Paycheck </li></ul></ul></ul>Bi-directional
  24. 24. Depicting associations <ul><li>Bi-directional (solid line) </li></ul><ul><ul><li>Both classes “know about” each other </li></ul></ul><ul><li>Unidirectional (line w/ arrow pointing to the class that needs to be known </li></ul><ul><li>Naming a relationship (optional) </li></ul><ul><ul><li>Active verb or verb phrase describing the relationship </li></ul></ul><ul><li>Multiple relationships can exist between a pair of classes </li></ul><ul><ul><ul><li>Separate semantic relationships? </li></ul></ul></ul><ul><ul><ul><li>Individualized behavior of the same relationship? </li></ul></ul></ul>
  25. 25. <ul><li>Each association has two roles </li></ul><ul><ul><li>Each role describes how one class relates to the other </li></ul></ul><ul><ul><li>A role can be labeled (on the association line next to the class) instead of an assoc. name </li></ul></ul><ul><ul><li>Identify associations by analyzing the sequence or collaboration diagram messages </li></ul></ul><ul><ul><ul><li>Does the message require an object or return an object? </li></ul></ul></ul><ul><ul><ul><li>If the object is primitive (e.g., String, Integer) then the association usually is not shown </li></ul></ul></ul>Depicting associations
  26. 26. <ul><li>Dependency relationship exists when the client does not know the intrinsic location of the supplier </li></ul><ul><ul><li>E.g., the client calls a supplier1 that needs to call another supplier2 to fulfill the client’s request </li></ul></ul><ul><ul><ul><li>The client does not have a direct association with supplier2; not knowing its location (reference) </li></ul></ul></ul><ul><li>Aggregate relationships are a “whole-part” relationship a.k.a. a “part of” relationship </li></ul><ul><ul><li>An “aggregate” object is essentially an extended object that is treated as a unit in many operations </li></ul></ul><ul><ul><ul><li>The “aggregate” object is composed of lesser objects (e.g., Car <>= {Engine,Transmission,Suspension,Frame}) </li></ul></ul></ul>Depicting associations
  27. 27. Depicting Associations – A couple of Aggregation Examples Aggregate “ Part-of” extension One-way relationship
  28. 28. <ul><li>Two types of aggregates (“has a” relationship) </li></ul><ul><ul><li>Shared </li></ul></ul><ul><ul><ul><li>Can be parts of other aggregates too </li></ul></ul></ul><ul><ul><ul><li>Destroying an aggregate does not necessarily destroy the parts </li></ul></ul></ul><ul><ul><ul><ul><li>Don’t delete the shared aggregate objects, if they can exist on their own (without the aggregate object) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>“delete” maps to the command to release an object from memory </li></ul></ul></ul></ul><ul><ul><li>Composition </li></ul></ul><ul><ul><ul><li>Aggregate is “composed of” the parts (having strong ownership of its parts) </li></ul></ul></ul><ul><ul><ul><ul><li>Destroying the aggregate, destroys the “composed of” parts </li></ul></ul></ul></ul><ul><ul><ul><ul><li>The “composed of” parts are not part of other aggregates </li></ul></ul></ul></ul>Depicting Associations – Aggregate Types
  29. 29. Depicting Associations – Composition example Composite Solid diamond “ Composed of” parts, specifically created for DialogBox
  30. 30. Depicting Multiplicities in Associations <ul><li>The number of objects that can participate in a relationship </li></ul><ul><ul><li>Used in class diagrams </li></ul></ul><ul><ul><ul><li>Multiplicity indicators (single, range, disconnected, *) </li></ul></ul></ul><ul><ul><ul><li>Multiplicities (1-to-1, 1-to-many, many-to-many) </li></ul></ul></ul><ul><ul><ul><li>2 indicators per relationship </li></ul></ul></ul>0 to 4 courses Only 1 Professor teaches
  31. 31. <ul><li>When no multiplicity is depicted, it defaults to one </li></ul><ul><li>Underestimating multiplicity can restrict the application </li></ul><ul><ul><li>Not enough objects will be created </li></ul></ul><ul><li>Overestimating multiplicity causes more overhead </li></ul><ul><ul><li>Managing more objects becomes more complex </li></ul></ul><ul><li>Multiplicity decisions are made during analysis and design as well </li></ul><ul><ul><li>The question of multiplicity is as integral in associations as it is in database design – it is a business rule too </li></ul></ul>Depicting Multiplicities in Associations
  32. 32. Depicting Multiplicities in Associations – Example [0 to 1] InteractionUse to [many] Actions
  33. 33. Documenting Real World Relationships <ul><li>So think about how we describe the real world in terms of objects that we deal with everyday </li></ul><ul><li>Accurately document the real-world scenarios of the problem domain (a.k.a. requirements) </li></ul><ul><li>Analyze the scenarios, identify the objects and messages between them </li></ul><ul><li>Determine the (types of) relationships among the objects and their multiplicities </li></ul><ul><li>Further refine the interaction diagrams as you move through design </li></ul><ul><li>Once the modeling is complete, the coding should be a straight-forward process </li></ul>
  34. 34. What Interaction Modeling Means <ul><li>You are modeling real-world scenarios </li></ul><ul><ul><li>Managing our applications should be easier, since they map directly to how our business processes actually work </li></ul></ul><ul><ul><li>Our problem domains and solution domains have a direct relationship with each other </li></ul></ul><ul><ul><li>The interaction modeling is derived from the problem domain (requirements) through the solution domain (detailed design) </li></ul></ul><ul><li>As Albert Einstein said, “Keep it simple, but not simpler!” </li></ul><ul><li>Try to keep the model complete and sufficient at the same time </li></ul><ul><li>Analyze the diagrams, refine them, simplify them, but don’t take away value </li></ul>
  35. 35. Summary <ul><li>Need to model object relationships in a use-case scenario? </li></ul><ul><ul><ul><li>Think in terms of how people or things interact as they do in the real-world </li></ul></ul></ul><ul><ul><ul><li>This is easier than we think, since we are accustomed to it … we don’t apply those same principles in the world of procedural design and development </li></ul></ul></ul><ul><li>Object Interaction Diagramming is one part of the super-specification of UML </li></ul><ul><li>UML 2.0 is the Current Official Version </li></ul><ul><ul><ul><li>http://www.omg.org/technology/documents/formal/uml.htm </li></ul></ul></ul><ul><ul><ul><li>Get the UML 2.0 specification for free </li></ul></ul></ul><ul><ul><ul><li>Choose the type of diagramming that suits your needs </li></ul></ul></ul><ul><ul><ul><li>“ Go for it!” </li></ul></ul></ul>

×