-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructural-Design-Patterns-Note.txt
More file actions
46 lines (26 loc) · 1.67 KB
/
Copy pathStructural-Design-Patterns-Note.txt
File metadata and controls
46 lines (26 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Structural
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
=> This design patterns is all about Class and Object composition i.e.
How do you want structure the software component.
=> These design patterns are about organizing different classes and objects to form larger structures and provide new functionality.
1. Proxy - An object representing another object
Example: checkbook leaf, credit card, debit card are the proxy for Money and a customer representative to order a product.
java.rmi.*, the whole API actually.
2. Composite - Gives a unified interface to a leaf and composite.
Example: File System in Operating Systems, Directories are composite and files are leaves.
System call Open is a single interface for both composite and leaf.
3. Decorator - Gives additional feature to leaf, while giving unified interface.
Example:
-> Adding discounts on an order
-> Gun is a deadly weapon on its own.
But you can apply certain "decorations" to make it more accurate, silent and devastating.
All subclasses of java.io.InputStream, OutputStream, Reader, and Writer have a constructor taking an instance of the same type.
4. Facade - Simplifies multiple complex components with single interface
Example: Control Panel
javax.faces.context.ExternalContext, which internally uses ServletContext, HttpSession, HttpServletRequest, HttpServletResponse, et
5. Adapter - Provides different interface for an interface.
Example: Power Adapters
java.util.Arrays#asList()
6. Flyweight - A fine-grained instance used for efficient sharing
Example : Dial tone
java.lang.Integer#valueOf(int) (also on Boolean, Byte, Character, Short and Long)