Design Pattern using C# Training - Day 1 | Factory and Factory Method Design Patterns in C#
Design Pattern using C# Training - Day 1 | Factory and Factory Method Design Patterns in C# In this Training Series, we are going to discuss all the Design Patterns in C# with Real-Time Examples. It is very easy to understand and implement design patterns in Real-Time Applications. Writing code with design patterns will make your applications more Reliable, Scalable, and Maintainable. This Video Course is For Whom? This course is designed for Students, Beginners as well as Professional Developers who want to learn and enhance their knowledge of Design Patterns using .NET Applications. Here, I will explain all the design patterns step by step i.e. first we will discuss the definition, then we will give simple as well as multiple real-time examples, then we will discuss how to implement the same using .NET Application, then we will compare the example with the UML diagram of the design pattern so that you will understand the concept very easily. What are Design Patterns? Design Patterns are nothing but documented and tested solutions for recurring problems in a given context. So, in simple words, we can say that Design Patterns are reusable solutions to the problems that, as a developer, we encounter in our day-to-day programming. Design Patterns are basically used to solve the problems of Object Generation and Integration. As we progress in this Design Patterns course, you will understand what are Object Generation and Integration problems and how we solve them using different design patterns. What is Factory Design Pattern in C#? Let us first try to understand the definitions of the factory design pattern. If you are not understanding the following definition, then do not worry, we will explain the same with real-time examples and then definitely you will understand the definition. According to Gang of Four (GoF), the Factory Design Pattern states that A factory is an object which is used for creating other objects. In technical terms, we can say that a factory is a class with a method. That method will create and return different types of objects based on the input parameter, it received. In simple words, if we have a superclass and n number of subclasses, and based on the data provided, if we have to create and return the object of one of the subclasses, then we need to use the Factory Design Pattern in C#. In the Factory Design pattern, we create an object without exposing the Object Creation and Initialization logic to the client and the client will refer to the newly created object using a common interface. The basic principle behind the Factory Design Pattern is that, at run time, we get an object of a similar type based on the parameter we pass. So, the client will get the appropriate object and consume the object without knowing how the object is created and initialized. What is Factory Method Design Pattern?