GeeCON Prague 2014*
The moose likes Agile and Other Processes and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark ""Clean code" book question: refactoring always?" Watch ""Clean code" book question: refactoring always?" New topic
Author

"Clean code" book question: refactoring always?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hi,

Many times we get some application whose code is not very well written, but the application is working fine.
Do you think is it a waste of time refactoring something like this, if the whole application was written in a way you consider not so clean?

Thank you.


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 467
IMHO, if you have the time, ALWAYS refactor. You would certainly be in the situation where you need to maintain that code, and then you will be in deep S***


Visit my blog: http://jnassef.blogspot.com/
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
My rule of thumb is (and I think I learned that at least partly from Uncle Bob) that code that I touch should be in a better shape when I'm finished with it then it was before.

Refactoring code that I don't need to touch, or making the code "perfect" immediately can be fun, but often isn't viable economically, and sometimes even risky.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Robert Martin
Author
Ranch Hand

Joined: Jul 02, 2003
Posts: 76
Originally posted by Rogerio Kioshi:
Hi,

Many times we get some application whose code is not very well written, but the application is working fine.
Do you think is it a waste of time refactoring something like this, if the whole application was written in a way you consider not so clean?

Thank you.


It is not a waste of time to refactor ugly code. You don't want to turn that refactoring into a whole project of it's own however. Rather, every time you touch that code, you should clean a little bit of it. Every time you check it in, make sure it's cleaner than when you checked it out. (This is the "Boy Scout Rule").


---<br />Uncle Bob.
 
GeeCON Prague 2014
 
subject: "Clean code" book question: refactoring always?