The adapter and bridge patterns are very similar. They're both considered a form of encapsulation and facilitate more control over code changes without impacting the class structure. However, the main difference between the two is that using a bridge pattern separates the essential data from its implementation, while an adapter pattern allows incompatible classes to interface with each other without changing the source code.
For example, the memory card slot on a computer is the adapter that allows the memory card to interface with the computer. A bridge pattern can be represented through the example of a household light switch. The switch for the device can be in the form of a chain, a 2-position switch or a dimmer, but regardless of the form, the bridge pattern makes sure that the switch performs the task of turning the light on and off.
Posted Date:- 2021-09-06 20:19:37