04. Naming Conventions

Some languages make you use their reserved words and name the different elements of your project in a particular way but more often than not they simply give you some broad rules that dictate how you should go about it. The different aspects of your code you’ll likely have to name are:

  1. Constants
  2. Variables
  3. Objects/Elements
  4. Methods/Functions/Sub-Procedures
  5. Classes

Each language will usually have their own way of doing things so it’s hard to define a set of generic rules you should abide by, there are however, a few universal truths:

  1. Constants should always be named in UPPERCASE letters
  2. Classes should always start with a Capital letter
  3. Variables, methods, functions etc should always start with a lower case letter.
  4. If you wish to have multiple words in a name then separate them with underscores or utilise camelCase.
  5. Avoid using spaces and special characters when naming things even if the language allows it

Rather than give you too much to take in with this section I suggest looking up what the developers of the particular language you’re using suggest when it comes to naming. As with every aspect of formatting though remember to:

  1. Be consistent: Whatever you decide to use, use it always!
  2. Make it readable: Think about how someone else would interpret your names

### Conclusion ###
And there you have it. Four fairly simple but essential concepts needed to become a well-rounded programmer. While certainly not the most exciting element of programming I can assure you that solid formatting will allow you to spend much less time debugging your code and more time actually programming!

Leave a Comment

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>