Recently I came across a very good book on writing maintainable code: https://amzn.com/1491953527.
This book is written by very experienced authors (from Software Improvement Group – SIG). What I like about this book is, it condenses the experiences of the authors in 10 specific guidelines. Based on my experience working in real-world code and trying to improve the code, I felt that the selection of best practices is really good and stands out.
- Write short units of code: limit the length of methods and constructors
- Write simple units of code: limit the number of branch points per method
- Write code once, rather than risk copying buggy code
- Keep unit interfaces small by extracting parameters into objects
- Separate concerns to avoid building large classes
- Couple architecture components loosely
- Balance the number and size of top-level components in your code
- Keep your codebase as small as possible
- Automate tests for your codebase
- Write clean code, avoiding “code smells” that indicate deeper problems
The examples in this book are in Java, and a C# version is also available (https://amzn.com/1491954523).