Site Loader

The Design Pattern called Factory is focused on give instance to clients but hiding the way on how the instance is done.

But why would we do that?

Well there are several reasons why use it, image an escenario where you need to pass relevant and so sensitive data on the parameters to make your class work properly but you don’t want to expose that information to the others module that will use your library , other scenario could be where you have several products implementing a particular interface and you don’t have the way to figure out which product the client will and you must handle that and in our final escenario imagine you have important logic that need to be implemented by you before anyone could use a specific instance. There are a lot of examples of use where this pattern will solve several of your issues.

The basis of this pattern is in the diagram below:

In the next git example I use the Factory Pattern with a Singleton implementation. The Singleton is

Here is the link, the example is developed using Visual Studio 2015 with C# as programming language: https://github.com/edgarleonardo/Factory-design-pattern-example

Hope it could help you on anything you want to know about this pattern.

Post Author: Edgar Leonardo

I am Full Stack Developer and DevOps passionate, result-driven with deep experience on IT concerns. I am always seeking the best knowledge and practices in the world of technologies that make me and my work improve every day.

With more than 10 years of experience working as an IT professional, I have been involved and in some case leading large-scale IT projects since Backend, Frontend, Mobile Applications, Cloud Solutions and API integrations and even DevOps for Latam and the Caribbean in areas like Finance, Banking, Digital Advertising, Search engines, Social Network, Software Development, Outsourcing and Freelancer, integrations and more.