Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.

Slides:



Advertisements
Similar presentations
MicroKernel Pattern Presented by Sahibzada Sami ud din Kashif Khurshid.
Advertisements

Object-Oriented Application Frameworks Much of the cost and effort stems from the continuous re- discovery and re-invention of core concepts and components.
Design Patterns Section 7.1 (JIA’s) Section (till page 259) (JIA’s) Section 7.2.2(JIA’s) Section (JIA’s)
CEN Ninth Lecture Introduction to Software Engineering (CEN-4010) Instructor: Masoud Sadjadi Object Design.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns (Lecture I)
1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 17 Object Oriented Design 3.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns.
Chapter 8, Object Design Introduction to Design Patterns
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Reuse Activities Selecting Design Patterns and Components
Computer Science 240 Principles of Software Design.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
OO Frameworks Department of Computer Science Kent State University.
Software Engineering Muhammad Fahad Khan
Design Patterns.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Ceg860 (Prasad)L6MR1 Modularity Extendibility Reusability.
Chapter 2 소프트웨어공학 Software Engineering 임현승 강원대학교
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns 1.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Object Oriented Software Development
Frameworks CompSci 230 S Software Construction.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Dynamic and Selective Combination of Extension in Component-based Applications Eddy Truyen, Bart Vanhaute, Wouter Joosen, Pierre Verbaeten, Bo N. Jørgensen.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Developing Product Line Components Jan Bosch Professor of Software Engineering University of Groningen, Netherlands
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
CS 5150 Software Engineering Lecture 16 Program Design 3.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
COP 3331 Object-Oriented Analysis and Design 1 Design Overview  Design Overview (Ch 6)  Review of RAD  System Design  System Design Concepts  System.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain –The solution domain is changing very rapidly.
Design Patterns: MORE Examples
Chapter 8 Object Design: Reuse and Patterns 1.
Chapter 5:Design Patterns
Design Patterns.
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Advanced Programming Behnam Hatami Fall 2017.
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Introduction to Software Engineering (CEN-4010)
Chapter 8, Object Design: Reuse and Patterns
Structural Patterns: Adapter and Bridge
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Chapter 8, Object Design: Reuse and Patterns
Chapter 8, Object Design: Reuse and Patterns I
Chapter 8, Design Patterns Introduction
From Use Cases to Implementation
Presentation transcript:

Chapter 8 Object Design Reuse and Patterns

Object Design Object design is the process of adding details to the requirements analysis and making implementation decisions The object designer must choose among different ways to implement the analysis model with the goal to minimize execution time, memory and other measures of cost.

Requirements Analysis: Use cases, functional and dynamic model deliver operations for object model Object Design: Iterates on the models, in particular the object model and refine the models Object Design serves as the basis of implementation

Object Design Activities Identification of existing components Full definition of associations Full definition of classes Specifying the contract for each component Choosing algorithms and data structures Identifying possibilities of reuse

Detection of solution-domain classes Optimization Increase of inheritance Decision on control

First part of object design Reuse Concepts The use of inheritance Implementation vs Interface Inheritance Delegation Components

Reuse Concepts Application objects versus solution objects Specification inheritance and implementation inheritance The Liskov Substitution Principle Delegation Delegation and inheritance in design patterns

Application domain vs solution domain objects Application objects, also called domain objects, represent concepts of the domain that are relevant to the system. –They are identified by the application domain specialists and by the end users. Solution objects represent concepts that do not have a counterpart in the application domain, – They are identified by the developers –Examples: Persistent data stores, user interface

Implementation of Application Domain Classes New objects are often needed during object design: –The use of design patterns introduces new classes –The implementation of algorithms may necessitate objects to hold values –New low-level operations may be needed during the decomposition of high-level operations

Observation about Modeling of the Real World [Gamma et al 94]: Strict modeling of the real world leads to a system that reflects today’s realities but not necessarily tomorrow’s. There is a need for reusable and flexible designs Design knowledge complements application domain knowledge and solution domain knowledge.

