Tag Archives: design-patterns

Design Patterns: Template Method

This method consist in having a Template for your classes. It solves the problem of having multiple classes with duplicated code. Instead we can just create an abstract class and make our classes inherit from it. This way we can implement the common functionality in the parent class and have other classes inherit the unique behavior from a unique place.
Continue reading

Design Patterns: Adapter

2015-43-09 10-43-09-063 The adapter is used when you want to integrate a class from another source into your code.

It could also be used to enable the use of legacy classes into your new architecture. It can also be used with classes that needs very specific methods to complete some work, like database access classes, and then they could be adapted to use a common interface.
Continue reading

Design Patterns: Decorator

The decorator design pattern comes in handy when we need to add behavior or state to an object during run-time. It allows you to change the behavior of a class at run-time without having to change the core code.

It can be used, for example, to add logging capabilities to an instance. It works by wrapping the original class in the decorator class, invoking the methods where applicable and invoking the custom behavior at the same time.
Continue reading