Skip to content

Commit 1a2bf26

Browse files
authored
Structural pattern
1 parent d1dffe0 commit 1a2bf26

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,48 @@
3737
Disadvantages:- - Complexity is high
3838
- Tends to rely on other patterns.
3939
- Low popularity.
40+
41+
### 2. Structural Patterns:-
42+
It provides a common solution to common issues realted to object structures and features of those factors is that they rely on concepts of inheritance, polymorphism
43+
44+
Types of Structural Patterns:-
45+
46+
i) Adapter Pattern:- This pattern is generally used when there is a need to combine the capabilities of the interface.
47+
use cases:- - In case of legacy applications.
48+
- In case of converting an interface into another.
49+
- in case of translating a client's requests for a website.
50+
51+
examples of usage in Java API:-
52+
- Arrays.asList();
53+
- I/O streams
54+
55+
ii) Bridge pattern:- It aims to separate a large structure of classes into two heirarchy.
56+
use cases:- - when having a complex structure of classes with similar implementations.
57+
- when want to impose the same implementation for multiple objects.
58+
- when providing a map b/w orthogonal class hierarchies.
59+
60+
iii) Filter pattern:- It enables us to define filters for our objects.
61+
62+
iv) Composite pattern:-
63+
features:- - Designed on tree structure.
64+
- Root level is the Component.
65+
- Leaf objects implement the Component.
66+
- Composite perform the same operations as the leafs.
67+
- Composite knows about the child objects.
68+
69+
v) Decorator pattern:-
70+
features:- - Decorates a base object with multiple features.
71+
- Adheres to the single responsibility principle.
72+
- uses OOP principles.
73+
74+
vi) Facade pattern:- The pattern is used for providing an interface to the client while hiding all the complexities of a system.
75+
76+
vii) Flyweight pattern:- It is used for memory optimization purposes. The design pattern is usually chosen whenever there is a need to reduce the number of created objects.
77+
- It has capability to optimize object structure.
78+
79+
viii) Proxy pattern:- It is basically a class that serves as an interface between a client application and another object.
80+
usage:- - when creating a wrapper to cover main's object complexity.
81+
- when creating a security layer for preventing unauthorized access.
82+
weakness:- - It can have a single proxy.
83+
- creates complexity.
84+

0 commit comments

Comments
 (0)