Object-Oriented Design

Slides:



Advertisements
Similar presentations
Object-Oriented Design
Advertisements

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.
Copyright Irwin/McGraw-Hill Software Design Prepared by Kevin C. Dittman for Systems Analysis & Design Methods 4ed by J. L. Whitten & L. D. Bentley.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
THE OBJECT-ORIENTED DESIGN WORKFLOW Interfaces & Subsystems.
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.
1 Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Requirements Analysis 2 What objects collaborate to achieve the goal of a use case?
Object-Oriented Design
Data Abstraction: The Walls
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.
BACS 287 Basics of Object-Oriented Programming 1.
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
An Object-Oriented Approach to Programming Logic and Design
Chapter 11 Introduction to Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
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.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Diagram Notations
Software Design Designing the overall structure (architecture) of a software system Designing small pieces of computation Designing non-automated processes.
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.
Cohesion and Coupling CS 4311
Systems analysis and design, 6th edition Dennis, wixom, and roth
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
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.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
Object-Oriented Analysis and Design CHAPTERS 9, 31: DOMAIN MODELS 1.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Lecture 13 Law of Demeter. Cohesion Cohesion: the “glue” that holds a module together. Don’t do things that do not support a common goal Cohesion: the.
© 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.
1 Software Design Lecture What’s Design It’s a representation of something that is to be built. i.e. design  implementation.
CS 106 Introduction to Computer Science I 04 / 18 / 2008 Instructor: Michael Eckmann.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
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.
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.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
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.
Programming Logic and Design Fourth Edition, Comprehensive
Software Design Lecture : 9.
Reference This talk is loosely based on the following
Use Case Analysis – continued
ECE 352 Digital System Fundamentals
C++ Object Oriented 1.
Presentation transcript:

Object-Oriented Design

Why is that joke supposed to be funny? Objects and concerns – Objects have a concern in the sense that they have a purpose. Likewise, all code should have a concern, a purpose for being. – A place for every concern… – and every concern in its place.

Concerns of classes Each class should be an entity that performs a certain purpose. – One class usually corresponds to one kind of entity – Each class member usually corresponds to one attribute Only code related to that purpose should be in the class. – Put functions together with the data that they modify. – Put code together if it needs to be modified at the same time.

Concerns of packages Ditto for packages – Every package should have a purpose – Code should be in that package if and only if it is related to that purpose “Module” can refer to a class or to a package – Every module should have a purpose – Code should be in module if and only if related to that purpose

Object-oriented Programming Abstraction – An object contains only the information that we actually care about at this time Encapsulation – An object can call methods that the object performs – The object also hides information that other people don’t care about Inheritance – An object can reuse attributes and methods from another object by being a more specific version Polymorphism – An object can express the same interface as another, but provide a different implementation of that interface that suit its own purpose – Used to ensure that an object reacts to commonly used signals (ex: toString(), equals(), draw())

An example system to support drug and alcohol counseling

What are the key concerns? Survey DB Survey Survey answers Health Information Every answer from patient (ever) Counselee Counselor Create report Postscript Printer Pick up Printout Printout Authen- ticate User ID Last name & PIN

What are the key concerns? A second look at another diagram we’ve made before…

Some key concerns Managing the users – Authenticating counselees – Matching counselees to counselors Performing the survey – Representing the questions – Representing the answers – Performing skip logic – Storing the answers Generating the report – Reading the data – Performing calculations in the report – Sending to the printer

Assigning concerns to code 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

Assigning Concerns to Code When it’s reasonable, objects can do actions (reports print, surveys load, counselees give answers) Some of these “actions” are delegated to other objects though (ex: SurveysLoader, Authenticator)

Coupling and cohesion Coupling – When one module is involved in another module’s concern – i.e. the strength of dependency between modules Cohesion – When a module is devoted to its concern Coupling is about how a module connects to other modules Cohesion is about how the internals relate to each other

Coupling reduces maintainability Levels of coupling – Content coupling (worst) A modifies B – Common coupling A and B both read/write the same data – Control coupling A calls B – Stamp coupling A provides structured data to B – Data coupling A provides unstructured data to B – Uncoupled (best) None of the above If A and B are coupled, then modifying A may require modifying B.

Poor Coupling Report is coupled with SurveysFileReader, SurveysDatabase, and Question SurveysFileReader is stamp coupled with Surveys and Report Question is coupled with Survey and Report

Better Coupling Report depends on Surveys only Inheritance helps change stamp coupling to data coupling

Cohesion increases maintainability Levels of cohesion – Functional/informational cohesion (best) A and B work together for just one purpose – Communicational cohesion A and B use the same data – Procedural cohesion A executes, then B executes, and A & B have vaguely related purpose – Temporal cohesion A executes, then B executes, but A & B do not have any related purpose – Logical cohesion Either A or B might be executed – Coincidental cohesion (worst) None of the above If A is highly cohesive, then it is easy to find the code for a concern.

Bad Cohesion WOAH that user’s doing a lot of stuff.

Reducing Cohesion Increase cohesion by distributing responsibilities to appropriate classes! Counselees fill out questions, Counselors print reports, reports load from surveys, etc.

Split modules to reduce cycles That design had no dependency cycles – But here’s one way to get rid of cycles when they do happen to occur… Pfleeger & Atlee

In reuse, prefer composition over inheritance In general, use composition to add features or to reuse code, and use inheritance to add a new version of an entity.

Tip #4: In reuse, prefer composition over inheritance In general, use composition to add features or to reuse code, and use inheritance to add a new version of an entity.

The secret to using interfaces An interface is a promise – I can do this for you. – If you meet these preconditions, then I can meet these postconditions. Functional or non-functional Polymorphism – If A and B and C and D each implement an interface, then they all make the same promise But may keep the promise in different ways!

Incremental and iterative development Use incremental development – When much of the system’s value resides in one subsection – When one part of the system must be completed (logically) before another Use iterative development – When the system’s value is spread out over much of the system – When the whole system needs to work at least a bit before you can build up

Incremental and iterative development Incremental examples – Adding new kinds of print outs From customers’ standpoint, paper printout carried much of the system’s value – Adding a new data export module Logically, the main system needs to be done before we can worry about exporting data. Iterative examples – Tweaking reports and surveyor user interface to improve usability Improvements to existing pieces of system – Adding new kinds of questions (and answers), changing reports accordingly Changes are spread across system