3. Object-oriented Design

Slides:



Advertisements
Similar presentations
Introduction To System Analysis and Design
Advertisements

Requirements Analysis 2 What objects collaborate to achieve the goal of a use case?
System Engineering Instructor: Dr. Jerry Gao. System Engineering Jerry Gao, Ph.D. Jan System Engineering Hierarchy - System Modeling - Information.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
Systems Analysis and Design in a Changing World, Fifth Edition
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Designing a Graphical User Interface (GUI) Krisana Chinnasarn, Ph.D. January 2007.
12 Systems Analysis and Design in a Changing World, Fifth Edition.
Detailed design – class design Domain Modeling SE-2030 Dr. Rob Hasker 1 Based on slides written by Dr. Mark L. Hornick Used with permission.
Introduction To System Analysis and Design
1 ITEC 3010 “Systems Analysis and Design, I” LECTURE 10: Use Case Realizations [Prof. Peter Khaiter]
Approaching a Problem Where do we start? How do we proceed?
Cohesion and Coupling CS 4311
SYS466: Analysis and Design Using OO Models Domain Class Diagram.
9 Systems Analysis and Design in a Changing World, Fourth Edition.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Use Case Textual Analysis
Week 9, Day 2 Object-oriented Design Acknowledgement: These slides by Dr. Hasker SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Logical Architecture and UML Package Diagrams. The logical architecture is the large-scale organization of the software classes into packages, subsystems,
Slide design: Dr. Mark L. Hornick
Introduction To DBMS.
Cmpe 589 Spring 2006.
CS 325: Software Engineering
UNIT 1.
Chapter 5: Structural Modeling
Example of a Problem Statement: Introduction into ARENA
SOFTWARE DESIGN AND ARCHITECTURE
System Design Ashima Wadhwa.
Conception OBJET GRASP Patterns
Chapter 11 Object-Oriented Design
Objectives State the reasons for the complexity involved in the development of software Define the following terms Objects Classes Messages Methods Explain.
Copyright © by Curt Hill
CSSSPEC6 SOFTWARE DEVELOPMENT WITH QUALITY ASSURANCE
Datamining : Refers to extracting or mining knowledge from large amounts of data Applications : Market Analysis Fraud Detection Customer Retention Production.
CHAPTER 2 CREATING AN ARCHITECTURAL DESIGN.
MANAGEMENT INFORMATION SYSTEM MEHTAP PARLAK Industrial Engineering Department, Dokuz Eylul University, Turkey 1.
Understand Windows Forms Applications and Console-based Applications
The Object Oriented Approach to Design
SE-2811 Software Component Design
UML Class Diagram.
Introduction to the Unified Modeling Language
Systems Analysis and Design in a Changing World, 6th Edition
Object oriented analysis and design
Starting Design: Logical Architecture and UML Package Diagrams
SYS466 Domain Classes – Part 1.
Design Tips.
Analysis models and design models
ATIS’ Service Oriented Networks (SON) Activity
Chapter 9 Architectural Design.
Objects First with Java A Practical Introduction using BlueJ
Copyright 2007 Oxford Consulting, Ltd
Business Modeling - Domain Analysis
Operating Systems : Overview
State Pattern By the Group of Four.
7. Decorator SE2811 Software Component Design
Operating Systems : Overview
4: Object-oriented Analysis & Design
Basic OOP Concepts and Terms
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
12. Command Pattern SE2811 Software Component Design
11. MVC SE2811 Software Component Design
Use Case Analysis – continued
11. MVC SE2811 Software Component Design
Databases and Information Management
5. Strategy, Singleton Patterns
Chapter 6: Architectural Design
Software Development Process Using UML Recap
Information system analysis and design
Presentation transcript:

3. Object-oriented Design SE2811 Software Component Design Dr. Yoder Acknowledgement: Slides originally by Dr. Hasker 3. Object-oriented Design

How to design object-oriented systems? Null Object Pattern, Adapter Pattern: solving problems in existing systems Open question: how to write systems in the first place? Imagine that you have just discovered an idea for a new web application with an enormous market share What qualities would you want your software to have in ten years? How do we achieve these goals? What were the steps in SE 2030? Steps in SE 2030: write use cases, develop classes from those – some students will know about noun identification

How to identify classes? Meal Wheel As a hungry student, I want my phone to randomly select from different restaurants so I know where to eat. As a picky student, I want my phone to suggest close restaurants that serve sashimi so I can choose a place to eat within 10 minutes walk. As a restaurant owner, I want to distribute menus to potential customers. As a restaurant owner, I want potential customers to know of dietary restrictions that I support so I can attract customers who do not eat particular foods. What classes should be in this system? Why?

Domain classes Solution 1: solution space Solution 2: domain classes Classes that are in a particular solution Possible classes: table of restaurants to GPS coordinates, table of restaurants to menus, table of dietary restrictions to menu items Solution 2: domain classes Classes that are part of the problem space Why prefer domain classes? Solution independent – less likely to change to support new features How would each solution change if we track popularity and wait times? Natural: these are the entities that form the problem to solve The best designs can have both Why prefer domain classes?

How to identify domain classes? Solution 1: just sit there and think them up Solution 2: mine the stories/scenarios/requirements Objects: lead to classes Verbs: actions

