Documente Academic
Documente Profesional
Documente Cultură
MSRIT-ISE SDP 1
A technique to repeat designer success. Borrowed from Civil and Electrical Engineering domains.
MSRIT-ISE
SDP
Context: The general situation in which the pattern applies. Problem: A short sentence or two raising the main difficulty. Forces: The issues or concerns to consider when solving the problem. Solution: The recommended way to solve the problem in the given context.
MSRIT-ISE SDP 3
Designer
Programmer
Reduce gap
Design
Implementation
MSRIT-ISE
SDP
Creational Patterns concern the process of object creation. Structural Patterns concern with integration and composition of classes and objects. Behavioral Patterns concern with class or object communication.
SDP 5
MSRIT-ISE
Abstract Factory: Factory for building related objects Builder: Factory for building complex objects incrementally Factory Method: Method in a derived class creates associates Prototype: Factory for cloning new instances from a prototype Singleton: Factory for a singular (sole) instance
SDP 6
MSRIT-ISE
Adapter: Translator adapts a server interface for a client Bridge: Abstraction for binding one of many implementations Composite: Structure for building recursive aggregations Decorator: Decorator extends an object transparently Facade: Simplifies the interface for a subsystem Flyweight: Many fine-grained objects shared efficiently. Proxy: One object approximates another
SDP 7
MSRIT-ISE
Chain of Responsibility: Request delegated to the responsible service provider Command: Request is first-class object Iterator: Aggregate elements are accessed sequentially Interpreter: Language interpreter for a small grammar Mediator: Coordinates interactions between its associates Memento: Snapshot captures and restores object states privately
SDP 8
MSRIT-ISE
Observer: Dependents update automatically when subject changes State: Object whose behaviour depends on its state Strategy: Abstraction for selecting one of many algorithms Template Method: Algorithm with some steps supplied by a derived class Visitor: Operations applied to elements of a heterogeneous object structure
MSRIT-ISE
SDP
Purpose
Creational
Factory method Abstract factory Builder Prototype Singleton
Structural
Adapter (class) Adapter (object) Bridge Composite Decorator Faade Flyweight Proxy
Describe algorithms and flow control
Behavioral
Interpreter Template method Chain of responsibility Command Iterator Mediator Memento Observer State Strategy Visitor
10
Scope
Class Object
MSRIT-ISE
SDP
The class Facade is introduced as an interface to the whole subsystem. Any client class needs a service from any of the subsystem classes will be send the request to the facade class.
MSRIT-ISE
SDP 11
11
Design Patterns produce quality designs by reducing coupling Example of how a Faade Pattern reduces coupling
MSRIT-ISE
SDP
12
MSRIT-ISE
SDP
13
MSRIT-ISE
SDP
14
When an object changes its state, all its dependants are notified.
MSRIT-ISE
SDP
15
Internet
Cricinfo Server
MSRIT-ISE
SDP
16
MSRIT-ISE
SDP
17
Eg: JNI helps JVM to use Libraries written in other Languages such as c, c++ etc.
Java module
C++ module
MSRIT-ISE
SDP
18
MSRIT-ISE
SDP
19
MSRIT-ISE
SDP
20
Event handling in Java GUI components is unimplemented. Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
MSRIT-ISE
SDP
21
When we have only one instance for class. We simply solve our problem using Singleton Pattern
Static UniqueInstance
MSRIT-ISE
SDP
22
ConcreteComponent Operation()
Decorator
Operation()
If you have a TextView object that displays text in a Window. TextView has no scroll bars by default TextView has no bord by default
aBorderDecorator component aScrollDecorator component
aTextView
MSRIT-ISE SDP 24
The Strategy Pattern Context class has multiple control strategies provided by the concrete strategy classes, or by the abstract strategy (by default) . The pattern lets us vary the algorithm that implements a certain function during run time depending on the conditions of the system .
The Pattern reduces coupling by having the client class be coupled only to the context class.
MSRIT-ISE SDP 25
Example of using the pattern in JAVA AWT GUI components lay out managers
MSRIT-ISE
SDP
26
Situation: A GUI text component object wants to decide at runtime what strategy it should use to validate user input. Many different validation strategies are possible: numeric fields, alphanumeric fields, telephone-number fields, etc.
MSRIT-ISE
SDP
27
Intent To decouple object creation from its use and to support different way of creating objects To define an interface for creating objects but let subclasses decide which class to instantiate and how.
Client AbstractFactory
makeProduct() ConcreteProuct Product
ConcreteFactory makeProduct()
MSRIT-ISE SDP 28
MSRIT-ISE
MSRIT-ISE
SDP
30