3 ms·
A sort of reverse or corollary to DRY, “don’t be unintentionally repeatable.”
by Pulcinella 4y ago
A sort of reverse or corollary to DRY, “don’t be unintentionally repeatable.”
- Jtsummers 4y agoIt's more of an extension to "Don't use globals", but at a more fine-grained level. Code using this can still be DRY, if you understand DRY to be "don't repeat the same information excessively". Reusing the same variable name in multiple (similar or dissimilar) contexts is not a DRY violation in that sense if the names are more a coincidence than actual shared information. Most programmers have no problem, for instance, with seeing multiple loops declared like: for(int i = ...; ...; ...) { ... } `i` is "repeated", but there's no objection in having multiple declarations since each has a meaning dependent on its local context.