BCE: Who May Call Whom 📎
The most asked BCE question is not what the layers mean, but which dependencies are allowed. Inside a business component the dependencies point downwards.
- boundary to control, control to entity. The boundary offers coarse grained, easy to use methods, the control finer grained, reusable ones, the entity holds the data, as a smart domain object or an anemic record.
- boundary to entity, directly. A control is only needed for the more complex use cases. For the simple ones, skipping the control is the default.
- Never entity to control, never entity to boundary. An entity that needs something from above emits an event instead. Any layer of any component can process it, and the entity stays unaware of the receiver.
Between business components three cases matter:
- boundary to boundary: avoid it. A boundary is designed for external actors, not for other business components. Acceptable at the very beginning, later a control takes over.
- control to control: allowed, and direct. No interfaces in between required. In Quarkus and MicroProfile applications the control is injected.
- entity to entity: allowed. Relations between persistent objects would be impossible without it.
Then count the links. A component that communicates less with itself than with its neighbors was cut in the wrong place.
See bce.design for the pattern rules and sbce.dev for the spec-driven workflow built on it.
Episode 6 of the free Screaming Architecture with BCE series applies the rules to two components of the example project:
The full course is available at airhacks.io.