Object-oriented design CSE 432: Object-Oriented Software Engineering.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Karolina Muszyńska Based on:
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Robert B. Jackson Brigham Young University John W. Satzinger
Ch 12: Object-Oriented Analysis
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Introduction To System Analysis and Design
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 System models.
Component-Level Design
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
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.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
Chapter 1 Principles of Programming and Software Engineering.
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Activity Diagrams and State Charts for detailed modeling Larman, chapters 28 and 29 CSE 432: Object-Oriented Software Engineering Glenn D. Blank.
Introduction To System Analysis and design
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
The Design Discipline.
Systems Analysis and Design in a Changing World, Fifth Edition
Systems Analysis – Analyzing Requirements.  Analyzing requirement stage identifies user information needs and new systems requirements  IS dev team.
1 Object-Oriented Testing CIS 375 Bruce R. Maxim UM-Dearborn.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
Chapter 7 Structuring System Process Requirements
Chapter 4 System Models A description of the various models that can be used to specify software systems.
System models Abstract descriptions of systems whose requirements are being analysed Abstract descriptions of systems whose requirements are being analysed.
An Introduction to Software Architecture
CSCI 6231 Software Engineering Chapter 7 From Modules to Objects
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Introduction To System Analysis and Design
Chapter 7 System models.
System models l Abstract descriptions of systems whose requirements are being analysed.
Pertemuan 19 PEMODELAN SISTEM Matakuliah: D0174/ Pemodelan Sistem dan Simulasi Tahun: Tahun 2009.
Modified by Juan M. Gomez Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
Systems Analysis and Design in a Changing World, 3rd Edition
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
Domain Model Refinement Larman, chapter 31 CSE 432: Object-Oriented Software Engineering Glenn D. Blank, Lehigh University.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
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.
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
7. 2Object-Oriented Analysis and Design with the Unified Process Objectives  Detailed Object-Oriented Requirements Definitions  System Processes—A Use.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Dr D. Greer, Queens University Belfast )Chapter Six 1 Software Engineering Chapter Six Software Design Quality Learning Outcomes.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Systems Analysis and Design in a Changing World, Fourth Edition
Topic 4 - Database Design Unit 1 – Database Analysis and Design Advanced Higher Information Systems St Kentigern’s Academy.
Design. 2 The Need for Software Blueprints Knowing an object-oriented language and having access to a library is necessary but not sufficient in order.
CSCI 3428: Software Engineering Tami Meredith UML Unified Modeling Language.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
 To explain why the context of a system should be modelled as part of the RE process  To describe behavioural modelling, data modelling and object modelling.
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
OBJECT-ORIENTED TESTING. TESTING OOA AND OOD MODELS Analysis and design models cannot be tested in the conventional sense. However, formal technical reviews.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
Engineering, 7th edition. Chapter 8 Slide 1 System models.
Systems Analysis and Design in a Changing World, Fourth Edition
GRASP – Designing Objects with Responsibilities
The Object Oriented Approach to Design
Object-Oriented Analysis
Activity Diagrams and State Charts for detailed modeling
An Introduction to Software Architecture
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Presentation transcript:

Object-oriented design CSE 432: Object-Oriented Software Engineering

Goals of OO analysis (quick review) What are the two main goals of OO analysis? 1) Understand the customer’s requirements 2) Describe problem domain as a set of classes and relationships What techniques have we studied for the 1st goal?  Develop a requirements specification  Describe scenarios of use in user’s language as use cases What techniques have we studied for the 2nd goal?  CRC cards discover classes and run simulations  UML class diagrams represent classes & relationships  Sequence diagrams model dynamic behavior of a system

Goals of OO design OO design develops the analysis into a blueprint of a solution  Where does the “blueprint” metaphor come from? OO design starts by fleshing the class diagrams  Coad & Nicola call this "the continuum of representation principle: use a single underlying representation, from problem domain to OOA to OOD to OOP," i.e., class diagrams  Reworks and adds detail to class diagrams, e.g., attribute types, visibility (public/private), additional constraints  Looks for opportunities for reuse  Addresses performance issues, both for system and users  Designs UI, database, networking, as needed  Designs ADT to describe the semantics of classes in more detail  Develops unit test plans based on class diagrams and ADT design

Four activities of design (Coad) 1) Improve domain analysis: reuse and performance  OOA focuses primarily on the describing problem domain itself  OOD reexamines the domain with an eye to practical concerns  Reuse: factor out common code in abstract classes  Performance tradeoffs: efficiency vs. effectiveness 2) Human interaction: encapsulates user interface  HIC knows how to present data, not how to compute it  Separation of concerns principle: Keep problem domain classes distinct from human interaction classes. Why?  Loose coupling facilitates software reuse and maintenance  An example: the Smalltalk Model-View-Controller framework: model is the problem domain view is the human interface (windows that view the problem domain objects) controller is the mouse or keyboard input, also interacting with P.D. objects  C++ Interviews is two part framework: subject (problem domain) & views (UI)

How does this design illustrate the separation of concerns principle?

Four activities of design (continued) 3) Task management  Multi ‑ tasking and concurrency considerations  How does separation of concerns apply here?  Examples? 4) Data management  Storage and retrieval of external data  Database design (relational or object-oriented)  Or database interface (JDBC, CORBA)  How does separation of concerns apply here?

