Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 4 Object-Oriented Design.

Slides:



Advertisements
Similar presentations
From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write.
Advertisements

Use-Cases.
Use Case & Use Case Diagram
1Spring 2005 Specification and Analysis of Information Systems Specifying Requirements with Use Case Diagrams Part II.
© 2010 Bennett, McRobb and Farmer1 Use Case Description Supplementary material to support Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Use Case Modeling SJTU. Unified Modeling Language (UML) l Standardized notation for object-oriented development l Needs to be used with an analysis and.
Business Analysis & Data Design ITEC-630 Spring 2008
Robert B. Jackson Brigham Young University John W. Satzinger
Use cases.
Information System Engineering
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Requirements and Design
Sequence Diagrams. Introduction A Sequence diagram depicts the sequence of actions that occur in a system. The invocation of methods in each object, and.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
ATM User Interface Design. Requirements A bank customer is able to access his or her account using an automatic teller machine. To be able to use an ATM.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
Solving the Problem Analysis & Design.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Software Engineering CSE470: Requirements Analysis 1 Requirements Analysis Defining the WHAT.
Chapter 1 Program Design
Use Case Analysis – continued
UML exam advice. Minimal, yet sufficient UML course 80% of modeling can be done with 20% of the UML. Which 20% was that again? We’re supposed to be “Use.
Chapter 9 Domain Models 1CS6359 Fall 2012 John Cole.
Lecture Note 8 Using Data Flow Diagrams
Use Case Modeling. Use case diagram For each use case we develop  Object class diagram (with attributes only)  System sequence diagram (analysis) 
Chapter 3 Object-Oriented Analysis of Library Management System(LMS)
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
Chapter 3 Use Cases.
Use Cases 2 ENGR ♯10 Peter Andreae
1 © 2005 course technology University Of Palestine Chapter 6 Storyboarding the User’s Experience.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
Introduction to Sequence Diagrams
Interaction Modeling. Overview The class model describes the objects in a system and their relationships, the state model describes the life cycles of.
Interaction Modeling. Introduction (1) Third leg of the modeling tripod. It describes interaction within a system. The class model describes the objects.
© 2005 course technology1 1 1 University Of Palestine UML for The IT Business Analyst A practical guide to Object Oriented Requirement Gathering Hoard.
1 Object-Oriented Analysis Use Case Driven. 2 The outline method for OOA 1.Identify object classes within the problem domain 2.Define the behaviour of.
Faculty of Computer & Information Software Engineering Third year
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Approaching a Problem Where do we start? How do we proceed?
SE: CHAPTER 7 Writing The Program
Faculty of Computer & Information
©2008 TTW Where “Lean” principles are considered common sense and are implemented with a passion! Product Training RMA.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Example: object diagram for Scheduler, v What is wrong with this diagram? Seems like a lot of similarity between Task and UnplannedTask Can use.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
1 Chapter 5 Modeling System Requirements Finding the Use Cases Page
Design Model Lecture p6 T120B pavasario sem.
Requirements Management with Use Cases Module 10: Requirements Across the Product Lifecycle Requirements Management with Use Cases Module 10: Requirements.
Requirements specification Why is this the first major stage of software development? –Need to understand what customer wants first Goal of requirements.
CS212: Object Oriented Analysis and Design Lecture 32: Use case and Class diagrams.
Scenario A scenario is a sequence of steps describing an interaction between a user and a system. Use case is a set of scenarios tied together by a common.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Chapters 10, 11 SSD (Revision) SD DCD Exam Object-Oriented Design.
Object-Oriented Analysis and Design Use cases Finding classes Collaboration and Sequence diagrams Associations between classes.
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences.
1 After the scenarios are formulated Find all the use cases in the scenario Describe each of these use cases in more detail Participating actors Describe.
UC Diagram & Scenario RKPL C & D. Using Use Case Diagram Use case diagrams are used to visualize, specify, construct, and document the (intended) behavior.
Dillon: CSE470: ANALYSIS1 Requirements l Specify functionality »model objects and resources »model behavior l Specify data interfaces »type, quantity,
Use Case Modeling - II Lecture # 27.
Unified Modeling Language
OO Domain Modeling With UML Class Diagrams and CRC Cards
Workshop for CS-AP Teachers
SE-565 Software System Requirements IV. Use Cases
Use Case Model Use case diagram – Part 2.
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
Use Case Analysis – continued
Use cases Dr. X.
Presentation transcript:

Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 4 Object-Oriented Design

Georgia Institute of Technology Learning Goals Understand the basics of object-oriented design –Purpose of Design –Goals of Object-Oriented Design –Principles of Good Object-Oriented Design –How to transition from analysis to design –The design process

Georgia Institute of Technology Object-Oriented Design The purpose of design is to build an abstract, high-level, description of HOW the system will work In Structured Design the emphasis is on: –Top-down design –Successive refinement of functions In OO Design the emphasis is on: –Refinement of the classes and the relationships between them –Mapping classes to the implementation environment

