structural pattern
TRANSCRIPT
-
8/16/2019 Structural Pattern
1/23
STRUCTURAL
PATTERNB A Y U P R I Y A M B A D H A
-
8/16/2019 Structural Pattern
2/23
STRUCTURAL PATTERN
• Decorator Pattern
• Adapter Pattern
• Façade Pattern
• Composite Pattern
•
Proxy Pattern
-
8/16/2019 Structural Pattern
3/23
DE C O R A T O R
PATTERN
-
8/16/2019 Structural Pattern
4/23
DECORATOR PATTERN
• This type of design pattern comes under structural pattern.
• Attach additional responsibilities to an object dynamically. Decorators provide a
alternative to subclassing for extending functionality.
• This pattern creates a decorator class which wraps the original class and provid
functionality keeping class methods signature intact.
• Wrapping a gift, putting it in a box, and wrapping the box.
• so known as:
– Wrapper
-
8/16/2019 Structural Pattern
5/23
APLICABILITY
• To add responsibilities to individual objects dynamically and transparently, that is
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 produ
of subclasses to support every combination
– a class definition may be hidden or otherwise unavailable for subclassing
-
8/16/2019 Structural Pattern
6/23
DECORATOR PATTERN
-
8/16/2019 Structural Pattern
7/23
A D A P T E R
PATTERN
-
8/16/2019 Structural Pattern
8/23
ADAPTER PATTERN
• Adapter pattern works as a bridge between two incompatible interfaces.
• This pattern involves a single class which is responsible to join functionalities of
or incompatible interfaces.
• Adapter lets classes work together that couldn't otherwise because of incompat
-
8/16/2019 Structural Pattern
9/23
ADAPTER PATTERN : MOTIVATION
-
8/16/2019 Structural Pattern
10/23
ADAPTER PATTERN : MOTIVATION
• Sometimes a toolkit or class library can not be used because its interface is incothe 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 domain-specific application
-
8/16/2019 Structural Pattern
11/23
ADAPTER PATTER : STRUCTURE
-
8/16/2019 Structural Pattern
12/23
F A Ç A D E
PATTERN
-
8/16/2019 Structural Pattern
13/23
FAÇADE PATTERN
• Provide a unified interface to a set of interfaces in a subsystem
• Façade defines a higher-level interface that makes the subsystem easier to use
• Façade pattern hides the complexities of the system and provides an interface t
using which the client can access the system.
• This pattern involves a single class which provides simplified methods required b
delegates calls to methods of existing system classes.
-
8/16/2019 Structural Pattern
14/23
FAÇADE PATTERN : MOTIVATION
-
8/16/2019 Structural Pattern
15/23
FAÇADE PATTERN : STRUCTURE
-
8/16/2019 Structural Pattern
16/23
FAÇADE PATTERN : EXAMPLE
-
8/16/2019 Structural Pattern
17/23
C O M P O S I T E
PATTERN
-
8/16/2019 Structural Pattern
18/23
COMPOSITE PATTERN
• Compose objects into tree structures to represent part-whole hierarchies
• Composite lets clients treat individual objects and compositions of objects unifo
• This pattern creates a class that contains group of its own objects. This class pro
modify its group of same objects.
-
8/16/2019 Structural Pattern
19/23
COMPOSITE PATTERN : STRUCTU
-
8/16/2019 Structural Pattern
20/23
PRO XY PATT E
-
8/16/2019 Structural Pattern
21/23
PROXY PATTERN
• Provide a surrogate or placeholder for another object to control access to it.
• Use an extra level of indirection to support distributed, controlled, or intelligent
• Add a wrapper and delegation to protect the real component from undue comp
• Problem :
– You need to support resource-hungry objects, and you do not want to instantiate s
unless and until they are actually requested by the client.
-
8/16/2019 Structural Pattern
22/23
PROXY PATTERN : STRUCTURE
-
8/16/2019 Structural Pattern
23/23