Design Patterns – Creational Patterns
“The creational patterns are about class instantiation and object creation. It can further classify into Class-creation patterns and object-creation patterns. The class-creation patterns use the inheritance methods in the instantiation process. The object-creation patterns use delegation ways to get the task done. The creational designs have more ways to implement, such as the Factory Method, Abstract Factory, Builder, Singleton, Object Pool, and Prototype.”
From Design Pattern – Introduction
The “Creational Pattern” has more ways to implement, but how to use it in the .NET framework web application? This article can help the reader quickly understand how to use these patterns and demo these patterns without/within a web application project.
- Abstract Factory – Provide the classes or interface classes for creating several classes and objects in the superclass. It allows the superclass to alter the object type or other that will be made.
- Builder – This pattern allows making different types and representations of the object using the same construction code.
- Factory Method – Provides interface classes for creating objects in the superclass. It allows the superclass changes the object types that will be made.
- Object Pool – Avoid expensive acquisition and release of resources by recycling objects that are no longer in use
- Prototype – A fully initialized instance to be copied or cloned
- Singleton – A class of which only a single instance can exist
Note: All demo samples will build in the .NET Core case project so if you want to see the complete source code in everyone’s pattern articles, please, click the Github repository – Enterprise_MVC_WebApp.
In any computer language or framework, the creational patterns have a different mechanism that may be default setting or customer editing by SDK or the computer language characteristic. Writing format isn’t necessary! The developers should see these source codes bring about what kind of effect in the projects? Developers should ask themselves, “Is it good for this project in future management and future source code growth?”
Reference