Skip to main content
Collecting Parameter

Name

Collecting Parameter

Intent

To store the collaborative result of numerous methods within a collection.

Explanation

Real-world example

Within a large corporate building, there exists a global printer queue that is a collection of all the printing jobs
that are currently pending. Various floors contain different models of printers, each having a different printing
policy. We must construct a program that can continually add appropriate printing jobs to a collection, which is called the collecting parameter.


iluwatarAbout 3 minIdiomGeneric
Combinator

Also known as

Composition pattern

Intent

The functional pattern representing a style of organizing libraries centered around the idea of combining functions.
Putting it simply, there is some type T, some functions for constructing “primitive” values of type T, and some “combinators” which can combine values of type T in various ways to build up more complex values of type T.


iluwatarAbout 3 minIdiomReactive
Double Checked Locking

Intent

Reduce the overhead of acquiring a lock by first testing the
locking criterion (the "lock hint") without actually acquiring the lock. Only
if the locking criterion check indicates that locking is required does the
actual locking logic proceed.

Class diagram


iluwatarLess than 1 minuteIdiomPerformance
Double Dispatch

Intent

Double Dispatch pattern is a way to create maintainable dynamic
behavior based on receiver and parameter types.

Class diagram

Double Dispatch

Applicability

Use the Double Dispatch pattern when

  • the dynamic behavior is not defined only based on receiving object's type but also on the receiving method's parameter type.

iluwatarLess than 1 minuteIdiomExtensibility
Execute Around

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.

Explanation


iluwatarAbout 1 minIdiomExtensibility
Lazy Loading

Intent

Lazy loading is a design pattern commonly used to defer
initialization of an object until the point at which it is needed. It can
contribute to efficiency in the program's operation if properly and
appropriately used.

Class diagram

Lazy Loading

iluwatarLess than 1 minuteIdiomPerformance
Mute Idiom

Intent

Provide a template to suppress any exceptions that either are declared but cannot occur or should only be logged;
while executing some business logic. The template removes the need to write repeated try-catch blocks.

Explanation

Real World Example


iluwatarAbout 1 minIdiomDecoupling
Private Class Data

Intent

Private Class Data design pattern seeks to reduce exposure of attributes by limiting their
visibility. It reduces the number of class attributes by encapsulating them in single Data object.

Explanation

Real world example

Imagine you are cooking a stew for your family for dinner. You want to prevent your family members
from consuming the stew by tasting it while you are cooking, otherwise there will be no more stew
for dinner later.


iluwatarAbout 2 minIdiomData access
Resource Acquisition Is Initialization

Intent

Resource Acquisition Is Initialization pattern can be used to implement exception safe resource management.

Class diagram

Resource Acquisition Is Initialization

Applicability

Use the Resource Acquisition Is Initialization pattern when


iluwatarLess than 1 minuteIdiomData access