Skip to main content

Posts

Showing posts from February, 2025

Design Patterns: Factory Method

Let’s continue our series on design patterns with the Factory Method. Like the  Builder  or  Singleton  patterns we covered in previous posts, the Factory Method is also one of the creational patterns. It introduces a slightly more complex approach, offering a higher level of abstraction for object creation. Additionally, it helps decouple the object creation process from the rest of the application. It can be represented through the following components: Abstract object , which represents the base class for the objects that we want to create Concreate objects , classes that inherit the given base class Creator , abstraction of the classes resposible for the object creation Concreate creators, classes that inherit and implement given creator class Client or Consumer side , parts of the application where we call objects creation Bellow, we will show all these parts in one simple example. using System; // abstract object abstract class Engine { public abstract v...