Thursday, March 15, 2012

Bad Cs of Code Quality


Coupling: This indicates that the different packages are interlinked and the concerns are not separated.
A single change may require changes in multiple disparate packages/modules.
This makes the system fragile to changes
Copied Code: Code that is copied all over the place is bad code.
It causes unexpected errors. The developer will typically fix in one place and forget to fix it at other places.
Developer gets bored fixing it in all the locations.
Comments (What?): If we find comments which says what a piece of code is doing or explains the code it is bad comment and bad code.
If the developer feels that she needs to explain what the code is doing then it is not clear code and that is not good.
Colossal: If the code blocks are big then then it is bad code even if it addresses the functionality
Large blocks of code (classes, methods) are bad news as they make reading difficult
Complexity: If a code is too complex (cyclomatic complexity) it is bad code
High degree of Cyclomatic complexity means that testing the code become as much difficult and this in turn puts a doubt on the tests conducted.

No comments: