GoF Structural Patterns-Object-Oriented Design-Lecture 21 Slides-Computer Engineering, Slides of Object Oriented Analysis and Design

GoF Structural Patterns, Adapter, Bridge, Composite, Decorator, Facade, Proxy, UML, Structural Patterns, Raman Ramsin, Lecture Slides, Object Oriented Design, Department of Computer Engineering, Sharif University of Technology, Iran.

Typology: Slides

2011/2012

Uploaded on 02/19/2012

hester
hester 🇮🇷

4.5

(13)

84 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Department of Computer Engineering 1 Sharif University of Technology
Object-Oriented Design
Lecturer: Raman Ramsin
Lecture 21
GoF Design Patterns Structural
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download GoF Structural Patterns-Object-Oriented Design-Lecture 21 Slides-Computer Engineering and more Slides Object Oriented Analysis and Design in PDF only on Docsity!

Department of Computer Engineering

Sharif University of Technology

Object-Oriented Design

Lecturer: Raman Ramsin

Lecture 21

GoF Design Patterns – Structural

Department of Computer Engineering

Sharif University of Technology

GoF Structural Patterns  Class/ObjectAdapter: Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.  ObjectBridge: Decouple an abstraction from its implementation so that the two can vary independently.  Composite: Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.  Decorator: Attach additional responsibilities to an object dynamically.  Façade: Provide a unified interface to a set of interfaces in a subsystem.  Flyweight: Use sharing to support large numbers of fine-grained objects efficiently.  Proxy: Provide a surrogate or placeholder for another object to control access to it.

Department of Computer Engineering

Sharif University of Technology

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.  (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.

Department of Computer Engineering

Sharif University of Technology

Adapter (Class): Structure

Department of Computer Engineering

Sharif University of Technology

Bridge  Intent:  Decouple an abstraction from its implementation so that the two can vary independently.

Department of Computer Engineering

Sharif University of Technology

Bridge: Applicability  Use the Bridge pattern when  you want to avoid a permanent binding between an abstraction and its implementation; for example, when the implementation must be selected or switched at run-time.  both the abstractions and their implementations should be extensible by subclassing; combine different abstractions and implementations and extend them independently.  changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled.  (C++) you want to hide the implementation of an abstraction completely from clients. In C++ the representation of a class is visible in the class interface.  you want to share an implementation among multiple objects and this fact should be hidden from the client.

Department of Computer Engineering

Sharif University of Technology

Composite  Intent:  Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Department of Computer Engineering

Sharif University of Technology

Composite: Applicability  Use the Composite pattern when  you want to represent whole-part- hierarchies of objects.  you want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly.

Department of Computer Engineering

Sharif University of Technology

Composite: Typical Object Structure

Department of Computer Engineering

Sharif University of Technology

Decorator  Intent:  Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Department of Computer Engineering

Sharif University of Technology

Decorator: Applicability  Use the Decorator pattern  to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects.  for responsibilities that can be withdrawn.  when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses.

Department of Computer Engineering

Sharif University of Technology

Decorator: Structure

Department of Computer Engineering

Sharif University of Technology

Façade: Class Hierarchy

Department of Computer Engineering

Sharif University of Technology

Façade: Applicability  Use the Façade pattern when  you want to provide a simple interface to a complex subsystem.  there are many dependencies between clients and the implementation classes of an abstraction.  you want to layer your subsystems. Use a facade to define an entry point to each subsystem level.