Cidenet+Blog+Clean Dev Practices+Centralize the creation of objects with Creative Patterns!

Centralize the creation of objects with Creative Patterns!

Daniel Cataño Restrepo
Development analyst

Creational Patterns seek to hide the logic behind the creation of any objects by centralizing these creations in a single place in the application.

This allows the code to be re-used and increases flexibility, deciding which objects need to be created for a specific use case or which objects can be reused, rather than creating new instances; moreover, all of this is done in just one place within the app.

Creational patterns help us attack problems such as:

  • Create an instance of an object that can be used in different parts of an application and, no matter where it is used, its structure is expected to be the same. By centralizing the creation of this very specific object in a single place, it is simply not necessary to create the same objects several times, it simply returns the same instance each time it is required, saving resources this way.
  • When you have objects that may have different representations, but they all have the same structure. The structure is centralized, but you are free to create several representations of such a structure. For example, instances can be created such that one of these has all the attributes and the other only has some, however the two instances belong to the same class. Some patterns allow this flexibility in a generic way, without having to create a builder for each representation.
  • Delegate and centralize the creation of an instance of a class, so that the client does not have to decide which class to instantiate. With this, dynamism is gained, since more classes can be created in the future without affecting the ones already created, and for the client it will be transparent.

Sources:

Oscar Blancarte

Contact us

Allow us to contact you

    Medellín - Colombia

  • Carrera 69 #49A - 11 Barrio Suramericana
  • (+57) 312 8475682
  • comunicaciones@cidenet.com.co

    United States

  • 1200 Colorado Blvd, Denver Colorado 80220
  • (+1) 7723619239
  • jceballos@cidenet.net
WhatsApp
>