3 ms·
In the Clojure world, this used to be a popular way to structure backend apps: https://github.com/stuartsierra/component https://github.com/stuartsierra/compone
by fulafel 7y ago
In the Clojure world, this used to be a popular way to structure backend apps: https://github.com/stuartsierra/component https://github.com/stuartsierra/component
> Components provide some basic guidance for structuring a Clojure application, with boundaries between different parts of a system. Components offer some encapsulation, in the sense of grouping together related entities.
> Each component receives references only to the things it needs, avoiding unnecessary shared state. Instead of reaching through multiple levels of nested maps, a component can have everything it needs at most one map lookup away.
- TeMPOraL 7y agoUsed to be? What replaced it? I used it in my last Clojure project, and I'm about to start expanding it further; should I replace it with something else?
- fulafel 7y agoIt's fine, hasn't just been getting much press lately.
- heretoo 7y agotry integrant https://github.com/weavejester/integrant https://github.com/weavejester/integrant You can move from using component's functions/macros to using a map and cross references using reader literals. Having used both, I find integrant to work better for me.
- dkersten 7y agoStuart Sierra components and ECS components are not really the same thing though. They share the name “components” but not thaaat much else. Stuart Sierra Components are more akin to Unity’s behaviour components prior to their introduction of an ECS. They’re a way of encapsulating state which may have dependencies and has a lifecycle (needing to be started or stopped). ECS components are purely blobs of (usually fine grained) state, the existence and combination of which in an entity creates behaviours (that is, the systems which implement the behaviour will dynamically do so for any entity that has the prerequisite components, but the components are just data). I always preferred naming ECS components as “traits” (they are the traits that an entity has, eg “animated”) and the systems “behaviours” (they are the behaviours exhibited by entities that have certain traits).