Categories: Design Pattern

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 FactoryProvide 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 MethodProvides interface classes for creating objects in the superclass. It allows the superclass changes the object types that will be made.
  • Object PoolAvoid expensive acquisition and release of resources by recycling objects that are no longer in use
  • PrototypeA fully initialized instance to be copied or cloned
  • SingletonA 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

davidsky69

Recent Posts

API Gateway in .NET 5 with Ocelot

What is the API gateway? An API gateway is an API management tool that sits…

3 years ago

.NET 5 application with Onion architecture

The .NET 5 SDK is a kind of milestone in the .NET world. The .NET…

4 years ago

SOLID Principles – Dependency inversion principle

In object-oriented design, the dependency inversion principle is a specific methodology for loosely coupling software…

4 years ago

SOLID Principles – Interface segregation principle

In the field of software engineering, the interface segregation principle (ISP) states that no code…

4 years ago

SOLID Principles – Liskov substitution principle

Subtype Requirement: Let  be a property provable about objects  of type T. Then  should be true for objects  of type S where S is…

4 years ago

SOLID Principles – Open-closed principle

In object-oriented programming, the open–closed principle states "software entities (classes, modules, functions, etc.) should be…

4 years ago