Object-Oriented Design. 1 Objects and concerns Objects have a concern, meaning they have a purpose Not concerned as in worried All code should have a.

Slides:



Advertisements
Similar presentations
Object-Oriented Software Engineering Visual OO Analysis and Design
Advertisements

Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Architecture. Outline Example Decomposition Style Activity 1.
Diagram Notations
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Object-Oriented Design
1 Software Design Introduction  The chapter will address the following questions:  How do you factor a program into manageable program modules that can.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Diagram Notations
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
Lecturer: Dr. AJ Bieszczad Chapter 66-1 Object-Oriented analysis and design Special nature of OO development Use cases Design with UML OO system design.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
Requirements Analysis 2 What objects collaborate to achieve the goal of a use case?
Object-Oriented Design
PVK-Ht051 Contents Introduction Requirements Engineering Project Management Software Design Detailed Design and Coding Quality Assurance Maintenance.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Use Case Analysis – continued
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Objectives Design Class Diagrams Issues in system design Generalization Review UML papers.
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
Chapter 7 Software Engineering Objectives Understand the software life cycle. Describe the development process models.. Understand the concept of modularity.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
An Object-Oriented Approach to Programming Logic and Design
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Design (1) Design involves decisions on how to deliver the agreed functionality to the users. Design involves development of a clear, unambiguous and consistent.
Diagram Notations
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
Design Patterns. Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution.
In-Class Interviewing Activity (Grocery example) You can conduct a semi-structured/unstructured interview: How: Use the process outlined here. Individually.
Cohesion and Coupling CS 4311
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Coupling Cohesion Chandan R. Rupakheti Steve Chenoweth (Chapter 18)
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
CCSB223/SAD/CHAPTER131 Chapter 13 Designing the System Internals.
Object-Oriented Design
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Design CIS 4800 Kannan Mohan Department of CIS Zicklin School of Business, Baruch College Copyright © 2009 John Wiley & Sons, Inc. Copyright © 2008 Course.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Notations. Requirements Documentation Typical parts of Requirements Document Functional requirements Behavior of the software system Nonfunctional requirements.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CSCI 3428: Software Engineering Tami Meredith Chapter 6 Designing the Modules.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
1 Week 7 Software Engineering Spring Term 2016 Marymount University School of Business Administration Professor Suydam.
School of Business Administration
Coupling and Cohesion Rajni Bhalla.
Coupling and Cohesion 1.
Cohesion and Coupling Chapter 5, Pfleeger 01/01/10.
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
Improving the Design “Can the design be better?”
Software Design CMSC 345, Version 1/11.
Programming Logic and Design Fourth Edition, Comprehensive
Software Design Lecture : 9.
Diagram Notations
Presentation transcript:

Object-Oriented Design

1

Objects and concerns Objects have a concern, meaning they have a purpose Not concerned as in worried All code should have a purpose 2 Why is that joke supposed to be funny?

Classes Each class should have a clear purpose One class usually corresponds to one kind of entity Each class member corresponds to one attribute Only code related to that purpose goes in class Functions for data that they modify Code that needs to be modified at the same time 3

Software Packages Every software package should have a purpose Code in software package iff relates to purpose (iff -> if and only if) “Module” can refer to either a class or package Every module should have a purpose Code in module iff relates to purpose 4

5 Example: Drug and Alcohol Counseling

6 Survey DB Survey Survey answers Health Information All this patient’s answers (ever) Counselee Counselor Create report Postscript Printer Pick up Printout Printout Authen ticate User ID Last name & PIN What are the key concerns?

Key Concerns of Counseling Example Managing the users Performing the survey Generating the report 7

Key Concerns of Counseling Example Managing the users Authenticating counselees Matching counselees to counselors Performing the survey Generating the report 8

Key Concerns of Counseling Example Managing the users Performing the survey Representing the questions Representing the answers Storing answers Allowing skips Generating the report 9

Key Concerns of Counseling Example Managing the users Performing the survey Generating the report Reading the data Performing calculations of the report Sending to printer 10

UML Diagram (Review) One box per entity Usually lists attributes Interfaces and abstractions italicized Lines without arrowheads show references Represents member variables in OO Labeled with cardinality Lines with open arrowheads for specialization Lines with regular arrowheads for dependencies 11

12 Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Simple UML Diagram note: UML details omitted for clarity

13 Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Organize into Packages Data Records Authenticator Survey Report

