UML and the design of ObjectOriented Information Systems Professor Randy Guthrie Japanese Engineer Training (JET) Randy Guthrie – Microsoft Corporation 1 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 2 15 Years Industry Experience Contract Administrator Project Manager Financial Analyst 9 Years University Teaching Experience 1 Year with Microsoft Corporation Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 3 My Family Married 29 years Six Children three married Three in college one still in school Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 4 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 5 Denver, Colorado Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 6 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 7 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 8 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 9 Four Stages: Inception Elaboration Construction Transition Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 10 Making the business case to management High level goals of the project Rough estimates of costs & benefits Rough estimates of resource commitments Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 11 Better definition of overall goals of project Iterative implementation of core architecture Resolution of high risks Identification of most of the requirements Realistic estimates Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 12 Iterative implementation of lower-risk elements Preparation for deployment Training Hardware installation & test Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 13 Beta or limited-release testing Deployment Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 14 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 15 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 16 Iterative Development software/system developed in iterations (cycles) each iteration critical use cases developed first two-four weeks duration based on use cases fully-dressed use cases domain model robustness diagram sequence diagram class diagram working code tested code Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 17 Each iteration completes a portion of the system client evaluates software at each iteration changes are incorporated into next iteration cycle continues until system is complete Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 18 Prototype Screens Domain Model Casual / Full Dress Use Case Event Analysis Brief Use Cases Unified Process / Iterative Development Rank Use Cases Code and Test Robustness Diagram Sequence Diagram Class Diagram Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 19 Some Best Practices Iterative Development Project developed in 2-4 week phases Called “time-boxes” Use of software design “patterns” GRASP Gang of Four Many others Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 20 Exploring the “problem domain” Defining system and problem boundaries What is “in-scope” vs. “out-of-scope” Discovering system requirements Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 21 Creating a conceptual solution Identifying software classes Assigning responsibilities to the software classes Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 22 Software Classes have two types of responsibility: “knowing” (attributes / data) “doing” (behavior / methods) Assigning responsibilities to classes is a critical activity of software design In other words, deciding where the variables and operations go is really important Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 23 Are done at the same time Most analysis is completed during elaboration phase during early iterations Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 24 A standardized set of documentation and diagramming techniques that are useful for analyzing and designing information systems that will be implemented using object-oriented software Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 25 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 26 End-user Functionality Programmers Logical View Development View Scenarios Process View Physical View Integrators Performance Scalability Japanese Engineer Training (JET) System Engineers Topology/Communications Randy Guthrie - Cal Poly Pomona 27 Supports Functional Requirements what services the system should provide to the users Focus on objects and object classes class diagrams Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 28 Specifies non-functional requirements performance availability fault tolerance Specifies how functional requirements will be met Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 29 Focuses on how the actual software modules/class are organized software structure Object Oriented or structured three-tier architecture Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 30 Addresses physical infrastructure and topologies for system hardware/software platforms networks terminals protocols storage media backup / recovery Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 31 All four views are integrated (related) through “scenarios” Scenario is a story about how the system is used sometimes referred to as “use cases” Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 32 Stories about how a feature is used to complete a task Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 33 Not part of UML and not OO Text Document, not a “diagram” Focuses on one task / feature Can be high level and brief Can be low-level and detailed Typically avoids mention specific technology such as “scan bar code” Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 34 Three general types of use case Brief: one paragraph summary Casual: information paragraph format– multiple paragraphs cover various scenarios Detailed (full dress): formal structure Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 35 Sections of Detailed Use Case: Primary Actor Stake Holders and Interests Preconditions Success Guarantees (Post Conditions) Main Scenario (basic flow) Extensions (alternative flows) Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 36 Optional Sections Special Requirements Technology and Data Variations List Frequency of Occurrence Open Issues Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 37 Primary Actor the person that is interacting directly with the system (entering data and receiving output) Sometimes called the “user” Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 38 Stakeholders and Interests individuals and entities that have an interest in the successful completion of the use case Includes the person triggering the event if not the user Usually people/roles, but can also be organizations helps to define what should be included in use case Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 39 Preconditions a statement describing environmental conditions that must always be true before beginning the use case scenario example: must have an account with the bank before you can deposit money Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 40 Success Guarantees (Post Conditions) State what must be true on successful completion of the use case Describes what useful function the system performed and/or what thing of value was delivered to the customer Describes the system state, data storage, and activities completed Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 41 Main Success Scenario (basic flow) numbered steps describing both user and system behavior and interaction interactions validation state changes write in third person (sports announcer) Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 42 Extensions (Alternative Flows) Similar format as main success scenario Identifies what to do when there is a problem or failure in main success scenario Numbers correspond to step in main success scenario Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 43 Special Requirements Identifies any non-functional requirements, quality / performance attributes, or other constraint language time constraints business rules Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 44 Technology and Data Variations List known technology requirements operating system input/output devices ie: scanner, bar code, etc. interfaces / links Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 45 Write a “full-dress” use case for withdrawing funds from a bank ATM Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 46 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 47 In iterative development, you develop ( the most critical use cases first find out early about critical problems can cancel with minimal investment more schedule/budget flexibility when complicated parts of system are done early later project cost /schedule estimates will be more accurate Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 48 Three Criteria Risk Coverage Criticality Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 49 Technical Risk Scope Risk cutting edge technology not a lot of in-house expertise size of effort Cost Risk cost of hardware/software cost of outside labor/consulting Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 50 The number of processes that are impacted by this use case Is this an important pre-condition for other use cases? Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 51 The importance of the use case to the overall goals of the system/business If use case describes a process central to the reason the system is being developed, it is more critical Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 52 Use Case Risk Coverage Criticality Total Check out Book 3 6 8 17 Search Catalog 3 2 2 7 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 53 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 54 System is shown as a hollow rectangle Use cases are shown as labeled ovals inside the rectangle Actor(s) are shown as stick figures on the left of the rectangle Supporting actors are shown as stick fingers on the right of the rectangle. Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 55 Use Case Diagram Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 56 System Sell Item Reorder Inventory Ship Item Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 57 Use Case Diagram Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 58 Prepare a Use Case Diagram showing three basic banking functions: deposit withdrawal balance enquiry Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 59 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 60 Represents real thing (not software class) Class diagram structure: Name Attributes Associations name (may have a reading arrow) multiplicity Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 61 Student -name -address -e-mail -major -idNumber Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona Name Attributes 62 Association Name Association Student -name -address -e-mail -major -idNumber Reading Arrow Professor Is Taught By4 0..* 0..* -name -department -phone -empID -rank Multiplicity Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 63 Indicates how many instances of an object can be associated with a single instance of another Student -name -address -e-mail -major -idNumber One professor is associated with 0 to many students Japanese Engineer Training (JET) Professor Is Taught By4 0..* 0..* -name -department -phone -empID -rank One student is associated with 0 to many professors Randy Guthrie - Cal Poly Pomona 64 Multiplicity Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 65 Use Category List to help identify domain objects physical objects places transactions people roles organizations events collections of things containers of things Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 66 Nouns in use cases and other documents are often important objects Use case Event tables Other analysis artifacts Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 67 Naming objects Use existing names within the problem domain Exclude features not related to problem Do not add things that do not currently exist Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 68 Associations (connecting lines) relationship between conceptual classes that is meaningful or significant relationship that needs to be preserved over some time duration show only those that you know are important inherently bi-directional can have multiplicity (cardinality) Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 69 Strong (mandatory) relationship Whole cannot exist without the parts Example: Computer processor motherboard memory power supply Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 70 Weaker relationship (optional) Whole can exist without all the parts Example: Computer Floppy drive Mouse Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 71 Sometimes called “inheritance” Child classes are specific instances of parent class Child classes possess all attributes of parent Is-A type relationship Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 72 Attributes logical data values should be simple (primitive) are similar to variables in class diagrams should not be used as “foreign keys” Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 73 Process: identify classes add associations add attributes Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 74 Real World Objects Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 75 Write a domain model for a bank Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 76 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 77 Artifacts Feature Design Planner, Designer or Program Manager Prototype GUI Windows Detailed Specification Scenarios System specifications Software Design (UML) Robustness Diagram Interaction Diagrams Systems Analyst, Software Engineer or Programmer Class Diagrams Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 78 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 79 Based on a use case Is a “feature” in the system Highest ranked features are developed first Can be drawn by hand Or use Visual Studio or Visio Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 80 Select Search Type Enter Search Words List Box Text Field Search Button Results Window Text Area Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 81 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 82 Links your interfaces with software logic Not a formal part of the UML Shows how data moves between interfaces and entity classes Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 83 Represent GUI Components Can interact with Actors Can interact with Control Objects Cannot directly interact with Entity Objects Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 84 Represent methods Can interact with Boundary Objects Can interact with Entity Objects Can interact with other Control Objects Cannot interact with Actors Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 85 Represent software classes Represent real-world concepts Supply or store data Can only interact with Control Objects Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 86 Boundary Rules Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 87 Show how Control Objects move data between Boundary Objects and Entity Objects Customer Info Window Get Customer Info Customer Arrow shows the direction that data is moving Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 88 Search Type List Box Keyword Text Field Search Catalog Patron Catalog Search Button Display Results Results Window Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 89 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 90 Illustrates how instances of software classes interact via “messages” A message is sent to a class instance in order to make it fulfill one of its “responsibilities” Usually method calls set methods get methods constructor methods (<<create>>) query operations input / output operations Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 91 Notation for instances is slightly different than class notation name is preceded by a colon name is underlined static methods should be sent to the class (name not underlined) Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 92 Two Kinds: Object2 Object1 Sequence Diagram Object3 onClick() getData(no) performFunction(fno) Top Package::Actor1 Collaboration Diagram onClick() ObjectA 1. g etD ata(n o) ObjectB Top Package::ActorA ObjectC Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona rform 2 . pe ti Func on(fn o) 93 Messages flow from top to bottom in the order they would be sent in the use case Time Object2 Object1 Object3 onClick() getData(no) performFunction(fno) Top Package::Actor1 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 94 Example: Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 95 Object1 Three kinds of messages click Actor1 Object Object getData(parameter) returnValue Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 96 Message Notation return :=message(parameter: parameter type) : return type example: amount:=getDepositAmount(transNo: int) :double or more simply: getDepositAmount(transNo) create Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 97 Returns can optionally be modeled by a dashed arrow can be labeled to show what is being returned Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 98 Process: Select use case (see use case ranking) Examine robustness diagram for the boundary classes and entity classes Add pure fabrication classes as needed refer to software design patterns (ie: Expert, Controller, Pure Fabrication) Decide where operations go and add messages to perform the indicated operations Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 99 Process (continued) Draw classes (instances) from left-to-right from most highly-coupled to least coupled controller classes should be furthest left Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 100 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 101 Practice individually making a sequence diagrams using Visio based on Robustness Diagram you created in previous exercise. Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 102 Collaboration Diagrams Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 103 Similar notation as sequence diagram with some minor differences arranged in “network” structure instances (or classes) are connected by a link (line) messages are located on the link link can have multiple messages messages are numbered (except first incoming) Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 104 Example InputWindow 3. getData() 1. enter data 2. on click Actor1 Japanese Engineer Training (JET) 4. calcResult(data) Button Randy Guthrie - Cal Poly Pomona Data Class 105 Associations in collaboration diagrams can have multiple messages 1. calcResult() 2. getData(no) Object1 Japanese Engineer Training (JET) Object2 Randy Guthrie - Cal Poly Pomona 106 Process: Draw classes (instances) on diagram with most highly-coupled on the top left to least coupled on lower right controller classes should be furthest left locate classes that collaborate close to each other Draw association lines (hint: no arrow heads or messages on associations) Examine methods in class diagram and create numbered messages that would invoke those methods Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 107 Individually practice making a collaboration diagram using Visio using the robustness diagram (or sequence diagram) from the prior exercise. Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 108 Specifying Software Classes Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 109 Illustrates the specifications for software classes and interfaces Shows the final (static) design of the software Can show multiple use cases But can be too complex to be useful Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 110 Three sections Class Name Variables Functions/Method Student -idNo -name -address -phone -majorDept +setAttributes() +getAttributes() Uses correct syntax for programming language Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 111 + means public access - means private access # means protected access public: item is accessible anywhere private Java: accessible only within the class C++: within the class and its “friends” Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 112 Protected C++: accessible by the class and its subclasses Java: accessible by classes in same package and subclasses everywhere Package (Java only) accessible only from classes within the same package Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 113 Visibility Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 114 Constructor: initializes an instance Query: returns a value but does not change the state (variables) of an instance Update: carries out some action that changes the state of the instance Destructor: used to delete instances Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 115 Method Types Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 116 Values and operations that span multiple instances of objects number of orders cumulative sales Class attributes and operations are underlined in class diagrams In Java, are preceded by the word static Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 117 relationship between classes in a class diagram represents dependencies between classes in the implementation components name reading arrow multiplicities at ends Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 118 Association Name Association Reading Direction Class2 Class1 -attribute1 -attribute2 +operation1() uses4 0..1 1..* multiplicities Japanese Engineer Training (JET) -attribute1 -attribute2 -attribute3 +operation1() +operation2() Navigation Arrow Randy Guthrie - Cal Poly Pomona 119 Shows which class contains a reference to another class The calling class points to the class with the method Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 120 Shown in class diagram to show how the system interacts with them <<actor>> Telephone Agent Japanese Engineer Training (JET) <<actor>> Credit Card Authorization Randy Guthrie - Cal Poly Pomona 121 Process: created in parallel with Interaction Diagrams determine scope of the present iteration select classes from the Domain model that are relevant to the current iteration Draw in a network structure including attributes Add any obvious or missing attributes Draw navigation based on messages Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 122 Process: (continued) Add constructor methods Add mutator (“set”) methods Add accessor (“get”) methods Add process methods calculations input / output GUI/interface Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 123 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 124 Individually practice making a class diagram using Visio based on the banking system we have been discussing Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 125 Reverse Engineering Looking a source code and making UML diagrams from the code CASE tools can usually create class diagrams from source / object code Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 126 With your groups, reverse engineer the instructor-provided Java program and create a sequence diagram and a class diagram Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 127 Japanese Engineer Training (JET) Randy Guthrie - Cal Poly Pomona 128