Sobes.tech
Junior

What design patterns do you know?

sobes.tech AI

Answer from AI

  • Creational:

    • Singleton: ensures a class has only one instance and provides a global point of access to it.
    • Factory Method: defines an interface for creating an object but allows subclasses to decide which class to instantiate.
    • Abstract Factory: provides an interface for creating families of related or dependent objects without specifying their concrete classes.
    • Builder: separates the construction of a complex object from its representation so that the same construction process can create different representations.
    • Prototype: specifies the kinds of objects to create using a prototypical instance and creates new objects by copying this prototype.
  • Structural:

    • Adapter: converts the interface of a class into another interface clients expect.
    • Bridge: decouples an abstraction from its implementation so that the two can vary independently.
    • Composite: composes objects into tree structures to represent part-whole hierarchies.
    • Decorator: dynamically adds responsibilities to an object by wrapping it.
    • Facade: provides a unified interface to a set of interfaces in a subsystem.
    • Flyweight: uses sharing to support large numbers of fine-grained objects efficiently.
    • Proxy: provides a surrogate or placeholder for another object to control access to it.
  • Behavioral:

    • Chain of Responsibility: passes requests along a chain of handlers. Each handler either processes the request or passes it to the next handler.
    • Command: encapsulates a request as an object, allowing parameterization of clients with different requests, queuing of requests, or logging of requests.
    • Interpreter: defines a grammatical representation for a language and an interpreter to interpret sentences in the language.
    • Iterator: provides a way to access the elements of a collection sequentially without exposing its underlying representation.
    • Mediator: defines an object that encapsulates how a set of objects interact.
    • Memento: captures and externalizes an object's internal state so that the object can be restored to this state later.
    • Observer: defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
    • State: allows an object to alter its behavior when its internal state changes.
    • Strategy: defines a family of algorithms, encapsulates each one, and makes them interchangeable.
    • Template Method: defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.
    • Visitor: represents an operation to be performed on the elements of an object structure.

Also familiar with GRASP (General Responsibility Assignment Software Patterns) patterns.

What design patterns do you know? — Java - sobes.tech