|
|
|
|
|
by gluczywo
3443 days ago
|
|
Naming is related to scope and I'm surprised there is so little about it in the article. While trying to find an universal principle I came up with this rule: "identifier's entropy should be proportional to its scope". Global variables (if any) are long explicit phrases while inner loop variables can be a single letter. Without taking scope into account the naming guidelines become dogmatic and impractical trivia. EDIT: wording |
|
I actually really like reading/writing code that uses really small variable names but are still very obvious given it's context (usually never acronyms though, I despise those). I'd always rather working with something small like p1 rather than something very descriptive like sceneOffsetPoint1, especially if I can read the code above it that shows it being assigned based from the scene center point: let p1 = scene.center + Point(2,3);