This is useful when we want to create objects of different types based on some condition. The Factory Method pattern provides an interface for creating objects, but allows subclasses to decide which class to instantiate. This is useful when we need to limit the number of instances of a class, such as a database connection or a configuration object. The Singleton pattern ensures that only one instance of a class is created in the system. The creational patterns include Singleton, Factory Method, Abstract Factory, Builder, and Prototype. This helps to decouple the client from the objects it uses. They provide ways to create objects without exposing the creation logic to the client. Creational Patterns: Understanding the First Group of PatternsĬreational patterns are used to create objects in a system. In this article, we will explore each of these groups and understand how they work. The book describes 23 design patterns that are grouped into three categories: creational, structural, and behavioral.
They were first introduced by four authors – Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides – in their book 'Design Patterns: Elements of Reusable Object-Oriented Software' in 1994. The Gang of Four (GoF) patterns are the most popular and well-known design patterns. Understanding the Gang of Four Design Patterns: A Beginner's Guideĭesign patterns are solutions to recurring problems in software development.