Wednesday, May 5, 2010

Refactoring: less is best

Every programmer has probably done code refactoring at least once in their lifetime. It's not something that they enjoy doing but it must be done in order to keep the program up-to-date or with new features being added. The best way to reduce the amount of refactoring is to write clean code. Doing it right the first time reduce the amount of work you will have to do in the future. It might take longer the first time to write clean code compare to sloppy code, but the extra time spent doing it will save countless hours of refactoring in the future.

As a student programmer, we tend to write quick sloppy codes that satisfy the requirements of the program. That's because we tend to have the mentality of writing the code once, get a passing grade, and we'll never have to look at it again. This practice is "okay" in an academic sense, but its a failure as a programmer in the real world. Codes produce in the real world are constantly being reviewed, reused, and refactored by yourself and others. So save yourself time, stress, and humiliation by doing it right the first time around.

If your a java programmer, I recommend getting or reading "The Elements of Java Styles". Its a great book that gives pointers on writing clean Java codes. I'm sure that there are similar books for other programming languages that you could read to improve on writing cleaner codes.

0 comments:

Post a Comment