Return to site

📐 DESIGN PATTERN: Marker

· pattern

The ______ Pattern is a design pattern that uses empty interfaces or classes to mark objects with specific attributes or requirements at runtime.

* Marker

* Twin

* Decorator

* Bridge

#design #pattern #marker

https://www.udemy.com/course/master-software-design-patterns-questions-and-full-answers/?referralCode=D6366BB829DB93970447

Key points about the Marker Pattern:

Marker Interface: It defines an empty interface or class that serves as a marker. Objects that implement or inherit from this marker interface are marked with a certain attribute or requirement.

Metadata or Behavior: The marker indicates that the marked objects should possess specific characteristics or behavior, which can be checked at runtime.

Example: An example of a marker interface is the Serializable interface in Java. Implementing this interface indicates that an object can be serialized, and it allows serialization frameworks to treat objects accordingly.

Usage: Marker interfaces are typically used to enable conditional behavior, such as enabling or disabling specific operations, during runtime.

The Marker Pattern can be a simple and effective way to add metadata or behavior to objects without changing their class hierarchy or structure. However, it's important to use marker interfaces judiciously, as they can introduce tight coupling and may not always be the most maintainable solution.