Skip to main content
Context Object

Also known as

  • Context
  • Context Encapsulation
  • Context Holder

Intent

Encapsulate the context (state and behaviors) relevant to the user or the request being processed in order to decouple application components from the complexities of the environment.


iluwatarAbout 2 minBehavioralContextDecouplingEncapsulation
Execute Around

Also known as

  • Around Method Pattern
  • Resource Block Management

Intent

Execute Around idiom frees the user from certain actions that should always be executed before and after the business method. A good example of this is resource allocation and deallocation leaving the user to specify only what to do with the resource.


iluwatarAbout 2 minBehavioralClosureCode simplificationEncapsulationFunctional decompositionResource management
Extension Objects

Also known as

  • Interface Extensions

Intent

The Extension Objects pattern allows for the flexible extension of an object's behavior without modifying its structure, by attaching additional objects that can dynamically add new functionality.

Explanation


iluwatarAbout 3 minStructuralEncapsulationExtensibilityObject compositionPolymorphism
Facade

Intent

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Explanation

Real-world example

How does a goldmine work? "Well, the miners go down there and dig gold!" you say. That is what you believe because you are using a simple interface that goldmine provides on the outside, internally it has to do a lot of stuff to make it happen. This simple interface to the complex subsystem is a facade.


iluwatarAbout 3 minStructuralCode simplificationEncapsulationGang Of FourObject composition
Factory Kit

Also known as

  • Object Kit
  • Toolkit

Intent

Define a factory of immutable content with separated builder and factory interfaces.

Explanation

Real-world example

Imagine a magical weapon factory that can create any type of weapon wished for. When the factory is unboxed, the master recites the weapon types needed to prepare it. After that, any of those weapon types can be summoned in an instant.


iluwatarAbout 2 minCreationalDecouplingEncapsulationGenericInstantiationObject composition
Factory Method

Also known as

Virtual Constructor

Intent

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Explanation

Real-world example

Blacksmith manufactures weapons. Elves require Elvish weapons and orcs require Orcish weapons. Depending on the customer at hand the right type of blacksmith is summoned.


iluwatarAbout 2 minCreationalEncapsulationGang of FourInstantiationObject compositionPolymorphism
Model-View-Intent

Intent

MVI is a derivation of the original MVC architectural pattern. Instead of working with a
proactive controller MVI works with the reactive component called intent: it's a component
which translates user input events into model updates.

Explanation

MVI is a Reactive Architecture Pattern which is short for Model -View-Intent.
It introduces two new concepts: the intent and the state.
UI might have different states — Loading State, Fetch Data State, Error State,
and user events are submitted in the form of an Intent.


iluwatarAbout 2 minArchitecturalDecouplingEncapsulation