This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Object-Oriented Desgin Structural Patterns George Blankenship 1 Structural Patterns George Blankenship 1 CSCI 253 Object Oriented Design: Structural Patterns George Blankenship Structural Patterns George Blankenship 2 Overview Creational Patterns ¡ Singleton ¢ Abstract factory ¢ Factory Method ¢ Prototype ¢ Builder Structural Patterns ¢ Composite ¢ Façade ¢ Proxy ¢ Flyweight ¡ Adapter ¡ Bridge ¡ Decorator Behavioral Patterns ¡ Chain of Respons. ¡ Command ¡ Interpreter ¢ Iterator ¡ Mediator ¡ Memento ¢ Observer ¢ State ¢ Strategy ¡ Template Method ¢ Visitor Structural Patterns George Blankenship 3 Structural Patterns • The Adapter pattern, used to change the interface of one class to that of another one. • The Bridge pattern, intended to keep the interface to your client program constant while allowing you to change the actual kind of class you display or use. You can then change the interface and the underlying class separately. • The Composite pattern, a collection of objects, any one of which may be either itself a Composite, or just a primitive object. • The Decorator pattern, a class that surrounds a given class, adds new capabilities to it, and passes all the unchanged methods to the underlying class. • The Façade pattern, which groups a complex object hierarchy and provides a new, simpler interface to access those data. • The Flyweight pattern, which provides a way to limit the proliferation of small, similar class instances by moving some of the class data outside the class and passing it in during various execution methods. • The Proxy pattern, which provides a simple place-holder class for a more complex class which is expensive to instantiate. Object-Oriented Desgin Structural Patterns George Blankenship 2 Structural Patterns George Blankenship 4 The Adapter Pattern: The Problem Provide an Interface for to remap the interface of an existing class to expected interface of another existing class- Linked List – each object is a list entry (extends ListEntry)- List of objects – none of the object are required to extend LinkEntry Also known as : Wrapper Linked List List of Objects Structural Patterns George Blankenship 5 Motivation • Sometimes a toolkit or class library can not be used because its interface is incompatible with the interface required by an application • We can not change the library interface, since we may not have its source code • Even if we did have the source code, we probably should not change the library for each domain-specific application Structural Patterns George Blankenship 6 Link List • Two classes to create and maintain linked lists – ListHead (control object for a linked list) – ListEntry (entries that can be placed on list) – Objects that extend ListEntry can be placed on any linked list – Objects that do not, cannot • Should all classes extend LinkList?...
View Full Document
- Spring '10
- Design pattern, Software design patterns, George Blankenship, structural patterns