Books, General, Programming, Refactoring

Code Simplicity


Code Simplicity by Max Kanat-Alexander is a thought provoking book on improving software code quality. As with many “philosophical” books (i.e. books not aimed at a specific technology) on software development the advice given here is not “hard and fast” and should not be considered as “rules” but rather as “guidelines” that developers should think about when writing code within their own context.

The book’s main theme is on the three flaws of software design.

  1. Writing code that isn’t needed (YAGNI)
  2. Not making the code easy to change
  3. Being too generic

These three flaws have some conflicting aspects and I think the developer needs to find the right balance. The author himself talks about these flaws in this great 4 part series on YouTube.  I suggest watching these short videos if you don’t want to buy the book (or perhaps buy the book after watching them :))

There are many other useful advice in the book such as;

 

It is more important to reduce the effort of maintenance than it is to reduce the effort of implementation

 

Never “fix” anything unless it’s a problem, and you have evidence showing that the problem exists

 

The ease of maintenance of any piece of software is proportional to the simplicity of it’s individual pieces

 

Strangely to me (call me nuts ;)) the most simple but most important line in the book was not about code quality itself, but rather the author’s answer to the question “What is the purpose of Software?”

 

The purpose of software is to help people….”not to make money” or “show people how intelligent I am”

 

Software developers (including yours truly) often ignore or forget this basic fact when designing and implementing software products. This most often results in a complex, over-engineered product that makes simple things hard for the end-user.

Advertisements
NetBeans IDE, Refactoring

NetBeans Refactoring Support


NetBeans has some great support for refactoring Java code.Recently I stumbled upon a nice feature when I wanted to do an extract method refactoring.

This is done easily by selecting the code segment you need to extract into a method and then right click and select Refactor/Introduce Method… menu option.

But then I was pleasantly surprised when NetBeans suggested to me that there are more occurances of the code I’m extracting into the method.

This came in handy as all the duplicate code (similar to the code I selected) was extracted into a single method in a flash!