Skip to content

Design pattern

Bad design

Here, if we want to increase minions, it will increase if/ else in our code.

Adapter Pattern

Adapter is basically mapper between these different functions.

A possible example:

A better an generalised solution to adapter design pattern would be:

Notice here the changes made to adapter object will make changes to Parent class ( achieved using getter and setter method)→ this is actually implementation of decorator pattern

Facade Pattern:

Basically providing an simple API. By adding one more layer of abstraction.

Observer Pattern

Here observable notify the observer whenever any change occurs, rather than the observer polling and asking if any changes has occured.

Safe traders.