Computer Science, asked by cherryagarwal3601, 9 months ago

What do you think is most effective way to ensure that code adheres to good coding standards?

Answers

Answered by fiercespartan
1

For beginners in programming/coding, it is frequent and common to make mistakes and see the code having some bugs. It is fine to have mistakes, just try debugging the code. Everyone learns from mistakes. Be it in life or in coding

For coders who just started, it is the best to use either pycharm or jupyter notebook, these two softwares create the best environment for coding for beginners and they also have many options to debug the code written.

But anyway, if you want to write a code with good standards, there has to be no bugs and no loopholes. For example, you have to write a code to print the sum of all numbers between a given range but you write the code which works only if the limit is 1 and 10. This is an example of a loophole and in many competition or many projects this is not acceptable and cost one heavily.

Next, use comments for each line. '#' in python, '//' in java (I don't about C). Using comments can reduce the chances of the code being bugged and helps especially if you are writing a code which is VERY lengthy.

The next method is kind of embarrassing but is proven to work many times. It is called rubber ducky coding. What coders do is keep a rubber ducky beside the computer and if the code is being bugged, coders would explain the code to the ducky. By doing this, one can easily figure out the mistake he/she has done.It is sometimes effective to explain what you have done to someone to figure out the mistake rather than reading it to your self.

Next, use def() in python, these definitions can help a lot, you dont have to write the same code again and again if you use def() function.

Last, keep the code as short as possible. :)

Similar questions