Long Names Are Long – journal.stuffwithstuff.com
But, anyway, that's not what this is about. Heck, it's not even about Dart. What I want to talk about is something I see in a lot of code that drives me up the wall: identifiers that are too damn long.
Yes, names can be too short. Back when C only required external identifiers to be unique up to the first six characters; auto-complete hadn't been invented; and every keypress had to be made uphill, in the snow, both ways; it was a problem. I'm glad we now live in a futuristic utopia where keyboard farts like p
, idxcrpm
, and x3
are rare.
But the pendulum has swung too far in the other direction. We shouldn't be Hemingway, but we don't need to be Tennessee Williams either. Very long names also hurt the clarity of the code where they are used. Giant identifiers dwarf the operations you're performing on them, are hard to visually scan, and force extra line breaks which interrupt the flow of the code.
Long class names discourage users from declaring variables of that type, leading to massive, gnarly nested expressions instead of hoisting things out to locals. Long method names obscure their equally important argument lists. Long variables are annoying to use repeatedly, leading to sprawling method chains or cascades.
I've seen identifiers over 60 characters long. You could fit a haiku or a koan in there (and likely enlighten the reader more than the actual chosen name did). Fear not, I am here to help.
Read full article from Long Names Are Long – journal.stuffwithstuff.com
No comments:
Post a Comment