The Factory Pattern

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.


Comments

Popular posts from this blog

WebSockets Implementation With SignalR And Xamarin.Forms

Creating A Push Notification Server with ASP.NET And Xamarin.Form App With Firebase Push Notification, Refit, And LiteDB - Part 1 (Firebase Configuration)

CDN And Cloud Storage On Azure