Summary

Data-oriented design (DOD) is a way of structuring software around how data is laid out in memory and how it is processed in bulk. Instead of beginning with an object hierarchy and then asking how to make it fast, DOD begins with the access pattern: what data is touched together, how often, and in what order. In game-engine work this often leads to arrays of tightly packed data, fewer pointer-heavy object graphs, and more predictable iteration performance. (Llopis, Game Engine Gems 2 & 3, see source-game-engine-gems-2-3)

Key ideas

  • Cache locality matters: CPU time is often dominated by memory access, not arithmetic.
  • Favour contiguous data: Arrays and structs-of-arrays are often preferable to fragmented object graphs.
  • Process in batches: Update many similar items with the same code path rather than dispatching per-object virtual behaviour.
  • Separate data from behaviour when needed: Rich OOP models can obscure the actual memory layout and make optimisation harder.
  • Parallelism becomes easier: Bulk data transforms are easier to divide across threads or jobs.

In practice

OOP-style approach:

for (Enemy* enemy : enemies)
    enemy->Update();

Data-oriented approach:

for (size_t i = 0; i < enemyCount; ++i)
{
    positions[i] += velocities[i] * deltaTime;
    health[i] = std::max(0.0f, health[i] - damageOverTime[i]);
}

The second style is often less elegant at first glance, but it gives the CPU a far easier job.

Trade-offs

  • Strength: excellent for large homogeneous workloads such as particles, crowds, animation data, and broad simulation.
  • Strength: meshes naturally with ECS and job-based execution.
  • Weakness: can reduce local readability if every feature becomes a set of parallel arrays.
  • Weakness: not every system benefits equally; heavily bespoke gameplay logic may still be clearer with conventional object design.

Examples

  • particle systems
  • crowd or NPC updates
  • pathfinding node processing
  • animation pose data
  • ECS-style gameplay loops

cpp-classes-and-oop · cpp-memory-management · particle-systems-design · npc-performance-at-scale · source-game-engine-gems-2-3