Skip to main content
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
Flyweight

Intent

The Flyweight pattern's primary intent is to reduce the number of objects created, decrease memory footprint and increase performance by sharing as much data as possible with similar objects.

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 3 minStructuralGang of FourMemory managementObject compositionOptimizationPerformance