This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is refactoring?

 
John Mallavalli
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Refactoring? I am pretty new to this topic. So please can any one out there throw some light on this.
Thanks in advance.
cHeErS,
John
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the Refactoring Home Page
http://www.refactoring.com/
Regards
 
Wouter Zelle
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically a set of methods you can use to simplify your code, making it easier to test and maintain. XP suggest that you write a test, code, refactor, write a test, code, refactor, etc. In other words: first define what you want to achieve, get it working next and then make it clean and maintainable.
Refactoring by hand is a chore, a good way to learn it is to get a nice IDE with refactoring support. IntelliJ IDEA, for instance. Here is a list with many refactoring tools.
 
John Mallavalli
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys..
ChEeRs,
John
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Wouter Zelle:
It's basically a set of methods you can use to simplify your code, making it easier to test and maintain. XP suggest that you write a test, code, refactor, write a test, code, refactor, etc. In other words: first define what you want to achieve, get it working next and then make it clean and maintainable.

You don't need to use this development cycle to get value from refactoring, though.
Refactoring is accommodating the fact that program design invariably degenerates over time. So if you have to clean up the code regularly if you don't want to end with a "ball of mud".
The "Refactoring" book is showing indications of design problems (so called "code smells") and providing solutions to remove them in tiny little steps. The purpose is to evolve the system to a better state while sustaining its perceived behaviour and having a working system every couple of minutes.
Like the Design Patterns book, it also gives the patterns names (like the "Jealousy" code smell iirc), simplifying communication between developers.
IMO the book is a definite must-have.
 
Wouter Zelle
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to use this development cycle to get value from refactoring, though.

True, it's just a guideline. I usually just refactor when a smell hits me in the face. The point I was trying to make was that refactoring, coding and testing are strongly related. Refactoring makes your code easier to test and expand with new features. So you should really be doing it while coding.
Don't create seperate tasks in the future where you will be refactoring parts of your code (unless it really is a mess ), do it when you see a problem. Refactoring is coding.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic