Tag Archives: strategy pattern

Prefer dependency injection to hard wiring resources

When creating new classes it is preferable to design them easy to test (easy to mock) and as independent from other elements as possible (decoupling). Even though it might seem at the beginning that the classes used inside will never change, it is still advice to code to interface, instead of the implementation; and to […]

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