Design Patterns

How to create the dependencies when the dependency injection pattern is used?

Submitted by Kamal Wickramanayake on

In object oriented design of software, the dependency injection pattern (or inversion of control pattern – abbreviated as IoC pattern) is widely used to avoid key classes from instantiating their dependencies but to accept the dependencies from outside. Accordingly, the concern of object usage and the concern of object instantiation are separated. It is a case where "separation of concerns" is seen.

Difference between the Factory Method and Strategy design patterns

Submitted by Kamal Wickramanayake on

Gang of Four (GoF) collection of design patterns talks about these patterns where the beginners sometimes fail to see the difference between. They often look at the code example of a pattern and attempt to guess what it is but fail to read through the details and understand the real intent of it. The Factory Method and Strategy patterns are coded similarly but with minor code differences. These minor code differences make the two patterns very different in the way they are used and the problems they solve. In this article, I describe these differences.