A programmer's tale

Saturday, December 30, 2006

Digest of TIPS from Refactoring: Keeping the promise ;)

I'm very much infamous for breaking promises. I promise but glibly forget to keep it. Sometimes I'm paranoid with the thought that
Promise is made to break
But I'm dying to prove that I'm not bad in my "digital" life as in my "analog" life. Here, I promised to bring the TIPS of Refactoring from Martin Fowler's masterpiece "Refactoring". I'm going to keep that. Some of the words are ditto copy of the book.

Definition of Refactoring:
Refactoring has two definition depending upon the context.
Refactoring (noun):
a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.
Refactor (verb):
to restructure software by applying a series of refactorings without changing its observable behavior.
Why do we need Refactoring?
All the points are self-explanatory. The details discussion available in the book.
  • Refactoring Improves the Design of Software.
  • Refactoring Makes Software Easier to Understand.
  • Refactoring Helps us to Find Bugs.
  • Refactoring Helps us to Program Faster.

When do we need Refactoring?
  • When Add Function is to be added.
  • When need of Fixing a Bug arise.
  • When Code Review is to be done.

TIPS:

  • When you find you have to add a feature to a program, and the program's code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.
  • Before you start refactoring, check that you have a solid suite of tests. These tests must be self-checking.
  • Refactoring changes the programs in small steps. If you make a mistake, it is easy to find the bug.
  • Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

My thoughts:
Refactoring is a similar type of concept as Design patterns, but the purpose is different. As design pattern has it's catalog and vocabulary, Refactoring also has the same. But catalog of Refactoring is less known than that of design pattern; Refactoring concept came later then design pattern. Design patterns is handy during the design phase but Refactoring is useful during the maintenance phase. Refactoring prevents the decay of the software with time. Exhaustive discussion about Refactoring is available here: http://www.refactoring.com/

0 Comments:

Post a Comment

<< Home