Skip to content

Comment on How to Write Unmaintainable Code – Naming

Comments

Short variable names are fine with context. "cs : Customer list" - we know it's a list of customers from the type, no need to repeat. And a loop on it could easily be "for c in cs". Single letters are also useful in local or anonymous functions.

Reuse identifiers? Yes! If I've got a parameter foo that's a string, then I convert it into an int and never use the string again, why not rebind the identifier? It makes it clear the old foo is no longer in use, and prevents such use.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.