0% found this document useful (0 votes)
22 views35 pages

Design Patterns-P2

The Decorator Design Pattern is a structural pattern that allows for adding functionalities to a class dynamically without altering the class itself. It enables clients to choose notification methods and enhances class capabilities at runtime. The document also briefly mentions other design patterns such as Adapter and Bridge, which facilitate collaboration between incompatible interfaces and separate class hierarchies, respectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views35 pages

Design Patterns-P2

The Decorator Design Pattern is a structural pattern that allows for adding functionalities to a class dynamically without altering the class itself. It enables clients to choose notification methods and enhances class capabilities at runtime. The document also briefly mentions other design patterns such as Adapter and Bridge, which facilitate collaboration between incompatible interfaces and separate class hierarchies, respectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like