No actual Unity reading material but inspired by new features in coming out in 2018
3 Big Lies, or Why Data Oriented?
- Despite the many layers of abstraction, code still runs on hardware and thus, not all data layouts are equal
- Code modelled after the real world does not actuall add value
- “Real world objects” approach does not scale, every instance costs the same instead of leveraging economies of scale
- Code is ephemeral and has no actual value in and of itself, the data and the data transformation are valuable
- Entities avoid hierarchies through composition, and are essentially a list of components
- Component is primarily data (some proponents say methods belong, others say no), must have property defining type, and means to find “containing entities” at runtime
- Systems are where the logic is implemented, operating on the components they are equipped for (i.e. a movement sytem should be equipped to operate on position and velocity components)
ECS benefits and anti-patterns
- Implementation inside components is a misconception, it is better for the component to be purely a blueprint
- Putting/inheriting methods is a component - this is an anti-pattern as calling inherited virtual methods defeats the data-oriented benefits of ECS (efficient in memory, good for multi threading)
- Instead, systems should be responsible for required methods and threading synchronization
- Use of inheritance via components prevents difficult inheritance questions and deep hierarchies
- Almost non existant examples of usage apart from game development
- Communication between systems/components is not defined, but event based approach can work
- For applications, ECS is not as well defined as MVC/MVVM et al.
- Uses other than games include simulations of large scale systems