(26) Design Patterns

(26) Design Patterns - Design patterns CMSC 132:...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 132: Object-Oriented Programming II Design Patterns Department of Computer Science University of Maryland, College Park 2 Design patterns Design patterns are descriptions of reusable solutions to common software design problems They capture the experience of experts: Rationale for design Tradeoffs Codifies design in reusable form Goals: Solve common programming challenges Improve reliability of solutions Aid rapid software development Useful for real-world applications Example: Iterator pattern 3 Observations, con't. Many design patterns may need to fit together Design Patterns (by Gamma et al. 1995, a.k.a. Gang of Four, or GOF) list 23 design patterns There are around 250 well-known OO design patterns Design patterns are used throughout the Java class libraries 4 Documentation format 1. Motivation or context for pattern 2. Prerequisites for using a pattern 3. Description of program structure 4. List of participants (classes and objects) 5. Collaborations (interactions) between participants 6. Consequences of using pattern (good and bad) 7. Implementation techniques and issues 8. Example code 9. Known uses 10. Related patterns
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5 Types of design patterns Creational Deal with the best way to create objects Structural Ways to bring together groups of objects Behavioral Ways for objects to communicate and interact 6 Creational patterns 1. Abstract Factory- creates an instance of several families of classes 2. Builder - separates object construction from its representation 3. Factory Method - creates an instance of several derived classes 4. Prototype – a fully-initialized instance to be copied or cloned 5. Singleton - a class of which only a single instance can exist 7 Structural patterns 6. Adapter - match interfaces of different classes 7. Bridge - separates an object’s interface from its implementation 8. Composite - a tree structure of simple and composite objects 9. Decorator - add responsibilities to objects dynamically 10. Façade - single class that represents an entire subsystem 11. Flyweight - fine-grained instance used for efficient sharing 12. Proxy - object representing another object 8 Behavioral patterns 13. Chain of Responsibility - a way of passing a request between a chain of objects 14. Command - encapsulate a command request as an object 15. Interpreter - a way to include language elements in a program 16. Iterator - sequentially access the elements of a collection 17. Mediator - sefines simplified communication between classes 18. Memento - capture and restore an object's internal state
Background image of page 2
9 Behavioral patterns, con't. 19. Observer - a way of notifying change to a number of classes 20. State - alter an object's behavior when its state changes 21. Strategy - encapsulates an algorithm inside a class 22. Template Method - defer the exact steps of an algorithm to a subclass 23. Visitor - defines a new operation to a class without changing class 10 Iterator pattern Definition
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/16/2011 for the course CMSC 132 taught by Professor Padua-perez during the Fall '08 term at Maryland.

Page1 / 10

(26) Design Patterns - Design patterns CMSC 132:...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online