Category Archives: Design patterns

Strangler pattern

Strangler fig

When you need to migrate an old application into new technology, create a facade which routes requests. You can now migrate small parts of your old app and direct your clients into migrated parts once they are ready, but keep the whole app working and coherent. It is transparent for you clients whether they are […]

Read more

Bridge pattern

Bridge design pattern is the essence of Object Oriented programming best practices. It enforces encapsulation, separation of responsibilities and coding to interfaces. It decouples the classes while maintaining a clear interface between them. Let’s see how it works. Let’s imagine that we have two types of classes, and we would like them to cooperate, in […]

Read more

Adapter pattern

Adapter programming pattern comes in handy, when we would like to use a certain API, but have an object with a different interface. When so, we can use the adapter to wrap the strange interface with convenient API of ours. Plus, we can adapt the output to our needs. What are the scenarios where we […]

Read more

Proxy pattern

The idea behind the proxy design pattern is to have a class, which in some way facilitates or optimises access to an underlying object. At the same time, the proxy class has the same interface as the underlying object, so it can be substituted for it. Proxy pattern can be used for accessing remote resources, […]

Read more

Facade design pattern

This one is as easy as it gets. You simply create a class which exposes a simple API and hides the complexity behind it. Facade pattern code example: public class Facade { public int simpleCall() { ComplicatedObject1 obj1 = process(); ComplicatedObject2 obj2 = processAgain(obj1); return obj2.getTheMeaningOfLife(); } }

Read more

Decorator pattern

A decorator extends base object by modifying its behaviour. Each decorator contains a base object type reference, and at the same time is of base object type. That way, decorators can be chained one over another, and none of them know, if the reference base object they contain is in fact a concrete base object […]

Read more

Strategy pattern

The name of the pattern always sounded misleading to me – there is no mystical sophisticated strategy that you need to apply to use this pattern. This is all about substituting plain object oriented inheritance with neatly encapsulated algorithms. So, instead of inheriting a behaviour from parent class, we provide a behaviour on instance creation. […]

Read more