Last active
October 20, 2018 14:25
-
-
Save biniama/57c730996a5e1ee7b88556f1fddf35ec to your computer and use it in GitHub Desktop.
Adapter vs Decorator vs Bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In scope and intent | |
Adapter - intent is to mix an interface into a class that doesn't currently implement htat interface. | |
Decorator - intent is to change the way a method behaves differently for different decorators. | |
Bridge - intent is to insolate sub-systems so you can swap out sub-systems without impacting the code that is using that sub-systems. | |
The point of a Bridge is to isolate two subsystems so that they can be independently modified. Bridges are big things, often comprised of other patterns (like Adapters and Decorators). This segment looks at how to implement a Bridge and discusses the differences between Bridge and similar patterns like Adapter. | |
E.g. JDBC (bad implementation of Bridge since swapping doesn't work as it should) | |
Best example: ORM systems like Hibernate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Idea is to simplify | |
Facade is another way to isolate subsystems, but it's purpose is simplification, not complete isolation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment