Skip to content

Instantly share code, notes, and snippets.

@delbetu
Created November 29, 2016 15:47
Show Gist options
  • Save delbetu/a5285175b63f7b73b5245e7231d1974a to your computer and use it in GitHub Desktop.
Save delbetu/a5285175b63f7b73b5245e7231d1974a to your computer and use it in GitHub Desktop.
Uncle Bob best practices - Naming

#Names

Names are a powerfull tool for communcating your intent

If you have to put a comment to explain your name then you chose a bad name

Make sure the a names says what it means and means what it says

If you have to read the code to undertstand what it means that is a bad name

Use pronounceable names because other people will talk about your code

Avoid encodings like hungarian notation zpsBlah...

Code must be read as proses so to figure out a name for your class think of where and how it will be used. Make sure a line of code it looks like and read like a sentence.

  • variables are nouns
  • class names are nouns
  • functions/methods are verbs
  • booleans are predicates isCommited()

The scope rule variable names should be short if they are in a short scope variable names should be long if they are in a long scope(global variables should be very long)

function names should be short if they have a short scope(public) function names should be long and descriptive if they have a short scope(private) Same for class names Nice short names for public classes Longer names for private classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment