0

Why do we do refactoring? What are the benefits of refactoring? What problems can be avoided by performing refactoring the code of a software tool?

mikerobi
  • 20,527
  • 5
  • 46
  • 42
Raj
  • 3,051
  • 6
  • 39
  • 57
  • 5
    Why do we clean up our rooms frequently? – Pekka Oct 27 '10 at 16:29
  • 2
    @Pekka - I don't. I mean, it's just gonna get dirty again, duh. – Rob Hruska Oct 27 '10 at 16:31
  • 1
    @Pekka, because some of us don't live with our moms ;) – mikerobi Oct 27 '10 at 16:32
  • There are plenty of resources. Such as [A book on refactoring](http://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read/13332#13332)... – ircmaxell Oct 27 '10 at 16:33
  • I'm sorry, I misunderstood what refactoring is. Delete if you'd like. – Raj Oct 27 '10 at 16:34
  • See [What is the best way to explain refactoring to non-technical people?](http://stackoverflow.com/questions/3138823/what-is-the-best-way-to-explain-refactoring-to-non-technical-people) – Jonas Oct 27 '10 at 16:34
  • @Pekka, you clean your room frequently? – Abe Miessler Oct 27 '10 at 16:34
  • 1
    Why do people ask stupid homework or test questions on SO? – DVK Oct 27 '10 at 16:34
  • 1
    @Raj: You can delete it yourself. I guess. – Jonas Oct 27 '10 at 16:35
  • @Raj, I think this is a perfectly legitimate question. I think some people just like to downvote to feel superior. – Abe Miessler Oct 27 '10 at 16:36
  • 2
    @Abe ummm... Well, not as often as I should. :) – Pekka Oct 27 '10 at 16:36
  • 1
    @Abe the question *is* legitimate, but it is put in a way that *sounds* like somebody got tasked with doing some research (especially the "what problems can be avoided" bit), and is looking to "outsource" that research to us instead of reading the relevant Wikipedia article. That is sometimes met by some indignation, rightly in my mind. – Pekka Oct 27 '10 at 16:37
  • 1
    @Pekka, it does sound like homework. I just don't get why some of those questions get polite suggestions to add the homework tag and others others get rude comments from people like @DVK and downvotes... @Raj, doesn't appear to have much experience on SO and instead of trying to help him along everyone blew him out of the water. – Abe Miessler Oct 27 '10 at 16:41
  • @Abe: The difference is that sometimes these homework questions - even though they are obviously homework - are asked *after the OP has made some research or tried to implement it himself*. Questions which obviously weren't researched on are often punished with downvotes and unkind comments... – NikiC Oct 27 '10 at 16:47
  • @Raj, is this a homework/test question? If so please add the "homework" tag to your question. As you may have gathered from the negative reception, the SO community prefers that you do SOME research on your own before coming here with your questions. You will get a much better response in the future if you do this. – Abe Miessler Oct 27 '10 at 16:51
  • This was no homework or test question. I am far far out of college and school. However fundamental and obvious the question may have been I wanted others perspective on it. One thing is clear though: Stack Overflow is not a place to ask questions and get helpful responses at all. – Raj Oct 28 '10 at 05:29

1 Answers1

3

While developing an application it often happens that your goals change. Especially if a non-technical person is your client it often happens that through his bad description you are going to modify the code again and again.

At some point everything will get really messy and needs cleanup - that's refactoring.

NikiC
  • 100,734
  • 37
  • 191
  • 225