Finding classes: Meal Wheel As a hungry student, I want my phone to randomly select from different restaurants so I know where to eat. As a picky student, I want my phone to suggest close restaurants that serve sashimi so I can choose a place to eat within 10 minutes walk. As a restaurant owner, I want to distribute menus to potential customers. As a restaurant owner, I want potential customers to know of dietary restrictions that I support so I can attract customers who do not eat particular foods.

Finding classes: Meal Wheel As a hungry student, I want my phone to randomly select from different restaurants so I know where to eat. As a picky student, I want my phone to suggest close restaurants that serve sashimi so I can choose a place to eat within 10 minutes walk. As a restaurant owner, I want to distribute menus to potential customers. As a restaurant owner, I want potential customers to know of dietary restrictions that I support so I can attract customers who do not eat particular foods.

Other sources of classes Active objects Objects which consume, produce others; objects which control actions Passive objects Data storage, inputs, basic output Example: light switch, sensors, printers Real-world items – domain classes discussed earlier Physical devices – things with internal state to capture Transactions – sales receipt, todo item Persistent information: configuration User interface elements – menus, dialogs

Sound designs Start with domain classes These persist across problem changes Capture things clients, users will recognize Capture requirements that go with those items Explore interactions through sequence and state diagrams Add containers, architectural elements Decisions about time/space/complexity tradeoffs Databases, network communications, GUI elements Introduce design patterns, refine These generally reduce coupling, increase flexibility May REMOVE classes from previous steps Be careful about removing domain classes! Might remove a domain class, but document why, especially where it’s responsibilities have moved

Common mistakes “doit” class: does everything Generally surrounded by lots of passive objects VERY low cohesion System class – no need to document main()! Often becomes a doit class Classes for actions “parser”, “artificial intelligence”, “list maintainer” Roll these into domain objects! Patterns excepted! Poor inheritance If A extends B, then anywhere a B can appear, so can an A Liskov Substitution Principle – see Ch. 5 of Software Design Principles Never violate contracts

How to design object-oriented systems? Null Object Pattern, Adapter Pattern: solving problems in existing systems Open question: how to write systems in the first place? What were the steps in SE 2030? More questions to consider: What makes a system object-oriented? Why are object-oriented designs preferred? What is the alternative to OO? Are some OO systems better than others? Starting point: defining what it means to be “object-oriented” Steps in SE 2030: write use cases, develop classes from those – some students will know about noun identification

What’s an object? What does it mean to say Java is object-oriented? 1st year: oo programming; 2811: object-oriented design So what’s an object? An instance of a class, but what makes a class? A class has state Captures information, provide it on request, record events Student: name, id, classes taking, GPA A class has behavior Operations that do things Student: compute GPA for term, add a class to schedule A class has responsibility What the object provides to the rest of the system Student: record classes taking, progress Ensure discuss: ways

What’s an object? What are the responsibilities of… A house? A roof? door? window? Bank account? Student record in registration system? How many responsibilities should a class have? Could say “just one,” but… What would happen if Student had just one responsibility? Responsibilities: clear, limited, but complete! When would it make sense to have just one responsibility?

Responsibilities are the key to understanding classes, but… What is the responsibility of a PostalAddress object? Address objects have state, behavior, and responsibilities, but… They are not ”real” objects We need another condition With my Unix mindset, I might count milliseconds since Jan. 1, 1970. You might count milliseconds since (or before) your birth.

Responsibilities are the key to understanding classes, but… What is the responsibility of java.util.Date? See first line of Java API Milliseconds from when? If time is a construct, this represents a concept, not a thing Date objects have state, behavior, and responsibilities, but… They are not ”real” objects We need another condition With my Unix mindset, I might count milliseconds since Jan. 1, 1970. You might count milliseconds since (or before) your birth.

What’s an object, continued… An object has identity Something you can point at An address: just text A building: there is a specific building at a specific location Helps distinguish between pieces of information about something (color, name, identification number, temperature) and the things that have that information (people, hurricanes, cars, boats) Objects without identity: attributes Examples: colors, names, addresses, numbers “Red” can appear in multiple places There had better be just one instance of each student in a system

What characterizes an object An object is something with Responsibility Identity Behavior State

What characterizes an object An object is something with Responsibility Identity Behavior State Helps to distinguish objects from attributes

Exercise: construct diagram Meal Wheel As a hungry student, I want my phone to randomly select from different restaurants so I know where to eat. As a picky student, I want my phone to suggest close restaurants that serve sashimi so I can choose a place to eat within 10 minutes walk. As a restaurant owner, I want to distribute menus to potential customers. As a restaurant owner, I want potential customers to know of dietary restrictions that I support so I can attract customers who do not eat particular foods.

Finding classes: Meal Wheel Noun identification method As a hungry student, I want my phone to randomly select from different restaurants so I know where to eat. As a picky student, I want my phone to suggest close restaurants that serve sashimi so I can choose a place to eat within 10 minutes walk. As a restaurant owner, I want to distribute menus to potential customers. As a restaurant owner, I want potential customers to know of dietary restrictions that I support so I can attract customers who do not eat particular foods. Noun identification method Classes: groups of objects w/ RIBS Attributes: simple data Methods: actions on objects

Review Noun identification method Other sources for classes Doit, passive classes and their dangers Liskov Substitution Principle