The Bridge Pattern is a structural design pattern that separates an abstraction
from its implementation, allowing both to evolve independently. By decoupling
these components, the pattern promotes flexibility and scalability in software
design. It is particularly useful when designing systems that require multiple
variations of abstractions and implementations.
typeImplementor={operationImp():void;};classConcreteImplementorAimplementsImplementor{operationImp():void{console.log("ConcreteImplementorA::operationImp");}}classConcreteImplementorBimplementsImplementor{operationImp():void{console.log("ConcreteImplementorB::operationImp");}}classAbstraction{constructor(protectedimp: Implementor){}operation():void{this.imp.operationImp();}}classRefinedAbstractionextendsAbstraction{// RefinedAbstraction can add its own methods if needed
// But it inherits the constructor and operation from Abstraction
// So, no need to redefine them unless you want to override
}constclient={run():void{constconcreteImplementorA=newConcreteImplementorA();constrefinedAbstractionA=newRefinedAbstraction(concreteImplementorA);refinedAbstractionA.operation();constconcreteImplementorB=newConcreteImplementorB();constrefinedAbstractionB=newRefinedAbstraction(concreteImplementorB);refinedAbstractionB.operation();constsimpleAbstraction=newAbstraction(concreteImplementorA);// Demonstrating simple abstraction
simpleAbstraction.operation();}};client.run();