Difference between GOOD code and BAD code
Information, 14 Sep 2016, 06:50am GMT
When writing code in any language, there are good coding practices and there are really bad ones. Both may be correct as far as compiling and when run, but bad code can present some problems in development, debugging, and modifying. No matter how well your program runs, someone will have to read and/or alter your code at some point. They may have to add new features, correct a rare bug, or just want to read it to understand how it works. Similarly, you will have to read someone else's code to do the same thing.
Difference between good code and bad code lies in, at least, two major aspects: style and intent. The word "style" here not in its traditional meaning, as in fashion, but as a programming style, which can be bad, OK and great. Where, "intent" is an aspect, closely related to style. However, the main point here is not elegance, but readability. Good code requires minimum efforts from a reader to understand the author's intent. As per machine aspect good code take less resource and less time to process a task than a bad code. In good code, the parts are each individually of high quality, and also fit together seamlessly and runs smoothly. In case of bad code, the individual parts are shoddy, and they're jammed together in a way that makes no sense, which cause it to runs rough, and not for long.
Qualities of a good code -
Qualities of a bad code -
How do you know you're writing good code?
When you have to go back and add/modify a feature, is it difficult?Do you constantly break existing functionality when making changes? If the answer to the above is "yes" then you probably have a poor overall design. It is a bit difficult to judge a design until it is required to respond to change.