CS 151: Object-Oriented Design September 3 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak www.cs.sjsu.edu/~mak.

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 Case & Use Case Diagram
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
Use Case Model. C-S 5462 Use case model describes what the user expects the system to do –functional requirements may describe only the functionalities.
Use Case Modeling SJTU. Unified Modeling Language (UML) l Standardized notation for object-oriented development l Needs to be used with an analysis and.
Ch 12: Object-Oriented Analysis
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
CS3773 Software Engineering Lecture 03 UML Use Cases.
CS 160: Software Engineering September 8 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Documenting Requirements using Use Case Diagrams
Object Oriented Analysis Process
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
CS 235: User Interface Design August 27 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CS 235: User Interface Design August 27 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Object-oriented Design CSCI 5801: Software Engineering.
Use Cases 2 ENGR ♯10 Peter Andreae
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 06. Requirements.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
CS 160: Software Engineering October 8 Class Meeting
CS 46B: Introduction to Data Structures June 16 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
CS 160: Software Engineering September 10 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 25. Review Design Level Class Diagram Identifying classes/Operations/Attributes Associations – Simple associations.
10/12/ Recall The Team Skills 1. Analyzing the Problem (with 5 steps) 2. Understanding User and Stakeholder Needs 1. Interviews & questionnaires.
Chapter 6 Use Cases. Use Cases: –Text stories Some “actor” using system to achieve a goal –Used to discover and record requirements –Serve as input to.
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.
USE CASE Bayu Adhi Tama, MTI Faculty of Computer Science, University of Sriwijaya Slides are adapted from Petrus Mursanto
 Development is organized in a series of short, fixed-length mini-projects called iterations  Iterations are also incremental  Successive enlargement.