Coupling and Cohesion Coupling When one module is involved in another module’s concern Cohesion When a module is devoted to its own concern 14

Levels of Coupling Content (worst) A modifies B Common Control Stamp Data Uncoupled (best) Coupling reduces maintainability! 15 A A B B modifies

Levels of Coupling Content (worst) Common A and B read/write same data Control Stamp Data Uncoupled (best) Coupling reduces maintainability! 16 A A B B data read/write

Levels of Coupling Content (worst) Common Control A calls B Stamp Data Uncoupled (best) Coupling reduces maintainability! 17 A A B B calls

Levels of Coupling Content (worst) Common Control Stamp A provides structured data to B Data Uncoupled (best) Coupling reduces maintainability! 18 A A B B structured data

Levels of Coupling Content (worst) Common Control Stamp Data A provides unstructured data to B Uncoupled (best) Coupling reduces maintainability! 19 A A B B unstructured data

Levels of Coupling Content (worst) Common Control Stamp Data Uncoupled (best) None of the above Coupling reduces maintainability! 20 A A B B

21 Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Inter-package Couplings? Data Records Authenticator Survey Report content: A modifies B common: A / B read/write same data control: A calls B stamp: A -> B structured data data: A->B unstructured data uncoupled

Levels of Cohesion Functional / informational (best) A and B work together for one purpose Communicational Procedural Temporal Logical Coincidental (worst) Cohesion increases maintainability 22 A A B B one purpose one purpose

Levels of Cohesion Functional / informational (best) Communicational A and B use the same data Procedural Temporal Logical Coincidental (worst) Cohesion increases maintainability 23 A A B B data

Levels of Cohesion Functional / informational (best) Communicational Procedural A executes, then B executes… A & B have vaguely related purpose Temporal Logical Coincidental (worst) Cohesion increases maintainability 24 A A B B purpose time

Levels of Cohesion Functional / informational (best) Communicational Procedural Temporal A executes, then B executes… A & B have NO related purpose Logical Coincidental (worst) Cohesion increases maintainability 25 A A B B time

Levels of Cohesion Functional / informational (best) Communicational Procedural Temporal Logical Either A or B might be executed Coincidental (worst) Cohesion increases maintainability 26 A A B B A ∨ B

Levels of Cohesion Functional / informational (best) Communicational Procedural Temporal Logical Coincidental (worst) None of the above Cohesion increases maintainability 27 A A B B

Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Intra-package Cohesion? Functional: A&B have one purpose Communicational: A&B share same data Procedural: A runs, then B, related Temporal: A runs, then B, unrelated Logical: either A or B might be executed No cohesion

Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Tip #1: “Don’t talk to strangers” This would be bad:

Counselee Rec. Counselor Rec. Survey Instance Questions Answers Authenticator Report Maker Survey Server Question loader Skip logic module Answer storer Data loader Calculation module Printer controller Tip #2: Move Code to Where It’s Used Reduce inter-package coupling

Tip #3: Split Modules to Reduce Cycles Our example had no cycles But here’s a way to correct them: 31

Tip #4: In Reuse, Prefer Composition over Inheritance Use composition to add features or to reuse code Use inheritance to add a new version of an entity 32 Survey Instance Questions Answers Survey Server Question loader Skip logic module Answer storer Timing data Answer check Logging module

Tip #4: In Reuse, Prefer Composition over Inheritance Use composition to add features or to reuse code Use inheritance to add a new version of an entity Survey Instance Questions Answers numeric question multiple choice question multiple choice question free-text question numeric answer multiple choice answer multiple choice answer free-text answer

Interface and Polymorphism An interface is a promise: I can provide this output if you provide a valid input If you can meet these preconditions, then I can meet these postconditions Polymorphism: If A, B, C, and D provide same interface, then they all make the same promise May keep the promise in different ways 34

Incremental vs. Iterative Use incremental development when: Much of the system’s value resides in one subsection One part of the system must be completed (logically) before another Use iterative development when: System’s value is spread out over much of the system The whole system needs to work before you can build it up 35

Incremental Examples Adding new kinds of print outs Printout carries much of system’s value Adding a new data export module Logically, main system needs to work before worrying about exporting data 36

Iterative Examples Tweaking reports and user interface (surveyor) to improve usability Improvements to existing system pieces Adding new kinds of questions (and answers), changing reports Changes spread across system 37