idlegossip / Design-Pattern

0 stars 0 forks source link

Design-Pattern 💻


Design patterns are the well proved solution of commonly occuring problems in software design. A design pattern is a general reusable solution to a commonly occurring problem in software design. It is a proven approach that provides a template or guideline for solving a specific design problem while promoting good software design practices such as modularity, reusability, and maintainability. Design patterns capture best practices and design principles that have been developed and refined by experienced software developers over time. They represent solutions to recurring problems and provide a common vocabulary for developers to communicate and share their design ideas.

Design patterns can be classified into three main categories: 🟠

  1. Creational Patterns: 📘 These patterns deal with object creation mechanisms, providing ways to create objects in a manner that is flexible, decoupled from the specific classes, and suitable for the situation. Examples of creational patterns include the Singleton, Factory Method, and Builder patterns.
  2. Structural Patterns: 📘 These patterns focus on the composition of classes and objects to form larger structures, providing ways to organize classes and objects to achieve flexibility, extensibility, and maintainability. Examples of structural patterns include the Adapter, Decorator, and Composite patterns.
  3. Behavioral Patterns: 📘 These patterns address the interaction and communication between objects, providing ways to define the responsibilities and collaborations among objects to achieve loose coupling and flexibility. Examples of behavioral patterns include the Observer, Strategy, and Command patterns.

[!note] Design patterns are not specific to a particular programming language or technology. They are higher-level concepts that can be implemented in various languages and frameworks. By utilizing design patterns, developers can create more robust, modular, and maintainable software systems.Design patterns include creational patterns, which deal with object creation. structural patterns, which focus on object composition and organization. and behavioral patterns, which deal with the communication between objects and classes.

Creational Pattern : 💻

Creational design patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code.
Read

1. Singleton Method : 📘

Singleton is a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance.
Read the_blog.

Singleton works on the concept of one and only one instance of the object, which results in the global control of a resource. In simple words, the Singleton design pattern ensures that only one instance of the class will be created and that instance will have global access within the application. When you want to ensure that only one instance of a class exists, for example, a single database object shared by different parts of the program, you should use the Singleton design pattern.

Pros and Cons: 🟠

2. Factory Method: 📘

Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.The Factory Method is a creational design pattern that provides a solution to create product objects without the need to specify their concrete classes during the creation process. The Factory Method is used to conserve system resources by reusing existing objects instead of reconstructing them repeatedly.
Read the blog.

Pros and Cons: 🟠

3. Abstract Factory: 📘

Abstract Factory is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.
Read the article.

Advantages: 🟠