Georgia Institute of Technology Goals of Object-Oriented Design Decrease coupling: the degree to which two components depend on each other’s implementations (minimize the effect of changes) Increase cohesion: the degree to which the responsibilities of a class are related (maximize the ability to combine objects)

Georgia Institute of Technology Good Object-Oriented Design Is based on real world artifacts –That makes the design reusable Information access is enough –Objects don't need information that they can't get to. –Objects can get to the information they need directly or indirectly Responsibility, control, and communication is distributed –No one object does everything Attributes and operations are factored out as high in the class hierarchy as possible –Using inheritance There should be little or no redundancy –Code should appear only once

Georgia Institute of Technology Good Design Exercise Double click on battle.html and run the battleship game Open the class battle.java in the folder exercises/battleship –What do you think of this design? –How easy or hard would it be to change this game? adding 2 players adding more ships changing the size of the game board

Georgia Institute of Technology Getting Started on Design Design can be partitioned into –Internal Design: Converting conceptual models into specification models Refinement of classes and the relationships between classes –Interface Design: Define the external interface to Users Persistent data Other programs OOD does not usually require –Pseudo-code for class operations –Class designs to be “frozen” before implementation commences

Georgia Institute of Technology Design Process Review the analysis class diagram –Check that the names are correct and understandable Create detailed use cases –Include user interface details and interface prototypes Modify the class diagram to add attributes, operations, and new classes –Found in the detailed use cases –Decide which class will track an association One direction or bi-directional

Georgia Institute of Technology Review the Class Diagram

Georgia Institute of Technology Example Class Diagram This model is just one feasible static object model At design time, we can refine the model –Is a Deck the same object as the Stock pile? –How do we handle moving piles of cards?

Georgia Institute of Technology Review the Class Diagram Review classes and remove –vague classes system –redundant classes a class should appear only once in the diagram –irrelevant classes outside the domain Review the class names Review attributes Review operations Review the relationships between classes

Georgia Institute of Technology Review the Class Names Do the names reflect the domain? Does the name reflect the purpose of the class? –Is a connector between shapes a line or a connector? Are the names pronounceable? Does each word in a class name start with a capital letter: ShapeCanvas? Are the names clear and unambiguous? Are the names singular? –Course not Courses

Georgia Institute of Technology Review Attributes Add types to attributes –Using types in the chosen language (if needed) Some attributes need to be expanded –A person’s name Some attributes should be classes –An address Some attributes can be grouped into a class –A date range

Georgia Institute of Technology Review Operations Check the names of the operations –Are they easy to read and clear? Add parameters and return types Check that the operations are on the correct class –The class you expect would be doing the action Check if several classes have similar operations that can be put in a parent class –Even if the names of the operations are different

Georgia Institute of Technology Review Inheritance Use inheritance only when the child class is a “type of” the parent class –Use association if this isn’t true Modify multiple inheritance to use interface realization –if you are using a language that doesn’t support multiple inheritance

Georgia Institute of Technology Add Classes to Clarify Relations Doctor, Nurse, and Patient are all “a kind of” Person But Doctor and Nurse are both Medical Personnel too –Introduce a new class Medical Person

Georgia Institute of Technology Delegation instead of Inheritance Use delegation to simply use (buy) another class –An object handles a message by sending messages to other objects User gets the person name from person –Allows an object to invoke other objects’ operations without adding the overhead of inherited operations

Georgia Institute of Technology Review Association Use association when an object of a class “has a” object of another class –A catalog has items Add navigability to show which side of an association cares about the relationship –A catalog will track the items in it but the items won’t care what catalog they are in

Georgia Institute of Technology Create Detailed Use Cases

Georgia Institute of Technology Create Detailed Use Cases Expand the high-level use cases from analysis –Go into the details including the user interface Elicit rare or minor use cases –People remember the “standard” things. Consider future use cases –What things might we want the system to do in the near future? Assign use cases to iterations –When will you implement the use case?

Georgia Institute of Technology A Detailed Use Case Defines how as well as what –Names the user interface elements –Names parts of the system –Go into the details of how Describes the success scenario –Sequence of steps when everything goes well Describes alternative scenarios as well –Times when things go wrong or –Times when things are handled differently

Georgia Institute of Technology Scenarios versus Use Cases A scenario is a sequence of interactions between a user and a system –About a user goal –Example for the goal of making a bulleted list: User selects some text and then clicks on the icon to make the text a bulleted list. The system modifies the text to make it a bulleted list. A use case is a set of scenarios that have the same user goal –Includes the success scenario “happy day” scenario –Includes failures and alternative success scenarios as well

Georgia Institute of Technology Detailed Use Case Format There is no standard format Two typical types –Use case with alternative scenarios included in the body of the success scenario Indenting used to show alternatives –Use case with uninterrupted success scenario Alternatives are listed after the success scenario Numbering –Some use simple numbering 1, 2, 3, … –Others use decimal numbering 1, , 1.2.1,

