Re:Against Best Practices
by cjblomqvist on Monday November 18, 2024 @07:33AM
(#42171817)
A nit; DRY is probably not what you think it is. DRY is basically the same as SRP, framed differently. In SRP, it's totally valid to have the code twice if it has different meaning from a user pov.
[ Parent
| on HN ]
The problem with definition is that it's subjective and cannot be checked automatically. So my definition was about mechanistic DRY, which is objective and checked by linter.
Quoted: "You can still not repeat yourself but violate single responsibility"
(https://softwareengineering.stackexchange.com/questions/2207...)
Re:Against Best Practices
by safetytrick on Monday November 18, 2024 @06:06PM
(#42178144)
Quoted: "Likewise, you can repeat yourself but classes only have a single (duplicated, but subtly different) responsibility."
Re:Against Best Practices
by deathanatos on Tuesday November 19, 2024 @02:15AM
(#42180770)
I think it's the same thing, but I usually postulate DRY as semantically identical code, not merely syntactically identical.
"Byte for byte equivalent" doesn't necessarily mean it's a copy, if the semantics of it are different.