1 / 51

Programming Logic and Design Fifth Edition, Comprehensive

Programming Logic and Design Fifth Edition, Comprehensive. Chapter 13 System Modeling with the UML. Objectives. Understand the need for system modeling Be able to describe the UML Understand use case diagrams Understand class and object diagrams

bayle
Download Presentation

Programming Logic and Design Fifth Edition, Comprehensive

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Logic and DesignFifth Edition, Comprehensive Chapter 13 System Modeling with the UML

  2. Objectives • Understand the need for system modeling • Be able to describe the UML • Understand use case diagrams • Understand class and object diagrams • Understand sequence and communication diagrams Programming Logic and Design, Fifth Edition, Comprehensive

  3. Objectives (continued) • Understand state machine diagrams • Understand activity diagrams • Understand component and deployment diagrams • Be able to diagram exception handling • Be able to decide when to use the UML and which UML diagrams to use Programming Logic and Design, Fifth Edition, Comprehensive

  4. Understanding the Need for System Modeling • Most programs are part of a larger system • System design: specification of how all parts of the system are implemented and coordinated • Some guidelines: • Large systems are easier to understand when broken down into subsystems • The larger the system, the more important are modeling techniques • Good models promote communication in the development team Programming Logic and Design, Fifth Edition, Comprehensive

  5. Understanding the Need for System Modeling (continued) • Unified Modeling Language (UML) • Popular design tool • Allows you to break a system into subsystems • Hides implementation details • Means for programmers and businesspeople to communicate about system design • Plan division of responsibilities Programming Logic and Design, Fifth Edition, Comprehensive

  6. What is UML? • UML • Standard way to specify, construct, and document systems • Modeling language, not a programming language • Creates top-view diagrams of business processes • Designed to be nontechnical in nature Programming Logic and Design, Fifth Edition, Comprehensive

  7. What is UML? (continued) • UML has 13 diagram types in three major categories: • Structure diagrams • Behavior diagrams • Interaction diagrams • Each type supports multiple variations Programming Logic and Design, Fifth Edition, Comprehensive

  8. What is UML? (continued) • Structure diagrams: • Class diagrams • Object diagrams • Component diagrams • Composite structure diagrams • Package diagrams • Deployment diagrams Programming Logic and Design, Fifth Edition, Comprehensive

  9. What is UML? (continued) • Behavior diagrams: • Use case diagrams • Activity diagrams • State machine diagrams • Interaction diagrams: • Sequence diagrams • Communication diagrams • Timing diagrams • Interaction overview diagrams Programming Logic and Design, Fifth Edition, Comprehensive

  10. Using Use Case Diagrams • Use case diagram: • Shows how a business works from the perspective of someone outside the business • Includes users (employees, customers, suppliers) • Represents only the functions that are visible to the system’s actors • Analyze the main events in a system to establish use cases Programming Logic and Design, Fifth Edition, Comprehensive

  11. Figure 13-1 Use case diagram for librarian Programming Logic and Design, Fifth Edition, Comprehensive

  12. Using Use Case Diagrams (continued) • Each use case has at least one main scenario, but may also have more that are variations • Three variations in use cases: • Extend • Include • Generalization • Extend variation • Shows functions beyond those in the base case • Usually an optional activity Programming Logic and Design, Fifth Edition, Comprehensive

  13. Figure 13-2 Use case diagram for librarian with scenario extension Programming Logic and Design, Fifth Edition, Comprehensive

  14. Using Use Case Diagrams (continued) • Stereotype: adds more meaning to the UML vocabulary of shapes • Add “<<extend>>” near the relationship line • Include variation: • When a case can be part of multiple use cases • Shown with an oval and a dashed arrow • Generalization variation: • When you want to substitute a more specific case for a general one • Use open-headed dashed arrows Programming Logic and Design, Fifth Edition, Comprehensive

  15. Figure 13-3 Use case diagram for librarian using stereotype Programming Logic and Design, Fifth Edition, Comprehensive

  16. Figure 13-4 Use case diagram for librarian using include relationship Programming Logic and Design, Fifth Edition, Comprehensive

  17. Figure 13-5 Use case diagram for librarian with generalizations Programming Logic and Design, Fifth Edition, Comprehensive

  18. Using Use Case Diagrams (continued) • Use case diagrams may show multiple actors • Use case diagrams are only tools to aid communication • Keep them visually pleasing and not overcrowded • Use separate diagrams for different points of view: • Might emphasize actors and their relationships • Might emphasize actions and hide some of the specific actors to keep it simple Programming Logic and Design, Fifth Edition, Comprehensive

  19. Figure 13-6 Use case diagram for librarian with multiple actors Programming Logic and Design, Fifth Edition, Comprehensive

  20. Figure 13-7 Use case diagram emphasizing actors Programming Logic and Design, Fifth Edition, Comprehensive

  21. Figure 13-8 Use case diagram emphasizing system requirements Programming Logic and Design, Fifth Edition, Comprehensive

  22. Using Class and Object Diagrams • Class diagrams: • Illustrate names, attributes, and methods • More useful to programmers than users • Class diagram is a rectangle with three sections: • Top: name of the class • Middle: names of attributes • Bottom: names of methods Figure 13-9Book class diagram Programming Logic and Design, Fifth Edition, Comprehensive

  23. Using Class and Object Diagrams (continued) • Use generalizations with class diagrams to show: • More general (parent) classes • More specific (child) classes that inherit attributes from parents • Association relationship: • Describes the connection between objects • May include information about arithmetic relationships such as cardinality or multiplicity • Shown with a straight line between classes Programming Logic and Design, Fifth Edition, Comprehensive

  24. Figure 13-10LibraryItem class diagram showing generalization Programming Logic and Design, Fifth Edition, Comprehensive

  25. Figure 13-11 Class diagram with association relationship Programming Logic and Design, Fifth Edition, Comprehensive

  26. Figure 13-12 Class diagram with several association relationships Programming Logic and Design, Fifth Edition, Comprehensive

  27. Using Class and Object Diagrams (continued) • Whole-part relationship: • One or more classes make up the parts of a larger whole class • Also called an aggregation • Use open diamond at the “whole part” end of the line • Represents a “has-a” relationship • Object diagram • Models specific instances of classes • Shows a snapshot of an object at one point in time • Can use class diagrams or object diagrams interchangeably to suit your needs Programming Logic and Design, Fifth Edition, Comprehensive

  28. Figure 13-13 Class diagram with whole-part relationship Programming Logic and Design, Fifth Edition, Comprehensive

  29. Figure 13-14 Object diagram for Library Programming Logic and Design, Fifth Edition, Comprehensive

  30. Using Sequence and Communication Diagrams • Sequence diagram: • Shows timing of events in a single use case • Horizontal axis represents objects • Vertical axis represents time • Vertical dashed line from x-axis to object shows period of time that the object exists • Horizontal arrows show communication between objects over time Programming Logic and Design, Fifth Edition, Comprehensive

  31. Figure 13-15 Sequence diagram for checking out a Book for a Patron Programming Logic and Design, Fifth Edition, Comprehensive

  32. Using Sequence and Communication Diagrams (continued) • Communication diagram: • Emphasizes the organization of objects in a system • Contains sequence numbers to show the precise order in which activities occur • Focus is on object roles Programming Logic and Design, Fifth Edition, Comprehensive

  33. Figure 13-16 Communication diagram for Book class Programming Logic and Design, Fifth Edition, Comprehensive

  34. Using State Machine Diagrams • State machine diagram: • Shows the different statuses of a class or object at different points in time • Use rounded rectangles for each state and labeled arrows to show sequence of events that affect the state • Solid dot indicates start and stop states for a class or object Programming Logic and Design, Fifth Edition, Comprehensive

  35. Figure 13-17 State machine diagram for checking out a Book for a Patron Programming Logic and Design, Fifth Edition, Comprehensive

  36. Using Activity Diagrams • Activity diagram: • Resembles a flowchart • Shows flow of actions in the system • Use flowchart start and stop symbols (lozenges) to describe actions • Use solid dots to show start and stop states • Use diamonds for decisions, with possible outcomes shown along the branches Programming Logic and Design, Fifth Edition, Comprehensive

  37. Figure 13-18 Activity diagram showing branch Programming Logic and Design, Fifth Edition, Comprehensive

  38. Using Activity Diagrams (continued) • Forks and joins: • Used to show simultaneous activities • Indicated by thick straight lines • Fork: • Defines a branch in which all paths are followed simultaneously Programming Logic and Design, Fifth Edition, Comprehensive

  39. Using Activity Diagrams (continued) • Join: • Reunites the flow of control after a fork • Time signal: • Indicates that a specific amount of time has passed before an action is started • Shaped like an hourglass Programming Logic and Design, Fifth Edition, Comprehensive

  40. Figure 13-19 Activity diagram showing fork and join Programming Logic and Design, Fifth Edition, Comprehensive

  41. Figure 13-20 A time signal starting an action Programming Logic and Design, Fifth Edition, Comprehensive

  42. Using Component and Deployment Diagrams • Component diagram: • Used to emphasize files, databases, documents, and components used by a system’s software • Deployment diagram: • Focuses on a system’s hardware Programming Logic and Design, Fifth Edition, Comprehensive

  43. Figure 13-21 Component diagram Programming Logic and Design, Fifth Edition, Comprehensive

  44. Figure 13-22 Deployment diagram Programming Logic and Design, Fifth Edition, Comprehensive

  45. Diagramming Exception Handling • Program code uses try-catch blocks to trap errors and handle them • Protected node: • A try block in UML • Use a rounded rectangle • Exceptions that may be thrown are shown as lightning bolts • Handler body node: a catch block in UML Programming Logic and Design, Fifth Edition, Comprehensive

  46. Figure 13-23 Exceptions in the Book check-out activity Programming Logic and Design, Fifth Edition, Comprehensive

  47. Deciding Which UML Diagrams to Use • UML widely recognized modeling standard • Criticisms of UML • Size: UML too large and complex • Many diagrams infrequently used • Several are redundant • Imprecision: UML a combination of rules and English • Problems when diagrams applied to tasks not implemented in OO languages • Complexity: UML relatively difficult to learn Programming Logic and Design, Fifth Edition, Comprehensive

  48. Deciding Which UML Diagrams to Use (continued) • Each type of UML diagram provides a different view of a system • No view is superior to the others • Most complete picture is achieved by several views • UML diagrams are a communication tool Programming Logic and Design, Fifth Edition, Comprehensive

  49. Summary • UML allows programmers and businesspeople to communicate about system design • UML has 13 diagram types • Use case diagram shows how business works from the standpoint of those who use the business • Class diagram illustrates the names, attributes, and methods of a class or set of classes Programming Logic and Design, Fifth Edition, Comprehensive

  50. Summary (continued) • Object diagram models a specific instance of a class at one point in time • Sequence diagram shows the timing of events in a single use case • Communication diagram shows the organization of objects in a system • State machine diagram shows status of a class or object at a specific point in time Programming Logic and Design, Fifth Edition, Comprehensive

More Related