Creational Design Pattern - Software Engineering

Creational Design Pattern - Software Engineering  👽

In the industry we have to use Design Patterns to develop systems. There are 3 types of design patterns. You can use below link to get an small idea about design patterns. https://miyurangika1223.blogspot.com/2024/09/design-patterns.html 

In this blog we can discuss about Creational Design Pattern.


Creational Design Patterns 

  • Creational design patterns provide various object creation mechanisms where objects are create in a manner suitable for a given situation 
  • It increases flexibility and reuse of existing code.

Some creational design patterns:

  1. Factory method design pattern
    • It defines a method to create objects and lets subclasses decide the exact type of object to create.
    • We use this pattern when we don't know in advance what type of object to create and subclasses might want to control object creation.
    • Example: creating different types of notifications like SMS and Email.
  2. Abstract factory design pattern
    • It creates groups of related objects (like buttons and checkboxes) that are meant to work together.
    • We use it to ensure that related objects are compatible.
    • Example: Buttons and checkboxes for different operating systems.
  3. Builder design pattern
    • It defines the steps for constructing a product.
    • It is particularly useful when the construction process of an object is complex.
    • Advantages: Separation of concerns, Complex object creation, Flexibility.
    • Example: create an example where we build a Car with different configurations like Engine, Seats, and GPS system.
  4. Prototype design pattern
    • It allows cloning of objects, ensuring that a new object can be created by copying an existing one.
    • Advantages: Performance optimization, Avoiding object creation overhead, Flexibility
    • Example: Cloning a object
  5. Singleton design pattern
    • It ensures that a class has only one instance and provides a global access point to that instance.
    • It's used when you want to make sure only one object of that class is created and you want to control how it is accessed.
    • Advantages: Controlled access to instance, Lazy initialization, Global state
                           A trick to remember Behavioral Design Patterns :

                            Funny Ants Build Perfect Sandwiches    
                              
                                     FABPS

Benefits of structural design patterns

  • Flexibility in object creation
  • Control over object creation
  • Simplify object creation logic
  • Separation of concerns
  • Easier object management
  • Cost efficiency

Blogs that you can refer to improve your knowledge about Design Patterns. 


Comments

Popular posts from this blog

Sorting Algorithms - JAVA👽

Object Oriented Programming - JAVA- class boundary, variable types, modifiers, java main method

Object Oriented Programming - JAVA- Method Overriding