Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

At least 3 design patterns of structural, creational and behavioral type

Sumit Rawal answered on September 1, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • What is the difference between a creational, structural, and behavioral design pattern?

  • At least 3 design patterns of structural, creational and behavioral type

    0

    Here are three design patterns, one from each of the structural, creational, and behavioral categories:

    Structural Pattern:

    Adapter Pattern:

    The Adapter Pattern allows the interface of an existing class to be used as another interface. It is particularly useful when you have two incompatible interfaces that need to work together. The adapter acts as a bridge between the two interfaces, allowing them to collaborate.

    Use Case: Imagine you have an old library that uses a legacy interface, and you want to use it in your modern application with a new interface. You can create an adapter that makes the old library compatible with the new interface.

    Creational Pattern:

    Factory Method Pattern:

    The Factory Method Pattern defines an interface for creating objects but allows subclasses to alter the type of objects that will be created. It provides an abstract method for creating objects, and concrete subclasses implement this method to produce objects of various types.

    Use Case: Consider a document processing application where you have multiple document types (e.g., PDF, Word, Excel). You can use the Factory Method Pattern to create document-specific factories that produce instances of the respective document types.

    Behavioral Pattern:

    Observer Pattern:

    The Observer Pattern defines a one-to-many dependency between objects so that when one object (the subject) changes its state, all its dependents (observers) are notified and updated automatically. This pattern promotes loose coupling between the subject and its observers.

    Use Case: In a weather monitoring application, you can have multiple displays (observers) that show different aspects of the weather (temperature, humidity, pressure). When the weather data changes, all the displays are notified and updated, ensuring they always display the latest information.

    These three design patterns provide solutions to common design problems in different areas of software development. The Adapter Pattern helps with integrating incompatible interfaces, the Factory Method Pattern manages object creation, and the Observer Pattern facilitates communication between objects in a decoupled manner. 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Sep 01 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.