Georgia Institute of Technology Detailed Use Case Example Name: Placing an Order Actors: customer (initiates), salesperson, Frequency: common, Priority: Essential 1.A customer calls in an order. The salesperson brings up an Order Entry page. The User Interface (UI) prompts the salesperson for the number on the catalog that identifies the catalog and customer. 2.The customer gives the number 3.The salesperson verifies the customer name and catalog name and asks for the first item 4.For each item the customer gives the item number 5.For each item the salesperson gives the item name, price and asks the customer for the options and quantity 6.For each item the customer gives the quantity and the salesperson reserves this quantity for the customer 7.When there are no more items in the order the salesperson gives the shipping choices, length of time, and cost 8.The customer picks a shipping method

Georgia Institute of Technology Detailed Use Case Example 9.The salesperson gives the total cost of the order and gets or verifies the credit card information. A check is made to make sure the credit card will allow the charge. 10.The salesperson gives the order confirmation number (order number) and tells the customer when to expect the order. 11.The order status is set to pending and after the credit card approval occurs it changes to approved 12.The shipping clerk uses the Waiting to be Shipped page to see the items needed for the order. 13.The shipping clerk uses the Item Locator page to find where the items are in the warehouse. 14.The shipping clerk prints off an invoice, mailing label, and packs the order. The credit card is charged for the order. 15.The shipping company picks up the order and delivers it.

Georgia Institute of Technology Use Case Alternatives Alternative: New Customer –At step 1 this may be a new customer so use the use case of creating a new customer Alternative: Expired Catalog –At step 1 this may be an expired catalog and if so notify the user that the prices may be out of date Alternative: Backordered Item –At step 6 the item may indicate that it is on backorder. If so the salesperson will notify the customer and ask if they want to continue Alternative: Cancel –At any point the customer can cancel the order

Georgia Institute of Technology Detailed Use Case Example Use Case: Withdraw from ATM Actors: Customer, ATM (Customer Initiates) Frequency: Common Priority: Essential Description:

Georgia Institute of Technology Vending Machine Exercise Objective:Practice Object-Oriented design Duration:30 minutes Exercise:Modify a class diagram for the following requirements. Then write a detailed use case describing getting an item from the vending machine. Create the next generation vending machine that can tell when a part of it is broken and can place a service call so that a repairman can come and fix it.

Georgia Institute of Technology Vending Machine Class Diagram

Georgia Institute of Technology Revised Vending Machine

Georgia Institute of Technology Detailed Vending Use Case Name: Get item from machine Actors(s): Customer (initiates) Frequency: Common Priority: Essential Description: 1.The customer starts a transaction by putting money in the vending machine 2.The money holder validates the money entered and if valid adds it to the amount entered 3.The money holder updates the display to show the amount entered. 4.The customer pushes an item selector (sends a select to the item selector) 5.The item selector tells the item holder to dispense 6.The item holder gets the price from the item. 7.The item holder tells the display to display the item price. 8.The item holder checks if the money holder can make the required change. 9.The item holder dispenses the item 10.The item holder tells the money holder to dispense the change 11.The item holder tells item to decrement the quantity in stock 12.Item will decrement the quantity in stock and check if it is at the restock level and if so send a message to the supplier

Georgia Institute of Technology Detailed Vending Use Case - Alts Alternative – Validate money fails –Step 2. If the validate money fails the money is returned to the user and the display tells the user Alternative – Can’t make change –Step 8. If the money holder can’t make change then the display tells the user so the user can cancel the transaction Alternative – Can’t dispense item –Step 9. If the item isn’t dispensed the display is updated to tell the user so the user can cancel the transaction Alternative – Can’t reach supplier –Step 12. If the supplier can’t be reached try again every few hours and notify the vending machine company

Georgia Institute of Technology Revise the Class Diagram

Georgia Institute of Technology Adding Operations and Attributes Creating detailed use cases will likely uncover attributes and operations that were not thought of in analysis. Determining where the new attributes and operations should go depends on the class responsibilities. The assignment of responsibilities is a crucial skill in object-oriented design. Often new classes need to be created to refine the responsibilities.

Georgia Institute of Technology Responsibility Assignment Where to put an attribute? –Assign attributes to the class that it belongs to or who you would expect to be able to ask about it. Where to put an operation? –Assign an operation to the class that has the data needed for the operation or assign the operation to an intermediate class to reduce coupling (indirection).

Georgia Institute of Technology Responsibility Assignment Who should create an object of a class? –A should create B if A contains B. –A should create B if A has the initializing data for B. Who should handle an event? –The object that takes action based on the event or the container that holds the object that where the event occurred.

Georgia Institute of Technology Summary The purpose of design is to build a high-level description of how the system will work The goals of design are to reduce coupling and increase cohesion During design we should –Build a class diagram of the solution Add types and method parameters –Create detailed use cases –Create user interface prototypes