Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: List of helpful words for naming variables (github.com)
4 points by dcolkitt 12 days ago | hide | past | web | favorite | 1 comment





Great list to start with, but IMHO you need to embed as much information into a variable name as reasonably possible. If that doesn't seem possible, then maybe split the variable into a composite object with clearer properties.

Additionally, another good way to name variables is to compose them from understandable sub-name parts. For instance, I personally prefer boolean variables to have "is" or "has" prefixed.

    isAdmin = true;
    hasDiscount = false;
To me it's easier to understand, than the simplified:

    admin = true;
    discount = false;
Code is interpreted by computers, but understood by humans...



Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: