Design Patterns in Golang: Decorator

Introduction The Decorator pattern adds new functionality to an existing object without altering its structure. It is a structural pattern as this pattern acts as a wrapper to existing class. The instanciate a decorator struct which decorates (wraps) the original object and provides additional functionality keeping its methods signature intact. Purpose Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to inheritance for extending functionality. Wrapping a present, putting it in a box, and wrapping the box....

April 17, 2016 · 3 min · Svetlin Ralchev

Design Patterns in Golang: Composite

Introduction A Composite Design Pattern is a structural pattern that uses to employ composition when implementing an interface rather than using multiple inheritance. It composes objects into tree structures and lets clients treat individual objects and compositions uniformly. There are situations when clients ignore the difference between compositions of objects and individual objects. If dealing with multiple objects in the same way as handle each of deam is identical, the Composite Design pattern is a good choice to decrease the complexity and treat them as homogeneous....

March 31, 2016 · 3 min · Svetlin Ralchev

Design Patterns in Golang: Adapter

Introduction The Adapter Pattern is responsible for adaptation of two incompatible interfaces. It is a structural pattern that is responsible to join functionalities of independent or incompatible interfaces without modifing their implementation. Interfaces may be incompatible but the inner functionality should suit the need. It allows otherwise incompatible objects to work together by converting the interface of each struct into an interface expected by the clients. Purpose Impedance match an old component to a new system Wrap the interface of a object into another interface clients expect....

February 22, 2016 · 5 min · Svetlin Ralchev