Active Object

Intent

The active object design pattern decouples method execution from method invocation for objects that each reside in their thread of control. The goal is to introduce concurrency, by using asynchronous method invocation, and a scheduler for handling requests.

Explanation


iluwatarConcurrencyPerformanceAbout 1 min
Caching

Intent

The caching pattern avoids expensive re-acquisition of resources by not releasing them immediately after use. The resources retain their identity, are kept in some fast-access storage, and are re-used to avoid having to acquire them again.

Explanation

Real world example


iluwatarBehavioralPerformanceCloud distributedAbout 4 min
Circuit Breaker

Intent

Handle costly remote service calls in such a way that the failure of a single service/component cannot bring the whole application down, and we can reconnect to the service as soon as possible.

Explanation

Real world example

Imagine a web application that has both local files/images and remote services that are used for fetching data. These remote services may be either healthy and responsive at times, or may become slow and unresponsive at some point of time due to variety of reasons. So if one of the remote services is slow or not responding successfully, our application will try to fetch response from the remote service using multiple threads/processes, soon all of them will hang (also called thread starvation) causing our entire web application to crash. We should be able to detect this situation and show the user an appropriate message so that he/she can explore other parts of the app unaffected by the remote service failure. Meanwhile, the other services that are working normally, should keep functioning unaffected by this failure.


iluwatarBehavioralPerformanceDecouplingCloud distributedAbout 5 min
CQRS

Intent

CQRS Command Query Responsibility Segregation - Separate the query side from the command side.

Class diagram

Applicability

Use the CQRS pattern when

  • You want to scale the queries and commands independently.
  • You want to use different data models for queries and commands. Useful when dealing with complex domains.
  • You want to use architectures like event sourcing or task based UI.

iluwatarArchitecturalPerformanceCloud distributedLess than 1 minute
Data Locality

Intent

Accelerate memory access by arranging data to take advantage of CPU caching.

Modern CPUs have caches to speed up memory access. These can access memory adjacent to recently accessed memory much quicker. Take advantage of that to improve performance by increasing data locality keeping data in contiguous memory in the order that you process it.


iluwatarBehavioralGame programmingPerformanceLess than 1 minute
Data Transfer Object

Intent

Pass data with multiple attributes in one shot from client to server, to avoid multiple calls to remote server.

Explanation

Real world example

We need to fetch information about customers from remote database. Instead of querying the attributes one at a time, we use DTOs to transfer all the relevant attributes in a single shot.


iluwatarArchitecturalPerformanceAbout 2 min
Dirty Flag

Also known as

  • IsDirty pattern

Intent

To avoid expensive re-acquisition of resources. The resources retain their identity, are kept in some fast-access storage, and are re-used to avoid having to acquire them again.

Class diagram

Applicability


iluwatarBehavioralGame programmingPerformanceLess than 1 minute
Double Buffer

Intent

Double buffering is a term used to describe a device that has two buffers. The usage of multiple buffers increases the overall throughput of a device and helps prevents bottlenecks. This example shows using double buffer pattern on graphics. It is used to show one image or frame while a separate frame is being buffered to be shown next. This method makes animations and games look more realistic than the same done in a single buffer mode.


iluwatarBehavioralPerformanceGame programmingLess than 1 minute
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


iluwatarIdiomPerformanceLess than 1 minute
Event Sourcing

Intent

Instead of storing just the current state of the data in a domain, use an append-only store to record the full series of actions taken on that data. The store acts as the system of record and can be used to materialize the domain objects. This can simplify tasks in complex domains, by avoiding the need to synchronize the data model and the business domain, while improving performance, scalability, and responsiveness. It can also provide consistency for transactional data, and maintain full audit trails and history that can enable compensating actions.


iluwatarArchitecturalPerformanceCloud distributedLess than 1 minute
2
3