Good programming practices
Okay, let’s reiterate it again.
Good (for me!) programming practices (esp. #c++ #cpp or #cplusplus)
Every wonder why I have the same language name written in three different ways.
- 1-3: Editor setup
- 4-9: C++
- 14-15: Git
- Have a snipets for
cstarting template. i.e. I type cpp [HIT TAB] to get main function.
- Have a snippet for autocompleting
- Have a two space for tab. Why? deeper nesting will look back if
4 spacesis used.
- filenames: put it meaniful. I prefer
camelcaseis not allowed.
- variable and functionNames: Begin with a lower-case and camel-case if more words. functionName will have a verb in it.
- ClassName: Singular and begin with a upper-case.
- CONSTANTS: Use all upper-case letters. so as enums
- Use a good option (say
-d) to print debug info than meare print statements which require (un)commenting every time.
- If the program, is going to be used less (2 days or lesser) and needs quick run, you may use
using namespace std;and
- If the program, is going to be a library or some large project might use it in future, then ignore the above suggestion.
- Make sure every chunck (block or few lines) of the code you write is compile-able. DO NOT write and fix bug.
- Comment the non-obvious items. Possible exceptions that you missed and change log.
- Add compilation (or/and execution) commands at the top of the file if it is unusual
GitHubto track the issues, ideas and progress.
- Use your own file version numbering if