Member-only story
JavaScript Design Patterns: Structural
Design patterns offer sophisticated object-oriented solutions for frequently encountered software challenges. Patterns are about reusable designs and interactions of objects. Each pattern has a name and becomes part of a vocabulary when discussing complex design solutions.
In a previous article, we have discussed Creational and Behavioral Design Patterns. In this article, we are going to discuss about Structural design Patterns.
Adapter
The Adapter Pattern is a structural design pattern that enables an existing class’s interface to be utilized as a different interface. It is commonly employed to integrate existing classes with others without altering their source code.
The Adapter pattern acts as a bridge that converts one interface (an object’s properties and methods) into another. This enables programming components with incompatible interfaces to function together seamlessly. The Adapter pattern is also known as the Wrapper Pattern.
// old interface
class Shipping {
request(zipStart, zipEnd, weight) {
const baseCost = 24.38;
return baseCost * weight;
}
}
// new interface
class…









