1.

Discuss the various types and subtypes of Design Patterns known to you.

Answer»

The various types and subtypes of DESIGN Patterns are as follows:

Creational Design Patterns: It is all about class instantiation in these design patterns. This pattern can be further subdivided into patterns for creating classes and patterns for creating objects. While class creation patterns make good use of inheritance in the instantiation process, object-creation patterns make good use of delegation. They can be of the following types:

  • Abstract Factory: Creates an instance of various classes from different families.
  • Builder: It distinguishes between the construction of an object and its depiction.
  • Factory Method: Creates a new instance of a collection of derived classes.
  • Object Pool: By recycling objects that are no longer in use, expensive ACQUISITION and release of resources is avoided.
  • Prototype: An instance that has been fully initialised and is ready to be duplicated or cloned.
  • Singleton: There can only be one instance of a class.

Structural Design Patterns: It is all about Class and Object composition in these design patterns. Inheritance is USED to construct interfaces in structural class-creation patterns. Structural object patterns define how to put objects together to get new functionality. They can be of the following types:

  • Adapter:  It combines interfaces from various classes.
  • Bridge: It separates the interface of an object from its implementation.
  • Composite: Simple and composite things are arranged in a tree structure.
  • Decorator: It assigns responsibilities to objects in a dynamic fashion.
  • Facade: An complete subsystem is represented by a single class.
  • Flyweight: For efficient sharing, a fine-grained instance is used.
  • Private Class Data: Accessor/mutator access is restricted in it.
  • Proxy: In it, an object is a representation of another object.

Behavioural Design Patterns: The communication of Class objects is the focus of these design patterns. Behavioural patterns are those that are primarily concerned with object-to-object communication. They can be of the following types: 

  • Chain of responsibility: A method of forwarding a request from one object to the next in a chain of objects.
  • Command: As an object, encapsulate a command request.
  • Interpreter: A method of incorporating language components into a program.
  • Iterator: Access the items of a collection in a LOGICAL order.
  • Mediator: It is used for defining simplified communication between classes.
  • Memento: Capture and restore the internal state of an object
  • Null Object: Designed to serve as a default value for an object
  • Observer: A method of informing a large number of classes about a change.
  • State: When an object's state changes, alter its behaviour.
  • Strategy: Inside a class, a strategy encapsulates an algorithm.
  • Template Method: Delegate the algorithm's precise steps to a subclass.
  • Visitor: It adds a new operation to a class without making any changes to it.


Discussion

No Comment Found