Skip to main content
Active Object

Intent

The Active Object design pattern provides a safe and reliable way to implement asynchronous behavior in concurrent systems. It achieves this by encapsulating tasks within objects that have their own thread and message queue. This separation keeps the main thread responsive and avoids issues like direct thread manipulation or shared state access.


iluwatarAbout 2 minConcurrencyPerformance
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.

Also known as

  • Cache
  • Temporary Storage

iluwatarAbout 5 minPerformance optimizationCachingPerformanceCloud distributed
CQRS

Intent

Command Query Responsibility Segregation (CQRS) aims to segregate the operations that modify the state of an application (commands) from the operations that read the state (queries). This separation allows for more flexible and optimized designs, especially in complex systems.


iluwatarAbout 2 minArchitecturalEvent-drivenPerformanceScalability
Data Locality

Also known as

  • Cache-Friendly Design
  • Data-Oriented Design

Intent

The Data Locality design pattern aims to minimize data access times and improve cache utilization by arranging data in memory to take advantage of spatial locality. This pattern is particularly useful in high-performance computing and game development where access speed is crucial.


iluwatarAbout 3 minPerformance optimizationCachingData accessGame programmingMemory managementPerformance
Dirty Flag

Also known as

  • Change Tracking
  • Is-Modified Flag

Intent

The Dirty Flag design pattern is employed to avoid unnecessary computations or resource-heavy operations by maintaining a boolean flag that tracks whether the state of an object has changed ('dirty') or remains unchanged ('clean'). This flag, when set, indicates that a particular operation, such as recalculating or refreshing data, needs to be performed again to reflect the updated state.


iluwatarAbout 3 minBehavioralGame programmingPerformanceResource managementState tracking
Double Buffer

Intent

The Double Buffer pattern aims to reduce the time necessary for rendering and displaying graphical or computational data by utilizing two buffers. One buffer is used for rendering the next frame or computing the next set of data, while the other is used to display the current frame or data set to the user.


iluwatarAbout 4 minBehavioralBufferingGame programmingOptimizationPerformance
Double-Checked Locking

Intent

The Double-Checked Locking pattern aims to 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 necessary does the actual locking logic proceed.


iluwatarAbout 2 minConcurrencyOptimizationPerformance
Embedded Value

Also known as

  • Aggregate Mapping
  • Composer
  • Inline Value
  • Integrated Value

Intent

The Embedded Value design pattern aims to enhance performance and reduce memory overhead by storing frequently accessed immutable data directly within the object that uses it, rather than separately.


iluwatarAbout 2 minBehavioralData accessEnterprise patternsOptimizationPerformance
Flyweight

Intent

Use sharing to support large numbers of fine-grained objects efficiently.

Explanation

Real-world example

Alchemist's shop has shelves full of magic potions. Many of the potions are the same so there is
no need to create a new object for each of them. Instead, one object instance can represent
multiple shelf items so the memory footprint remains small.


iluwatarAbout 2 minStructuralGang of FourPerformance
Half-Sync/Half-Async

Intent

The Half-Sync/Half-Async pattern decouples synchronous I/O from
asynchronous I/O in a system to simplify concurrent programming effort without
degrading execution efficiency.

Class diagram

Half-Sync/Half-Async class diagram

iluwatarAbout 3 minConcurrencyPerformance