3 ms·
Can I solicit some dumbed down explanations of DCI? I've read a few articles about it, as well as the Wikipedia entry, and I still have no idea what it's all ab
by extension 15y ago
Can I solicit some dumbed down explanations of DCI? I've read a few articles about it, as well as the Wikipedia entry, and I still have no idea what it's all about.
- andrzejkrzywda 15y agoThe metaphore of DCI is a theatre. The context is the director. Chooses who plays what, instruct them how to do it and then let them play. Theory: 1. Expose use-cases (context) as first-class citizens of your code. 2. Each use-case selects which objects are needed for this use-case. 3. Extend the objects only with the roles that are needed in this use-case. 4. Start the interaction. Example: Buying a product. 1. UserBuysAProduct object, that can be executed. 2. Objects/actors needed: user, shop 3. Extend user with a Buyer role and shop with ProductCatalogue and OrderManager. 4. call shop.buy_product(user, product)
- extension 15y agoOk, so this is a way of decomposing just the domain model into smaller parts: a minimal model, role objects that extend it for particular purposes, and context objects that assemble a set of models and roles for a particular use case. The rationale is, presumably, that you can add and change particular use cases independently of each other and the core model. Right?
- andrzejkrzywda 15y agoYes, exactly. The idea is that the Data doesn't change that often, so it's kept separate from the things that change frequently - roles, use-cases. Exposing use-cases is also an important goal, usually they are scattered across the codebase.