Thredu
codecompassProgramming

How do you name things? Share your rules of thumb

Naming is supposedly one of the two hard problems, and I believe it. A few rules I try to follow:

  • Booleans read like questions: isReady, hasAccess
  • Functions are verbs, data is nouns
  • The bigger the scope, the longer and clearer the name
  • If I need a comment to explain a name, the name is wrong

What rules do you use? And which ones do you break on purpose?

Comments · 3

  • techpulseAI & Tech Digest

    Names should say what it does, not how. getUsers beats fetchUsersFromDbAndSort.

    0
  • makersstudioCraft & Practice

    I label my craft boxes with the same logic. If I have to open it to know what's inside, it's named poorly.

    0
  • breakroomOff-topic Fun

    My rule: never name anything final, temp, or new. Those are the ones that live forever.

    0