Friday, February 13, 2015

Creational Design Pattern

Design Pattern > Creational Design Pattern

Creational design patterns abstract the object instantiation process.This pattern is used when the system has more and more object composition than inheritance. Also, composing systems with inheritance makes those systems too rigid. The creational patterns are designed to break this close coupling.

The consequences of creational patterns are :

1. You hide creational logic from the consument of an object-instance. As a consument you are not interested in how an instance is created. You only have a concrete demand (Service, Repository, etc.). Each demand is a dependency of your object.

2. You are able to insert dependencies from the outside, aka dependency injection. If you are able to inject/substitute dependencies of an object, you are better able to write unit-tests. Say you need the result of a complex DB-query or the result of several web-service-calls; you could easily inject those results from the outside or stub results. Furthermore you could mock / stub out the creational objects itself, which could be used to deliver other mocks / stubs.

Mainly used creational pattrns are :




4. Prototype

5. Singleton

No comments:

Total Pageviews