Faculty of Computer & Information
CS 151: Object-Oriented Design October 24 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
240 3/30/98 CSE 143 Object-Oriented Design [Chapter 10]
A Use Case Primer 1. The Benefits of Use Cases  Compared to traditional methods, use cases are easy to write and to read.  Use cases force the developers.
CS 235: User Interface Design September 3 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CS 160: Software Engineering September 3 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
1 System Analysis and Design Using UML INSTRUCTOR: Jesmin Akhter Lecturer, IIT, JU.
CS 151: Object-Oriented Design September 5 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak
CS 151: Object-Oriented Design September 12 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
1 Version /05/2004 © 2004 Robert Oshana Requirements Engineering Use cases.
1 Chapter 5 Modeling System Requirements Finding the Use Cases Page
1 Graph Coverage (6). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
ITEC324 Principle of CS III Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
CS212: Object Oriented Analysis and Design Lecture 32: Use case and Class diagrams.
CS 151: Object-Oriented Design August 29 Class Meeting Department of Computer Science San Jose State University Spring 2012 Instructor: Ron Mak
UML - Development Process 1 Software Development Process Using UML.
Chapter 6: Structuring Requirements: Use Case Description and Diagrams Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences.
CS 160 and CMPE/SE 131 Software Engineering February 18 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
CS 160 and CMPE/SE 131 Software Engineering February 25 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
Identification of Classes. Object Oriented Analysis (OOA) OOA is process by which we identify classes that play role in achieving system goals & requirements.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Requirements. Outline Definition Requirements Process Requirements Documentation Next Steps 1.
Chapter 2 (Horstmann’s Book) – Part 1 The Object-Oriented Design Process Hwajung Lee.
Chapter 3: Software Design –Use case Diagram Nouf Alghanmi.
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.
Requirements capture: Using UML Use Cases David Millard and Yvonne Howard {dem,
CMPE 135: Object-Oriented Analysis and Design August 31 Class Meeting
CMPE 280 Web UI Design and Development August 29 Class Meeting
Use Case Modeling - II Lecture # 27.
Recall The Team Skills Analyzing the Problem (with 5 steps)
Storyboarding and Game Design SBG, MBG620 Full Sail University
Use Case Model.
OO Domain Modeling With UML Class Diagrams and CRC Cards
SAD ::: Spring 2018 Sabbir Muhammad Saleh
CMPE 135: Object-Oriented Analysis and Design September 6 Class Meeting Department of Computer Engineering San Jose State University Fall 2018 Instructor:
Using Use Case Diagrams
CMPE/SE 131 Software Engineering February 16 Class Meeting
ITEC324 Principle of CS III
CMPE/SE 131 Software Engineering February 22 Class Meeting
Presentation transcript:

CS 151: Object-Oriented Design September 3 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 2 Ye Olde Waterfall Model Requirements DesignImplementation Testing

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 3 The Waterfall Model  Make sure each phase is 100% complete and absolutely correct before proceeding to the next phase.  Big Design Up Front (BDUF) Set requirements in stone before starting the design.  Otherwise, design work that is based on “incorrect” requirements would be wasted. Spend extra time at the beginning to make sure that the requirements and design are absolutely correct.  The waterfall model has been mostly discredited. It doesn’t work! But it’s still commonly practiced. Source: Wikipedia article on “Waterfall Model” Requirements Design Implementation Testing

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 4 Project Phases  Today we know that development is a series of iterations. Each iteration is a “mini waterfall” consisting of design, code, and test. Advocates of Extreme Programming will say: design, test, code

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 5 Agile Software Development  Iterative and incremental development Each iteration is a “mini waterfall”:  plan (with new requirements)  refine design  add new code  unit and integration testing Iterations are short: days and weeks rather than months. _ Requirements Design Implementation Testing

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 6 Ways to Elicit Requirements  Interview the stakeholders But you need to know the right questions to ask! Be aware of cultural or political issues.  Joint Application Design (JAD) Multi-day workshop with stakeholders and developers to hash out requirements.  Ethnography Developers “live with” the users to observe, learn, and understand their world. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 7 But …  Users don’t always know what they want! There must be an ongoing dialog among the developers, the clients, and the users. There needs to be an iterative process:  Developers show something  Clients and users validate  Repeat  If the developers force the clients or users to come up with the requirements too soon... They may make something up! Such requirements will most likely be wrong or incomplete. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 8 Requirements Elicitation Tasks  Identify actors  Identify and document use cases Abstractions of actor-system interactions.  Identify functional requirements Extract functional requirements from the use cases.  Identify nonfunctional requirements Do this at the same time as when you’re identifying the functional requirements (as embodied by the use cases). Nonfunctional requirements have as much impact on the development and cost of the system as functional requirements.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 9 Use Cases  A use case describes how to achieve a single goal or accomplish a single task. A complete sequence of actions or events. Primary sequence plus alternate sequences (“exception paths”). A sequence is triggered by an actor. Focus on what the system must do, not how to do it.  Actors are external agents that interact or communicate with the system. actor = role abstraction An actor can be a person or another system.  A use case treats the system as a “black box”. ?

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 10 Example: Bank ATM System Log in customer Display balance Shut down ATM Start up ATM Log out customer Withdraw cash Operator Customer Bank system boundary actor interaction system UML use case diagram use cases

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 11 Example Use Case Description  Name: Withdraw Cash  Goal: Customer withdraws cash from ATM.  Summary: A customer who has logged in can withdraw up to $500 cash in $20 bills.  Actors: The customer and the bank  Preconditions: The ATM has been started up.  See use case “Start up ATM”. The customer has inserted a valid bank card. The customer has entered a correct PIN. What must be true before the use case can start. verb object

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 12 Example Use Case Description, cont’d  Trigger: The customer selects the “Withdraw Cash” option.  Primary sequence: 1. The system prompts the customer for the amount. 2. The customer chooses from a list of amounts or enters a amount. 3. The customer submits the amount. 4. The system dispenses the amount in $20 bills. 5. The bank deducts the amount from the customer’s balance. 6. The system displays the customer’s balance See use case “Display balance”. At most about 10 steps.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 13 Example Use Case Description, cont’d  Alternate sequences: 3.1 The customer entered an amount not a multiple of $20.  The system displays a message to the customer.  The system prompts the customer for a new amount. 3.2 The customer’s bank balance is insufficient.  etc.  Postconditions: The customer receives the desired amount of cash.  The amount is deducted from the customer’s account.  The customer sees the new account balance. OR: The customer receives no cash.  The customer’s account is unchanged. What must be true after the use case is done.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 14 Example Use Case Description, cont’d  Nonfunctional requirements: The system responds to each customer input within 5 seconds. The system displays messages in either English, Spanish, or Vietnamese.  Glossary customer = a person who wants to withdraw cash from the ATM. bank = a system that maintains customer accounts and balances. etc. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 15 Use Case Guidelines  Use case names should be verb object. Each name should describe an achievable goal (e.g., “Withdraw Cash”).  Keep use cases short, simple, and informal. Clients and users need to understand them. No GUI or implementation details.  When your use cases cover most possible scenarios of your application, then you have enough requirements to start design. Some use cases may cause you to add new requirements. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 16 Assignment #1  Your team is going to write an application that where the computer plays the Rock-Paper-Scissors game with a human player. Note: You will not actually write this application for this assignment.  A match consists of one or more throws: The number of throws per match is an input parameter.  Example: 20 throws per match For each throw, the human player inputs his or her choice (rock, paper, or scissors) and then the computer responds with its choice. Although the computer records the human’s choice, its own choice must not depend on knowledge of the human’s choice. The computer keeps track of who wins each throw (or it’s a tie).

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 17 Assignment #1  Instead of entering his or her choice, the human can ask for the current score a help message  At the end of a match, the computer displays the number of throws won by the human the number of throws won by the computer the number of ties who is the winner of the match  See these links:

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 18 Assignment #1  Write a Function Specification for this application. It must contain, in this order: problem statement objectives functional requirements (at least 6) nonfunctional requirements (at least 3) use case diagram containing at least 3 use cases use case descriptions (at least 3)  Use case form:

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 19 Assignment #1  Send as a Word document or a PDF to Subject: CS 151 Assignment #1 team-name CC all the team members Team assignment (each team has one hand-in) Due Thursday, September 12 at 11:59 PM

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 20 Where Do Classes Come From?  Textual analysis Look for nouns and verbs in your use cases. Nouns  classes  Some nouns are actors. Verbs  methods Class names should be nouns in the singular form, such as Inventory, Instrument, InstrumentSpec.  How will the classes support the behaviors that your use cases describe?  Focus on concepts, not implementation. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 21 Categories of Classes  Things Examples: Instrument, InstrumentSpec  Agents Represent doers of tasks. Names often end in “er” or “or” Examples: Scanner, Paginator  Events and transactions Model records of activities that describe what happened in the past or what needs to be done later Example: MouseEvent remembers when and where the mouse was moved or clicked.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 22 Categories of Classes  Users and roles Stand-in for the actual users of the application. Common in systems that are used by more than one person or where one person needs to perform distinct tasks. Examples: Administrator, Reviewer  System Model a subsystem or the overall system being built. Typical methods: initialize, shutdown, read input  System interfaces and devices Interfaces to the host operating system, file system, etc.  Foundation Typically the built-in classes. Examples: String, Date

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 23 Class Responsibilities  Responsibilities correspond to verbs in the use cases.  Each responsibility should be owned by one and only one class.  Common mistakes: Assigning a responsibility to an inappropriate class. Assigning too many responsibilities to a class. Ideally, each class should have a single primary responsibility. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 24 Class Responsibilities Example  class Automobile start() stop() changeTires() drive() wash() displayOilLevel() checkOil()  class Automobile start() stop() displayOilLevel()  class Driver drive()  class CarWash wash()  class Mechanic changeTires() checkOil() Too many responsibilities! A cohesive class does one thing really well and does not try to be something else.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 25 Class Relationships: Dependency  Class C depends on class D : Some method of C manipulates objects of D Example: Mailbox objects manipulate Message objects.  Dependency is asymmetric. The Message class is not aware of the existence of the Mailbox class. Therefore, Message objects do not depend on Mailbox objects.  Loose coupling Minimize the number of dependency relationships. Another way for a design to handle change. _

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 26 Class Relationships: Aggregation  Class C aggregates class A : Objects of class C contains objects of class A over a period of time.  A special case of dependency. The “has-a” relationship. Example: An Inventory object has a list of Instrument objects.  Multiplicity 1:1 – Example: Each Person object has a single StreetAddress object. 1:n – Example: Each Inventory object has an array of multiple Instrument objects.

SJSU Dept. of Computer Science Spring 2013: September 3 CS 151: Object-Oriented Design © R. Mak 27 Class Relationships: Inheritance  Class C inherits from class S. The “is-a” relationship. All class C objects are special cases of class S objects. Class S is the superclass of class C. Class C is a subclass of class S. An object of class C is an object of class S.  Note Aggregation: A Mailbox object has a Message object. Inheritance: A ForwardedMessage object is a Message object. _