Structural Design Patterns

Slides:



Advertisements
Similar presentations
Matt Klein. Decorator Pattern  Intent  Attach Additional responsibilities to an object by dynamically. Decorators provide a flexible alternative to.
Advertisements

1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 14 Structural Design Patterns SWE 316: Software Design and Architecture.
Chapter 6: Using Design Patterns
Façade Pattern Jeff Schott CS590L Spring What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
Client/Server Software Architectures Yonglei Tao.
Design Patterns.
ADAPTER PATTERN BY Sravanthi Karumanchi. Structure Pattern Structure patterns are concerned with how classes and objects are composed to form large structures.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
1 The Proxy Design Pattern Problem: Defer the cost of object creation and init. until actually used Applicability (possible contexts): – Virtual Proxy:
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Patterns: Structural Design Patterns
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Facade Introduction. Intent Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
GoF: Document Editor Example Rebecca Miller-Webster.
SDP Structural Pattern. SDP-2 Structural Patterns Concerned with how classes and objects are composed to form large structures Class Patterns use.
ECE450S – Software Engineering II
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IV Structural Patterns.
Design Patterns Structural Patterns. Adapter Convert the interface of a class into another interface clients expect Adapter lets classes work together.
Proxy, Observer, Symbolic Links Rebecca Chernoff.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Proxy.
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 Advanced Object-oriented Design – Principles and Patterns Structural Design Patterns.
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
Structural Design Patterns Yaodong Bi October 25, 2005.
Design Patterns: Structural Design Patterns General and reusable solutions to common problems in software design Software University
The Proxy Pattern (Structural) ©SoftMoore ConsultingSlide 1.
S.Ducasse Stéphane Ducasse 1 Adapter.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Presented by FACADE PATTERN
Design Patterns: MORE Examples
Abstract Factory Pattern
Façade Pattern:.
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Structural Patterns Structural patterns control the relationships between large portions of your applications. Structural patterns affect applications.
Common Design Patterns
Design Patterns Lecture part 2.
Factory Patterns 1.
Introduction to Design Patterns
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
object oriented Principles of software design
Abstract Factory Pattern
Decorator Design Pattern
Intent (Thanks to Jim Fawcett for the slides)
Design Patterns Satya Puvvada Satya Puvvada.
Object Oriented Design Patterns - Structural Patterns
UNIT-III Structural Design Patterns
Structural Patterns: Adapter and Bridge
Informatics 122 Software Design II
Software Design Lecture 10.
Presentation transcript:

Structural Design Patterns

Objectives To introduce structural design patterns Facade Decorator Composite Adapter Flyweight Proxy

Facade Design Pattern Design Purpose Design Pattern Summary Provide an interface to a package of classes. Design Pattern Summary Define a singleton which is the a means for obtaining functionality from the package.

Facade: Motivation Clients communicate with the package (subsystem ) by sending requests to Facade, which forwards them to the appropriate package object(s).

Facade: Applicability To provide simple interface to a complex package, which is useful for most clients. To reduce the dependencies between the client and the package, or dependencies between various packages.

Facade: Structure

Facade: Sequence Diagram

Facade: Consequences It shields clients from package components, thereby reducing the number of objects that clients deal with and making the package easier to use. It promotes weak coupling between the package and its clients and other packages, thereby promoting package independence and portability. It doesn't prevent applications from using package classes if they need to.

Decorator Design Pattern Design Purpose Add responsibilities to an object at runtime. Design Pattern Summary Provide for a linked list of objects, each encapsulating responsibility.

Text View Example

Decorator: Class Model Decorator creates an aggregated linked list of Decoration objects ending with the basic Substance object.

Linked Objects in Decorator

Decorator: Sequence Diagram

Text View Example

Text View Example (Cont’d)‏

Decorator: Consequences Why use Decorator when a simple vector of Component objects seems to suffice? Instead of simple interface with a single Component object that Decorator provides, the client would have to know about the subclasses Substance and Decoration, thereby making the client code more specialized. If other classes replaced Substance or Decoration, the client code would have to change. This is not the case when Decorator is used. Therefore, Decorator would make the client’s interface more flexible.

Composite Design Pattern Design Purpose Represent a Tree of Objects. Design Pattern Summary Use a Recursive Form in which the tree class aggregates and inherits from the base class for the objects.

Composite: Class Model

Composite: Sequence Diagram

Bank/Teller Example

Composite: Consequences Defines class hierarchies consisting of primitive objects and composite objects. Makes the client simple. Makes it easier to add new kinds of components.

Adapter Design Pattern Design Purpose Allow an application to use external functionality in a retargetable manner. Design Pattern Summary Write the application against an abstract version of the external class; introduce a subclass that aggregates the external class.

Adapter: Applicability Use the Adapter pattern when you want to use an existing class, and its interface does not match the one you need. you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces.

Adapter: Class Model Adapter is based on the delegation form because an Adapter object delegates the command to the targeted command.

Adapter: Sequence Diagram

Financial Application Example

Adapter: Consequences Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Flyweight Design Pattern Design Purpose Manage a large number of objects without constructing them all. Design Pattern Summary Share representatives for the objects; use context to obtain the effect of multiple instances.

Flyweight: Class Model

Flyweight: Sequence Diagram

Text Magnifier Example

Text Magnifier Example (Cont’d)‏

Text Magnifier Example (Cont’d)‏

Flyweight: Consequences Space savings increase as more flyweights are shared.

Proxy Design Pattern Proxy Proxy Design Purpose Design Pattern Summary A class functioning as an interface to something else Proxy Design Purpose Avoid the unnecessary execution of expensive functionality like object creation or initialization in a manner transparent to clients. Design Pattern Summary Interpose a substitute class which accesses the expensive functionality only when required.

Proxy Usage Contexts Virtual Proxy Cache Proxy Remote Proxy Create an expensive object on demand (lazy construction) Cache Proxy Hold results temporarily Remote Proxy Use a local representative for a remote object (different address space) Protection Proxy Control access to shared object

Proxy: Class Model

Proxy: Sequence Diagram

Telephone Record Example of Cache Proxy

Telephone Record Example (Cont’d)‏

Proxy: Consequences Proxy promotes: Efficiency: avoids time-consuming operations when necessary. Correctness: separates design and code that are independent of retrieval/efficiency from parts concerned with this issue. Reusability: design and code that are independent of retrieval efficiency are most likely to be reusable. Flexibility: we can replace one module concerned with retrieval with another. Robustness: isolates parts that check for the validity of retrieved data. The penalties we pay can sometimes be too high: If the proxy forces us to keep very large amount of data in the memory and its use is infrequent.

Summary of Structural Design Patterns Structural Design Patterns relate objects (as trees, lists etc.)‏ Facade provides an interface to collections of objects Decorator adds to objects at runtime Composite represents trees of objects Adapter simplifies the use of external functionality Flyweight gains the advantages of using multiple instances while minimizing space penalties Proxy avoids calling expensive operations unnecessarily