I can’t scientifically say what makes code “good”, but my gut has a few things to say about it:
- good code reflects the problem it solves
- good code can be easily understood by programmers without experience in your language
- good code is generally short
- good code doesn’t require much thinking to understand
- good code has very little coupling
- good code is cohesive - definitions of functions and types required are not scattered throughout the software
- good code documents any requirements for proper usage
- good code makes just as much sense to you one year from now, as it does now
All of these properties I feel could be summed up simply as: “good code is reusable”, and taken a step further: “really good code is so simple it can be reused by a trained seal.”.
What do you feel are other properties of good code?