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:
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:
- Constants should always be named in UPPERCASE letters
- Classes should always start with a Capital letter
- Variables, methods, functions etc should always start with a lower case letter.
- If you wish to have multiple words in a name then separate them with underscores or utilise camelCase.
- 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:
- Be consistent: Whatever you decide to use, use it always!
- 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!