The use of inheritance Inheritance is used to achieve two different goals –Description of Taxonomies –Interface Specification Identification of taxonomies –Used during requirements analysis. –Activity: identify application domain objects that are hierarchically related –Goal: make the analysis model more understandable

Service specification –Used during object design –Activity: –Goal: increase reusability, enhance modifiability and extensibility Inheritance is found either by specialization or generalization

Metamodel for Inheritance Inheritance Specification (Interface) Inheritance Implementation Inheritance for Reuse Taxonomy Inheritance detected by generalization Inheritance detected by specialization Analysis activity Object Design

Taxonomy Example Mammal Tiger Wolf Whale

Implementation Inheritance A very similar class is already implemented that does almost the same as the desired class implementation.

 Problem with implementation inheritance: Some of the inherited operations might exhibit unwanted behavior. What happens if the Stack user calls Remove() instead of Pop()?  Example: I have a List class, I need a Stack class. How about subclassing the Stack class from the List class and providing three methods, Push() and Pop(), Top()? Add() Remove() List Push() Pop() Stack Top() “Already implemented” Implementation Inheritance

Implementation Inheritance vs Interface Inheritance Implementation inheritance –Also called class inheritance –Goal: Extend an applications’ functionality by reusing functionality in parent class –Inherit from an existing class with some or all operations already implemented

Interface inheritance –Also called subtyping –Inherit from an abstract class with all operations specified, but not yet implemented

Delegation as alternative to Implementation Inheritance Delegation is a way of making composition as powerful for reuse as inheritance In Delegation two objects are involved in handling a request –A receiving object delegates operations to its delegate. –The developer can make sure that the receiving object does not allow the client to misuse the delegate object

Client Receiver Delegate Delegates to calls Delegation as alternative to Implementation Inheritance

Delegation instead of Implementation Inheritance Inheritance: Extending a Base class by a new operation or overwriting an operation. Delegation: Catching an operation and sending it to another object. Which of the following models is better for implementing a stack?

Delegation instead of Implementation Inheritance +Add() +Remove() List Stack +Push() +Pop() +Top() +Push() +Pop() +Top() Stack Add() Remove() List

Many design patterns use a combination of inheritance and delegation Lecture on Design Patterns

Component Selection Select existing –off-the-shelf class libraries – frameworks or –components Adjust the class libraries, framework or components –Change the API if you have the source code. –Use the adapter or bridge pattern if you don’t have access

Frameworks A framework is a reusable partial application that can be specialized to produce custom applications. Frameworks are targeted to particular technologies The key benefits of frameworks are reusability and extensibility.

–Reusability leverages of the application domain knowledge and prior effort of experienced developers –Extensibility is provided by hook methods, which are overwritten by the application to extend the framework. Hook methods systematically decouple the interfaces and behaviors of an application domain from the variations required by an application in a particular context.

White-box and Black-Box Frameworks Whitebox frameworks: –Extensibility achieved through inheritance –Existing functionality is extended by subclassing framework base classes and overriding predefined hook methods

Blackbox frameworks –Extensibility achieved by defining interfaces for components that can be plugged into the framework. –Existing functionality is reused by defining components that conform to a particular interface –These components are integrated with the framework via delegation.

Class Libraries and Frameworks Class Libraries: –Less domain specific –Provide a smaller scope of reuse. –Class libraries are passive; no constraint on control flow. Framework: –Classes cooperate for a family of related applications. –Frameworks are active; affect the flow of control.

In practice, developers often use both: –Frameworks often use class libraries internally to simplify the development of the framework. –Framework event handlers use class libraries to perform basic tasks (e.g. string processing, file management, numerical analysis…. )

Reuse Main goal: –Reuse knowledge from previous experience to current problem –Reuse functionality already available Composition (also called Black Box Reuse) –New functionality is obtained by aggregation –The new object with more functionality is an aggregation of existing components

Inheritance (also called White-box Reuse) –New functionality is obtained by inheritance. Three ways to get new functionality: Implementation inheritance Interface inheritance Delegation