← Back to portfolio·ECS vs OOP in game architecture
May 2025·5 min read

ECS vs OOP in game architecture

C#Game DevECS

I built the same prototype twice: once with classic OOP inheritance, once with an Entity-Component-System. The difference was stark.

OOP: clean until it isn't

Inheritance works fine for 10 entity types. By entity type 20, you hit the classic diamond problem — a FlyingEnemy that is also a Boss that also explodes on death. Multiple inheritance chains get ugly fast.

ECS: everything is data

In ECS, a "FlyingBossExplosion" is just an entity with a Position, a Health, a FlyBehaviour, and an ExplodeOnDeath component. No class hierarchy. Systems operate on components, not objects.

The mental shift is real: you stop thinking about what an entity IS and start thinking about what it HAS.

Performance bonus

Components of the same type live contiguously in memory. Cache friendliness is a free lunch. Unity's DOTS proved this at scale — I proved it at small scale.

When to use which

For tools and business apps: OOP every time. For games with many entity types that share behaviours in surprising combinations: ECS. Know the problem before picking the pattern.

MORE POSTS
Why I ditched Unity for pure C#
March 2025 · 4 min read
Making WPF not look like Windows XP
January 2025 · 3 min read
How I actually learn new tech
April 2025 · 3 min read