Re:DRY is an over-rated programming principle?
by bluejekyll on Thursday July 07, 2022 @10:15AM
(#32014391)
The CRAP that you’re referring to is really only solving for a very minor downside of SPOT (and DRY), and that’s the inconvenient connection of technically unrelated code. In my own experience it’s far simpler to disconnect two code paths (copy a function, change its signature, etc) than it is to connect them to achieve SPOT.
In your CRAP model it seems like you’d be relying on tests or assertions to verify the “protocol”, if I’m understanding that correctly. Which means finding all the places where something needs to be true and then testing for it. Seems like a lot of work and wouldn’t necessarily catch all those places.
Re:DRY is an over-rated programming principle?
by rmbyrro on Thursday July 07, 2022 @09:49AM
(#32014051)
I have a feeling the acronym won't help to push your idea for wide adoption.
Re:DRY is an over-rated programming principle?
by DonHopkins on Thursday July 07, 2022 @10:32AM
(#32014609)
It's always a good idea to use an acronym that people aren't embarrassed to say out loud, especially for extremely successful widely adopted award winning open source projects.
Just watch what happened when the OpenVDB project won the 2014 Academy's Scientific & Technical Achievement Award hosted by Margot Robbie and Miles Teller on February 7, 2015 at the Beverly Wilshire.
Re:DRY is an over-rated programming principle?
by 12thwonder on Thursday July 07, 2022 @08:51AM
(#32013401)
can you elaborate on what "protocol" looks like? or can you give us some example?
Re:DRY is an over-rated programming principle?
by BurningFrog on Thursday July 07, 2022 @11:01AM
(#32014970)
Not sure if it fits within the CRAP idea, but sometimes I just write a test asserting that all duplicative definitions of X are equal.
Re:DRY is an over-rated programming principle?
by gopher_space on Thursday July 07, 2022 @02:36PM
(#32017672)
> Occasionally, it's not clear if a single point of truth is entirely appropriate
Feels similar to the monolith/microservice discussion in that it's mostly context sensitive. I think the term "programming principle" is misleading, these are tools with specific applications.
In this case, I sometimes prefer a slightly different approach; let's call it CRAP - Cross Reference Against Protocol: instead of definitions effectively referring physically to the same point of truth, they are designed instead such that they simply cross reference against a protocol, warn if there has been a deviation in protocol giving the developer the opportunity to go back and correct as necessary, or otherwise allow it and manually sever the link to the protocol if one is no longer desired.
This prevents against SPOT's weakness (at the cost of some extra manual work / due diligence by the developer), which is accidentally enforcing future convergence in situations when previous convergence was incidental/accidental, and divergence should have been allowed to take place instead.