Re:DRY is an over-rated programming principle?
by BurningFrog on Thursday July 07, 2022 @10:57AM
(#32014912)
This is a pretty good description of the motivation for OOP.
[ Parent
| on HN ]
Re:DRY is an over-rated programming principle?
by galaxyLogic on Thursday July 07, 2022 @11:18AM
(#32015191)
Right, if the "truth" is encapsulated inside an Object, it is the single location for that truth.
If you want a "different truth" create another object. And never assume that the truths of different objects must be the same.
That is a difficult condition to achieve in practice we often code based on what we know a method-result "must be, therefore it is ok to divide by it etc."
Re:DRY is an over-rated programming principle?
by AnimalMuppet on Thursday July 07, 2022 @12:59PM
(#32016466)
Especially for an object that has to have some consistency between its members, all the code that has to maintain that consistency (or that can break the consistency, same thing) should be in the same place - functions of that class. So if you ever see a class that has the data in an inconsistent state, you have a very small set of places to look for the culprit.