10 Tips for Writing Maintainable Code

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.

  1. Write short units of code: limit the length of methods and constructors
  2. Write simple units of code: limit the number of branch points per method
  3. Write code once, rather than risk copying buggy code
  4. Keep unit interfaces small by extracting parameters into objects
  5. Separate concerns to avoid building large classes
  6. Couple architecture components loosely
  7. Balance the number and size of top-level components in your code
  8. Keep your codebase as small as possible
  9. Automate tests for your codebase
  10. 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).

Leave a Reply

Your email address will not be published. Required fields are marked *