Bad naming can do a lot of damage. Names that lie, mislead, or obfuscate will confuse a programmer, or at least make her work harder to get the job done.
I think a name is "good" when you don't have to examine what is behind the name to know what it does. It doesn't have to add additional value, it just has to avoid obfuscation. For example:
void AThenB() { A(); B(); }
If you see
AThenB()
in code, you'll know exactly what it does. Not a great name, but not a damaging name, either.This is the minimum bar when naming a new entity in code. It's not a hard bar to meet. You can often do way better. But never check in any code that doesn't meet this bar.
JBrains calls it it "accurate names".
Arlo Belshee calls this "tweetable names":
A fn is tweetable iff I can tweet the name sans context and you will write exactly the same body. Untweetable code is crap.
— Arlo Belshee (@arlobelshee) December 12, 2014
1 comment:
Post a Comment