There are many signs of bad code, repeatable code fragments, long methods, unclear variable names and so on... Many books have been written on the subject, nevertheless sometimes programmers can not agree whether specific code is good or bad. A few days ago I’ve got the idea of very simple and (in my opinion) good test allowing to check code quality in a few minutes.
That’s what you have to do: select randomly one of the classes and remove one of its methods, after that call one of the programmers and ask him to write removed method again, from scratch. That’s it :). If code looks the same way or almost the same way then everything is OK. If code looks differently than there is a problem. If nobody can implement removed method again then system needs refactoring. (You can also remove the whole class or a couple of classes, it would be also interesting experiment).
Small portion of philosophy behind. Good software is like bad movies. 100% predictable, 100% boring. Everything is absolutely clear from declarations. If so then it is easy to rewrite any code portion. On contrary, if code is complex and full of tricks then it is bad and difficult to repeat.

Perfect post.
ОтветитьУдалитьThanks :)
ОтветитьУдалить