On Conflicting Principles
Contents
“Think about them of course, but not as absolute rules” — Gary Bernhardt
SOLID, Tell Don’t Ask, Law of Demeter, DRY, and many more principles guide the entire programming communities for decades, but do they conflict with each other? Of course!
I myself have been going back and forth between using Model (or Domain) objects vs Services or Functional Services for, like, 7 years. I still don’t know exactly when to choose which based on logic, I just choose either one mostly based on my instinct.
Is what I chose good or bad? I absolutely don’t know at the time. I will know sometime later after it’s been on production for a while until the first or the second change let me think that the design may be badly flawed.
But if I’ve learnt something over a decade of my programming experience, it’s that you can’t know everything in advance, and the good or bad design depends heavily on your knowledge of the domain, in which it may also constantly change — and that you should be ready for the changes.