Decorator Design Pattern
Decorator Design Pattern
45
Decorator Design Pattern
46
Decorator Design Pattern
47
Decorator Design Pattern
Clients can choose a single
notification method
48
Decorator Design Pattern
49
Decorator Design Pattern
The Decorator Pattern is a structural design pattern that is used to add
additional functionalities to a class either during compile time or
dynamically during run time without affecting the class itself and its
consumers.
50
Decorator Design Pattern
51
Decorator Design Pattern
52
Decorator Design Pattern
53
Decorator Design Pattern
54
Decorator Design Pattern
Sending Like and Subscribe!!! By Mail to Geek@Mail
Sending Like and Subscribe!!! By Mail to Geek@Phone
Sending Like and Subscribe!!! By Mail to Geek@Facebook
55
Decorator Design Pattern
56
Adapter Design Pattern
Adapter Design Pattern
58
Adapter Design Pattern
Takes all of the XML data and
transform it to JSON, making
it compatible with the 3rd
Library
59
Adapter Design Pattern
Adapter
Structural design pattern
Allows objects with
incompatible interfaces to
collaborate with each other
60
Adapter Design Pattern
61
Adapter Design Pattern
UI Library
62
Adapter Design Pattern
63
Adapter Design Pattern
Old UI
NEW UI
64
Adapter Design Pattern
65
Adapter Design Pattern
Adapter
Uses Inheritance and Composition to enable
objects with Incompatible Interfaces to
collaborate
It creates a middle-layer class
that acts as a Translator
The adapting behavior is now separated,
and we can introduce new adapters without
breaking existing code
66
Bridge Design Pattern
Bridge Design Pattern
68
Bridge Design Pattern
69
Bridge Design Pattern
70
Bridge Design Pattern
We’re trying to extend the Pizza class in two
Independent Dimensions
We should switch from
Inheritance to Composition
71
Bridge Design Pattern
72
Bridge Design Pattern
73
Bridge Design Pattern
74
Bridge Design Pattern
Bridge
75
Bridge Design Pattern
76
Bridge Design Pattern
Bridge
Splits a large class into two separate
hierarchies which can be developed
independently
Structural Design Pattern
The two hierarchies: Restaurant & Pizza
à Abstraction & Implementation
Abstraction is a High level control layer that delegates Work to the Implementation
77
Bridge Design Pattern
78