/bridge

Simple project demonstrating the bridge design pattern. For this one, I simulate a online shopping cart for two different types of user and two different payment methods. There is a bridge between the payment method class and the cart class.

Primary LanguageJavaApache License 2.0Apache-2.0

BRIDGE

Code

Simple project representing the bridge design pattern. For this one, i simulate a online shopping cart for two different types of user and two different payment methods. There is a bridge between the payment method class and the cart class.

Definition

image

Bridge is a structural design pattern that lets you split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other.

image

When a class varies often, the features of object-oriented programming become very useful because changes to a program's code can be made easily with minimal prior knowledge about the program. The bridge pattern is useful when both the class and what it does vary often. The class itself can be thought of as the abstraction and what the class can do as the implementation. The bridge pattern can also be thought of as two layers of abstraction.

image

Source: Wikipedia | Refactoring Guru