Posts for: #Structural Design Pattern

Adapter Pattern in Kotlin

Adapter Pattern in Kotlin

The Adapter or Wrapper Pattern allows you to translate one interface into another, expected by the client class. It is especially useful when the adapted object comes from 3rd party library, and you do not want to make your system depending on that interface, creating the so-called anticorruption layer. Adaptee interface changes will only affect the Adapter and not the rest of the code.

[Read more]

Facade Pattern in Kotlin

Facade Pattern in Kotlin

The facade allows you to hide the details of the module from clients. It ensures compliance with Law Demeter. Using the generic interface and various implementations greatly simplifies testing. It blends well with other patterns like Strategy, Template Method, or construction patterns, allowing configuration of the object available for the clients. The facade is a good entry point for libraries, giving customers access to high-level functionality and hiding all internal logic and classes.

[Read more]