DEV Community

Discussion on: Adapter Pattern using a payment gateway as a case study.

Collapse
 
tundebabzy profile image
tundebabzy

Good start but....

Looking at your code, it's not clear that this is the adapter pattern in play. Your adaptor class should either extend the adaptee class or for typed implement the same interface as the adapted class.

The way it is written can only work for non-typed languages and does not communicate the pattern correctly to a person reading the code.

Collapse
 
walosha profile image
Olawale Afuye • Edited

Thank you for the feedback! I have implemented an interface using typescript. I would rather not implement same interface for both ( adpater and adapte classes) to prevent a tight coupling of both classes