Reworking the class diagram Add new relations implied in classes  Inverse operations (e.g., undo/redo, getData/setData)  Factor complex behaviors out as classes themselves  If only difference between subclasses is presentation of data, use a service Should we derive HexCount, BinaryCount, OctCount from Count? Rather, add a service, asBase, to present data in different bases Distinguish client (has-a) and inheritance (is-a) relations  Misuse of multiple inheritance is when a derived class is "composed of" several parent classes  I.e., class AIRPLANE has parents WINGS, ENGINE, TAIL)  But the behavior of AIRPLANE is not just the sum of its parts  Bjarne Stroustrup's heuristic: "can it have two?" Then it's a containment, or has-a relation

Reworking the class diagram (continued) Heuristic: use inheritance to extend existing classes  E.g., ComplexMatrix adapts Array or OrderedCltn  But avoid adapting parents for the sake of their heirs (open ‑ closed principle) Generalize common behaviors in abstract classes  E.g., Mouse, Tablet and Keyboard can all inherit behavior from an abstract class, InputDevice Use multiple inheritance for compound classes  TeachingAssistant inherits from both Instructor and Student  Window as a compound of Rectangle (graphical behaviors) and Tree (hierarchical behaviors)  Note: many OO languages don’t support multiple inh.

Classes as active state machines Consider whether a class should keep track of its own internal state  Example from Bertrand Meyer: first cut design of LINKED_LIST class class LINKABLE[T] ‑‑ linkable cells feature value:T; right: LINKABLE[T]; ‑‑ next cell ‑‑ routines to change_value, change_right end; class LINKEDLIST[T] feature nb_elements: INTEGER; first_element: LINKABLE[T]; value(i:INTEGER):T is ‑‑ value of i ‑ th element; loop until it reaches the ith element insert(i:INTEGER; val:T); ‑‑ loop until it reaches ith element, then insert val delete(i:INTEGER); ‑‑ loop until it reaches ith element, then delete it Problems with first ‑ cut? Getting the loops right is tricky (loops are error ‑ prone) Redundancy: the same loop logic recurs in all these routines  Reuse leads to inefficiency: suppose I want a routine search  Find an element then replace it: I'll do the loop twice!  Need some way to keep track of the position I found!  Could return the LINKABLE cell found, but this would ruin encapsulation

Classes as active state machines (cont.) Instead, view LINKED_LIST as a machine with an internal state  Internal state is information stored as attributes of an object What have we added to represent internal state?  Cursor: current position in the list  search(item) routine moves the cursor until it finds item  insert and delete operate on the element pointed at by cursor  How does this simplify the code of insert, delete, etc.?  Client has a new view of LINKED_LIST objects:  l.search(item); ‑‑ find item in l  if not offright then delete end; ‑‑ delete LINKABLE at cursor  Other routines move cursor: l.back; l.forth

Key idea for OOD: data structures can be active  Active structures have internal states, which change  Routines manipulate the object's state What other classes could be designed this way?  Files, random number generators, tokenizers,...  Class as state machine view may not be obvious during analysis  A good reason for redesign!

Case Study: Full ‑ Screen Entry Systems Straightforward data processing application: menu ‑ driven data entry (see overhead)  Each menu comes with a panel of information & lets user choose next action  Interaction during a airline reservation session  Enquiry on flights, information & possible new states Meyer shows different ways to solve problem  goto flow (50's),  functional decomposition (70's)  OO design (90's): improves reusability and extensibility

State diagrams in UML States in ovals, transitions as arrows  Transitions labels have three optional parts: Event [Guard] / Action  Item Received is an event, /get first item is an action, [Not all items checked] is a guard State may also label activities, e.g., do/check item  Actions, associated with transitions, occur quickly and aren’t interruptible  Activities, associated with states, can take longer and are interruptible Definition of “quickly” depends on the kind of system, e.g., real-time vs. info system

Super-states Example shows a super-state of three states Example  Can draw a single transition to and from a super-state  How does this notation make things a bit clearer? Concurrency in state diagrams Concurrency  Dashed line indicates that an order is in two different states, e.g. Checking & Authorizing  When order leaves concurrent states, it’s in a single state: Canceled, Delivered or Rejected When should you create UML state diagrams?

UML package diagrams UML packages for higher level structure (Coad’s subjects) Denoted by box with smaller box on topbox with smaller box on top  Note dependency arrows  A dependency indicates that changes to one element may cause changes to the other Packages can be grouped in higher-order packagesgrouped in higher-order packages  Packages may include packages  Common package as > means all packages in system have dependency to this one  General package marked {abstract} means this package is an interface, with subtypes Heuristic: divide classes into packages; analyze dependencies; refactor to reduce dependencies

Design process procedures Conduct peer reviews at every stage of process  CRC cards: run simulations to discover missing responsibilities  Conduct peer review of class diagrams: does it cover the domain?  Explain design, looking for opportunities for iterative redesign  Contract design: peer review ADTs or assertions  Test design: review plans for unit and acceptance testing Plan testing on a per class basis  Write system and unit test plan descriptions as part of class design  Unit test all public member functions  Test for valid, invalid and boundary cases  System testing follows thorough class testing  See Junit tool for automated test generation supportJunit