Purpose of Having Coding Standard:
• A coding standard gives a uniform appearance to the codes written.
• It improves readability, and maintainability of the code and it reduces complexity also.
• It helps in code reuse and helps to detect error easily.
Using readable name for variable not only effective to be read by user but also make the code clean from bunch of comment. It doesn’t matter on what language the code is, as long as the user know what it is for then its good.
If there isn’t a comment about where “lat” and “lng” is from then its harder to analyze what is it for.
With proper variable name there is no need to be commented because its clearly says what is it for.
Global Variable, Local Variable and Constant Variable have its own purpose to be declared.
Global variable can be used on all function, but then can also be changed between one function and another. It also can only be declared once, therefore must be used wisely. Camel case naming style can be applied, be with capital on first word or not.
Local variable is effective to be used on one function that doesn’t connect to each other. It consumes less memory and also didn’t collide with other function even if using the same name. Snake case naming style can be applied for local variables. Its not only differentiate from global, but also make it readable even if it contains specific subject to be used.
Constant variable must be written using all-capital to make it easy to read and to be configured. Its better to gather it on one specific module or header and give a simple explanation within.
Handling an error could help to minimize time to trace a problem. Using error return can improve time and energy when debugging, it also increases performance of the system and decide what to do when it is occurred. It can be implemented on top to prevent recursive with function break or at the end of the process.
Debugging with IDE like ArduinoIDE might be beneficial that it can use time from its own operating system, but not all people using it. Although debugging is important to trace some function, process or/and an error that occurred on. Using simple debugging is good as start, but when applied to more complex system its necessary to put another aspect on debugging. Time and function name could make it faster to discover and specific its address one to another.
A proper indentation can make code cleaner and easy to read. It also easy to trace what’s function or section is error and fix it immediately. It might be not really important if the code is programmed using C/C++ since as long as the syntax is correct it will be compiled without an error but when moving to higher language such as python it might be crucial. It also create a habbit on programmer to follow standardized structure that applied on professional scene.
Within this example user cannot even differentiate which bracket each if statement is and debugging it would be more hassle to do.
Made with
Landing Page Software