290 likes | 298 Views
This lecture covers the topics of object design, reuse, and design patterns in software systems. It discusses the purpose of object design, the concept of reuse, interface specifications, object model restructuring, and the Liskov Substitution Principle. It also introduces various design patterns and application frameworks.
E N D
CS 509Design of Software Systems Lecture #5 Monday, Feb. 23, 2004 CS 509 - WPI
Class Format for Today • Term Project Administration • Changes to Course Material • Questions • Quiz #3 • Review of Chapters 8 & 9: • In-class Exercise: • Requirements for new design project CS 509 - WPI
Term Project Administration • Return Phase 2 – Functional Specifications • And Journals • Return Quiz #2 • About Phase 3: • How is the project progressing? • Can we continue as planned? • System & Object Design for CTS due next week • Have you started object design, or do you prefer to just focus on system design? CS 509 - WPI
Changes to Course Material • Next week start on a new project to design • Home Inventory System (thanks to Michael) • Discuss requirements later tonight • Presentations or 2 phases for last month? • Readings & lecture topics: • Read Chapter 10 for next week • New assignments will be posted to web site • Discuss possible topics for CS562 CS 509 - WPI
Questions? • About what was covered last time • From the reading • About the Term Project • Anything else? CS 509 - WPI
Quiz #3 Chapters 7, 8, 9 You have 15 minutes CS 509 - WPI
Chapter 8 Object Design: Reusing Pattern Solutions CS 509 - WPI
Overview of Activities • Reuse (Chapter 8) • Pick off-the-shelf components & design patterns • Service specification (Chapter 9) • Precisely describe each class interface • Object model restructuring (Chapter 10) • Improve understandability & extensibility • Optimizations to address performance criteria (time, memory, etc.) CS 509 - WPI
Purpose of Object Design • Close the gap between application objects and selected hardware/software platforms • Identify missing functionality not covered by system design • Construct precise specifications of classes, attributes and operations • Produce a model from which a set of classes can be implemented by individual developers CS 509 - WPI
Reuse • Off-the-shelf components identified during system design need to be integrated • Class libraries & 3rd party components selected for basic data structures & services • Wrapping components with custom objects • Refining them using inheritance • Design patterns selected for solving common problems & isolating the effects of change CS 509 - WPI
Interface Specifications • Subsystem services identified during system design specified in terms of class interfaces • Operations & Arguments • Type signatures • Constraints & Exceptions • Identify operations & objects needed to transfer data among subsystems CS 509 - WPI
Restructuring • Transforming & optimizing the object model should occur after classes & objects have been designed & interfaces fully specified • Often design activities can get side-tracked by optimization concerns • Focusing on interfaces, components & design patterns results in a more flexible design model • Focusing on optimizations first tends to produce design model that is rigid & difficult to modify CS 509 - WPI
Reuse Concepts • Application Objects vs. Solution Objects • Inheritance vs. Delegation • The Liskov Substitution Principle • Design Patterns • Application Frameworks CS 509 - WPI
Application & Solution Objects • Application domain objects come from the requirements & analysis • Boundary, Control, Entity • Represent concepts in the problem domain • Solution objects developed during design • Represent concepts with no counterparts in the problem domain CS 509 - WPI
Inheritance vs. Delegation • Review Set/Hashtable example on pgs 310-311 • Discuss distinction between inheritance and delegation • Which one is better? Why? • Is it a general rule, or better only in this case? • Are there cases where the other is better? • How does inheritance relate to taxonomy? CS 509 - WPI
Liskov Substitution Principle “If an object of type S can be substituted in all the places where an object of type T is expected, then S is a subtype of T. • Who can interpret what this means? • Examples? CS 509 - WPI
Intro to Design Patterns • Purpose: • Template solutions to recurring problems • History: • Patterns evolve over time • Refined for maximizing reuse & flexibility • Capture Knowledge: • Document context & trade-offs • Provide guidance about when to use inheritance vs. delegation CS 509 - WPI
Design Pattern Participants • Client Class • Accesses the pattern • Pattern Interface • Part of pattern that is visible to the client • Implementor Class(es) • Provides low-level behavior (may be > 1) • Extender Class • Provides a specialized implementation or extended behavior CS 509 - WPI
Design Patterns • Adapter • Bridge • Strategy • Abstract Factory • Command • Composite CS 509 - WPI
Application Frameworks • Terminology: • Hook Method • Infrastructure Framework • Middleware Framework • Enterprise Application Framework • White Box Framework • Black Box Framework CS 509 - WPI
Chapter 9 Object Design: Specifying Interfaces CS 509 - WPI
Activities Overview • Identify missing attributes & operations • Specify type signatures & visibility • Specify contracts on classes & methods CS 509 - WPI
Interface Spec. Concepts • Participants: • Class implementor • Class extender • Class user (client) • Types, signatures & visibility • Contracts on classes and methods: • Invariants, pre- and post-conditions CS 509 - WPI
Participants • Class Implementor • Realizes the class • Class User (Client) • Invokes operations provided by the class • Class Extender • Develops specializations of the class CS 509 - WPI
Types, Signatures & Visibility • Type specifies range of valid values: • For attribute, parameters & method return • Examples? • Signature specifies method: • Name, param types, return type • Visibility specifies who can see what • Private, protected, public • What does each mean? CS 509 - WPI
Contracts on Classes, Methods • Invariants • Predicate true for all instances of a class • Pre-conditions • Predicate true before an operation is invoked • Post-conditions • Predicate true after an operation has completed • Purpose? • Examples? CS 509 - WPI
Object Constraint Language • Formal language for specifying contracts • Constraints should be specified in design document, but may be done more informally • Contracts should also be documented in code, using comments. • See example code on page 358 CS 509 - WPI
In-class Exercise Requirements for Home Inventory System CS 509 - WPI
For Next Time • Phase 3 due (Design Documents) • Read Chapter 10 – Mapping Models to Code • Check course web site for updates • Syllabus • Reading material • Term project • I will send email to the class when updated CS 509 - WPI