2 ms·
What you're talking about has nothing to do with modularity. You're thinking of DRY. They having nothing to do with each other. DRY tells us the code for looki
by tantalor 13y ago
What you're talking about has nothing to do with modularity. You're thinking of DRY. They having nothing to do with each other.
DRY tells us the code for looking up a user id by user name should be written in only one place, not that the code should be called from only one place.
The mistake was assuming the name->name function was idempotent, because it wasn't.
You are right to suggest using a name->id function instead. It would not suffer the same problem because the canonical name should not be stored... it's an implementation detail!
- Confusion 13y agoThey having nothing to do with each other. DRY tells us the code for looking up a user id by user name should be written in only one place, not that the code should be called from only one place. If you write 'canonicalize(username)' in eight different places, you are not being DRY. If you need to write 'canonicalize(username)' in eight different places, your code probably doesn't separate responsibilities properly across separate modules. As such, they have a lot to do with each other. After all, if you call code from more than one place, you are writing the calling code in more than one place. Lack of DRYness is about the fact that you are doing so. Lack af modularity is about why you need to do so.