Presentation on how to chat with PDF using ChatGPT code interpreter
Bridge pattern for Dummies
1. BRIDGE PATTERN
“ decoupling an abstraction from its implementation ”
Jang,Taeksoon
(NHN NEXT)
Wednesday, March 26, 14
2. MOTIVATION
- Suppose an abstraction should have different implementation
- Simple implementation would just extend the object itself
-Then, inheritance binds an implementation to the abstraction
- When a class changes often, you should change all classes
“ Bridge Pattern helps minimize changes in class ”
Wednesday, March 26, 14
3. BRIDGE PATTERN DEFINED
- Separate abstraction and implementation
Class itself : Abstraction
What class can do : Implementation
Wednesday, March 26, 14
4. PARTICIPANT
Abstraction : defines abstract interface and maintains the implementor
reference
Refined Abstraction : extends the interface defined by abstraction
Implementor : defines the interface for implementation classes
Concrete Implementor : implements the Implementor interface
Wednesday, March 26, 14
5. EXAMPLE & CODE
[ Requirement 1 ]
“ I need a program
that can draw circles and rectangles.“
Wednesday, March 26, 14
16. BENEFIT OF BRIDGE PATTERN
- Avoid binding between abstraction and implementation
=> Able to select implementation at run time
- Reduction in the number of sub classes
- Abstraction and Implementation can be varied independently
- Cleaner code without ‘if’ or ‘switch’ statement
Wednesday, March 26, 14
17. ADAPTER VS BRIDGE
Adapter
- meant to change the interface of an existing object
- intended to make unrelated classes work together
- My Code + Someone else’s Code
Bridge
- intended to decouple abstraction from its implementation
- Entirely My Code and My Structure
Wednesday, March 26, 14