Skip to main content
Marker Interface

Also known as

  • Marker
  • Tagging Interface

Intent

The Marker Interface pattern is used to convey metadata about a class in a type-safe manner. Interfaces in Java that have no method declarations are known as marker interfaces. They are used to indicate that a class implementing such an interface possesses some special behavior or capability.


iluwatarAbout 3 minStructuralEncapsulationInterfacePolymorphism
Model-View-Presenter

Also known as

  • MVP

Intent

MVP aims to separate the user interface (UI) logic from the business logic and model in a software application, enabling easier testing and maintenance.

Explanation

Real-world example

Consider a real-world analogy of the Model-View-Presenter (MVP) pattern using a restaurant scenario:

  • Model: This is the kitchen in a restaurant, where all the cooking and preparation of dishes happens. It's responsible for managing the food ingredients, cooking processes, and ensuring that recipes are followed correctly.

  • View: This represents the dining area and the menu presented to the customers. It displays the available dishes, takes orders, and shows the final presentation of the food. However, it doesn't decide what's cooked or how it's prepared.

  • Presenter: Acting as the waiter, the presenter takes the customer's order (input) and communicates it to the kitchen (model). The waiter then brings the prepared food (output) back to the customer in the dining area (view). The waiter ensures that what the customer sees (the menu and food presentation) aligns with what the kitchen can provide, and also updates the view based on the kitchen's capabilities (e.g., out-of-stock items).

In this analogy, the clear separation of roles allows the restaurant to operate efficiently: the kitchen focuses on food preparation, the dining area on customer interaction, and the waiter bridges the two, ensuring smooth operation and customer satisfaction.


iluwatarAbout 3 minArchitecturalArchitectureClient-serverDecouplingEnterprise patternsInterfacePresentation
Monad

Also known as

  • Computation Wrapper
  • Monadic Interface

Intent

To provide a mechanism for encapsulating computations or side effects, enabling the chaining of operations while managing context and data flow in a side-effect-free manner.

Explanation


iluwatarAbout 3 minFunctionalAbstractionAccumulationDecouplingEncapsulationFunctional decompositionGenericIdiomInstantiationInterfaceLayered architectureObject composition
Property

Also known as

  • Dynamic Properties
  • Property Bag

Intent

The Property design pattern allows dynamic addition, removal, or modification of properties of an object at runtime.

Explanation

Real-world example

Imagine a custom burger ordering system at a restaurant. Each burger starts with a basic configuration (bun, patty), but customers can add or remove various ingredients (cheese, lettuce, tomato, sauces) as they wish. The restaurant's ordering system uses the Property design pattern to handle this flexibility. Each burger object dynamically updates its list of properties (ingredients) based on customer choices, allowing for a wide variety of custom burgers without needing a fixed class structure for every possible combination. This ensures the system can adapt to any new ingredient without altering the core burger class.


iluwatarAbout 3 minBehavioralAbstractionEncapsulationInterfaceObject compositionPolymorphism
Role Object

Intent

To dynamically assign roles to objects, enabling them to change behavior and responsibilities at runtime.

Explanation

Real world example

Imagine a restaurant where staff members can take on different roles based on the needs of the moment. For example, an employee could be a server, a cashier, or a kitchen helper depending on the situation. When the restaurant is busy, a server might also take on the role of a cashier to help process payments quickly. Later, the same employee might assist in the kitchen during a rush. This flexibility allows the restaurant to dynamically allocate responsibilities to meet real-time demands, enhancing efficiency and customer satisfaction. The Role Object pattern in software mimics this by allowing objects to assume different roles and behaviors at runtime, providing similar flexibility and adaptability.


iluwatarAbout 3 minStructuralAbstractionDecouplingExtensibilityInterfaceObject compositionPolymorphismRuntime