(This relates to the problem domain I have previously elaborated on here - though the exact details are not that important for this question)
I'm writing an analysis application for Blockchain (DeFi) smart contracts to help me learn DDD.
The source of truth for data and state is in fact the blockchain. I can always go to a blockchain node and query it for the latest up-to-date state. I parse this state into domain objects to perform my analysis.
I now have two related questions
1) Given I have no need to mutate or track the state of my objects then should they just be value-objects?
All I need is to query the blockchain and build objects that reference each other from memory. I can at any point go back to the source of truth to construct the current state of them.
What confuses me is that in the domain of Blockchain and smart contract the business domain is the technology domain, and every "thing (deliberately not saying entity" yet) has an intrinsic unique ID namely it's address. And while the blockchain needs to most definitely track state/life-cycle of these "things" my app really doesn't care and can just record this contract address as yet another attribute/property.
2) What happens if I want to cache/store calculation results persistently?
Now although I can just go back to source the computation and parsing is "expensive". If I wanted to persist the model and calculation results in my own data store does the answer change?
In this case I'm thinking I'd almost create another model which I use to capture/freeze and store computed state at a point in time. It wouldn't make much sense to persist the entire complex data structure as all that is needed is some base properties and meta-information computed about them.
1 Answer 1
Sure why not? But if that’s the case you are going to be missing a significant part of the DDD experience: the aggregate root.
But if you don’t need one you don’t need one. DDD is not the one size that fits all. Maybe solve some other problems with DDD while you’re trying to learn.
As always, your real problem knows what you need far better than any book does. Let it teach you.
-
So the reason I thought DDD is a good fit here is that the calculations I need to do are quite complicated and depend on relations of "value objects" to each other. Therefore it helped me to model the business elements in this way. Example why I think DDD fits "a token value object needs to derive its value based on the ratio of it to another asset in a liquidity pool". That requires traversing multiple objects and inferring intermediate values on them. I believe VOs still give me that benefit even without needing aggregate assured consistencySev– Sev06/30/2021 06:08:15Commented Jun 30, 2021 at 6:08
In this case I'm thinking I'd almost create another model which I use to capture/freeze and store computed state at a point in time
this a change log and yes, all are value objects because all the entries points to the past. Like events in a event log.