I always hear developers say "We must write good code" or "That code is bad" but what is good code and what is bad code?
First of all, we are engineers and what is engineering? A very basic description is: To solve a problem using the state of the art at the lower cost.
Now we have to find where the costs are in software development, the costs are mainly divided in two: creation and maintenance. Being maintenance the one that is the biggest by orders of magnitude therefore we need to lower the cost of maintenance.
We have found that TDD and some others called "good practices" help make software maintenance costs lower by reducing refactoring risks or making a well structured class system. Therefore a codebase with a 90% code coverage and a very low cyclomatic complexity isn't good code because it have those but because thanks to those it keeps it's maintenance cost low.
With all of this said we can say then that good code is the one that is cheapest to produce (being maintenance inside the production cost) and a good engineer is the one that can produces good code.
What are your opinions about this?