Is Entity Component System(ECS) a special case of DCI?

33 views
Skip to first unread message

Hai Feng Kao

unread,
Aug 25, 2024, 7:48:35 AM8/25/24
to object-composition
Brief introduction to ECS (from Wikipedia):
- Entity: An entity represents a general-purpose object. In a game engine context, for example, every coarse game object is represented as an entity. Usually, it only consists of a unique id. Implementations typically use a plain integer for this.[3]

- Component: A component characterizes an entity as possessing a particular aspect, and holds the data needed to model that aspect. For example, every game object that can take damage might have a Health component associated with its entity. Implementations typically use structs, classes, or associative arrays.[3]

- System: A system is a process which acts on all entities with the desired components. For example, a physics system may query for entities having mass, velocity and position components, and iterate over the results doing physics calculations on the set of components for each entity.

Similarities I've observed:

1. Separation of Concerns:
   - ECS separates components (Data) from systems (Behavior).
   - DCI separates what the system is (Data) from what it does (Interactions).

2. Runtime Object Composition:
   - ECS allows for dynamic composition of entities with different components.
   - DCI enables objects to take on different roles in various contexts at runtime.

3. Behavior Externalization:
   - ECS places behavior in Systems, external to the data (Components).
   - DCI places behavior in Interactions, separate from the core Data.

4. Context-Dependent Behavior:
   - In ECS, Systems operate on entities with specific component combinations.
   - In DCI, data assume roles with specific behaviors in different contexts.

5. Flexibility and Modularity:
   - Both patterns aim to create more flexible and modular systems.

Potential Correspondences:
- ECS Entity + Component ≈ DCI Data
- ECS System ≈ DCI Context + Interaction

Key Differences:
- ECS has more rigid structures (Entity as unique ID, Systems acting on all matching entities).
- DCI focuses more on roles and context, while ECS emphasizes component-based composition.

Could ECS be viewed as a specific implementation or variation of DCI principles?

James O Coplien

unread,
Aug 25, 2024, 11:08:06 AM8/25/24
to noreply-spamdigest via object-composition


On 25 Aug 2024, at 13.48, Hai Feng Kao <khai...@gmail.com> wrote:

Could ECS be viewed as a specific implementation or variation of DCI principles?

I don’t think so. In particular, point #2 is really a superficial similarity with much different semantics between the two.

Matthew Browne

unread,
Aug 25, 2024, 3:33:42 PM8/25/24
to object-co...@googlegroups.com

Yeah I was thinking the same thing about point #2 (just based on the description in the OP). Objects encapsulating their own behavior (at run-time) is a pretty central part of DCI. If it takes multiple objects to do what DCI does with one object, that's a pretty big difference.


--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/object-composition/36CFB133-D039-4ACC-8A50-78A5D0E9831B%40gmail.com.

Lund Soltoft

unread,
Aug 26, 2024, 1:46:56 AM8/26/24
to object-co...@googlegroups.com
It sounds like DCI turned inside out (point #2). Instead of the role behaviour being encapsulated in the role, it’s externalised in a “component”. Another way of viewing it is that the identity is lost. 

So though it seems from a decomposition point of view ECI does try to decompose along similar boundaries it looses a central point of DCI, the preservation of identity, because of the way the decomposition happens

Mvh
Rune

Den 26. aug. 2024 kl. 01.03 skrev Matthew Browne <mbro...@gmail.com>:


Reply all
Reply to author
Forward
0 new messages