menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Naming Thi...
source image

Dev

4w

read

342

img
dot

Image Credit: Dev

Naming Things in Code: Why It’s Hard and How to Do It Better

  • Naming code elements like variables and functions can be challenging, requiring precision and empathy for future readers.
  • Choosing clear, descriptive names is crucial for code readability and maintenance.
  • Variables should be named as nouns or noun phrases, reflecting the data they hold.
  • Functions or methods should be named as verbs or verb phrases, indicating the actions they perform.
  • Boolean variables should have positive names to avoid confusion, like using isEnabled instead of isNotVisible.
  • Distinguishing private or member variables using consistent naming conventions enhances code clarity.
  • Descriptive names trump short, cryptic ones to make code self-explanatory and easier to understand.
  • Consistent casing styles and naming conventions across projects promote readability and maintainability.
  • Using singular names for single items and plural names for collections contributes to code intuitiveness.
  • Good naming practices improve code readability, reduce bugs, and enhance collaboration in software development.

Read Full Article

like

20 Likes

For uninterrupted reading, download the app