• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

"Clean code" book question: refactoring always?

 
Ranch Hand
Posts: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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***
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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").
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic