3 ms·
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 h
by cjblomqvist 2y ago
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.
- begueradj 2y agoQuoted: "You can still not repeat yourself but violate single responsibility" (https://softwareengineering.stackexchange.com/questions/220769/how-is-dry-principle-applied-at-class-level-related-to-srp https://softwareengineering.stackexchange.com/questions/2207...)
- safetytrick 2y agoQuoted: "Likewise, you can repeat yourself but classes only have a single (duplicated, but subtly different) responsibility."
- vbezhenar 2y agoThe 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.
- deathanatos 2y agoI 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.