Skip to main content

Coding Convention Tips to Keep Track of

· 2 min read
Hamza Hussein

Nothing quite kills the joy in programming like silly mistakes do – be it a missing semicolon or faulty logic planning. However, some of these minute blunders can be rectified simply through bolstering your ‘coding style’. Every programmer has a variation of their own modus operandi, but a programmer worth their salt will tend to have these following tricks well-embedded into their programs:

Concise Commenting

Everyone knows commenting is a must. You would lose marks on your labs if you left your program especially ambiguous, right? But the importance of proper commenting stems past these labs – well-structured comments show their true potential when working on more long-term projects. If you took a break for a week off your computer, would you still remember exactly what every function on your program does? Unless the answer is “yes”, commenting remains a very valuable tool to keep the apt programmer in the know.

Ideal Indenting

Much like commenting, the concept of indents has most likely been hammered into your head since high school. But, in case you haven’t already heard of it, proper indentation is one of the most important techniques you can employ in your coding style. This is because it can drastically improve readability to humans, which may not only be you. If you want your TAs to have an easier time grading your work, make sure they can tell when your loops begin and end!

Variable Titles and Terming

Last, but not least: naming your variables and functions. Naming your variables unsuitably may not disadvantage the computer in any way, but it’ll certainly give your TA a reasonable basis to cross out some free marks on your final product. When creating a new variable or function, try not to resort to overly short or lengthy names. Name it appropriately to its functionality without going overboard with the description. Of course, exceptions exist: “i” and “j” are considered good style if your program only has a few loops. Proper naming comes with practice and intuition!