Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declarative Domain Model possible (DDD)?

I'm looking for insight/ papers/ articles, etc. whether a fully declarative Domain Model (as per DDD) is possible.

For example:

  • Validation can be declarative (lot's of ORMs do this)
  • business flow logic can be declarative: having a DSL for defining a workflow / Finite State Machine / process manager / DDD Saga (whatever you want to call it) on Crud-operations, through ddd-repositories most likely
  • decision logic can be declarative. I.e: most of the time this boils down to simple conditionals
  • derived / calculated fields could be done declaratively but is as bit tricky, especially when this cascades. I.e: you'd have to keep a dependency graph on the calculated fields, etc. Still it can be done.

Any links to people having actually tried that, or some convincing couter-arguments why this can't be done?

p.s.: Please don't answer with "Yes it can be done, since a FSM is Turing-complete with enough memory bla bla"

like image 626
Geert-Jan Avatar asked Jan 13 '23 06:01

Geert-Jan


1 Answers

"Everything is a nail if you hold a hammer"

Instead of asking if it is possible - ask: What are the reasons I want to do this particular thing declaratively?

Data validation is a nice thing to do declaratively. You have a DTO, you add some attibutes, everything is clear and readable.

Business flow done declaratively... Reminds me of a great failure of Windows Workflow Foundation. Is anyone actually using it? What is the benefit of making a behaviour-centric components in a declarative way? Imperative way seems to be well-fitted to this. Decision logic... maybe. But again - why?

"derived / calculated fields could be done declaratively but is as bit tricky" Why do you want to do tricky things when there is a way of achieving the same result with straightforward things?

So why? Do you need to change the behaviour of the app in runtime by editing some config file? OK, go for it.

Do you have a generic domain that will be used by many clients and you need some reconfiguration to fit them? Ok, but you need to clearly distinguish the unchangeable core of your domain and the varying stuff. Don't try to make all the things configurable - you'll end up with Inner Platform syndrome.

Do you believe you can make a declarative language your client could use to change his domain without a need for a programmer? No. You will fail. I know a language which was supposed to be like this. An easy, declarative language that ordinary accountants would use to explore their data. It's called SQL :D

like image 66
Bartłomiej Szypelow Avatar answered Jan 17 '23 16:01

Bartłomiej Szypelow