The Artima Developer Community
Sponsored Link

Java Buzz Forum
Should you always refactor code?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
Should you always refactor code? Posted: Jun 8, 2006 6:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: Should you always refactor code?
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

I read this blog again today Things you Should Never do, Part 1

It reminded me of a chat I had with another developer the other day, he was discussing some legacy code and he came to the conclusion that we should really refactor all of these classes. I have to admit that I wasn't so keen. I enjoy refactoring, watching the code transform is quite enjoyable.

but.... (I know you saw that coming)

I wasn't so sure it was worth refactoring all this code because it did currently work. Although it would improve the code most of the code were a set of seperate actions and refactoring them wouldn't have much improvement on the other code. I think I basically felt that we could use our time more productivily doing other things. I was in favour of a bit like are new junit test writing policy, if you change the code, write a test. Now we also have if you change the code, refactor it.

Of course most of the code doesn't have unit tests for it either.  This can make writing a unit test and refactoring the code a bit tricky.

I appreciate that we will probably have to refactor the code when day and it maybe whilst fixing a bug but I had the line of agile programmers

"do the simpliest thing that works"

I was thinking the simpliest thing is to leave the code until we are in there for some reason. On the other hand though I can feel the code will leap up and bite us on the ass at some point in the future but if it does then we fix it and if it keeps working then let it keep working.

It is also a bit over whelming when you have quite a few classes to refactor, it feels a bit like writing the unit test after you have written the code, it becomes too much of an effort, an effort it seems at the time for no reward.

In the end we didn't really have a decision to make because we were busy working on a couple of projects but it got me thinking, should you always refactor code?  What code shouldn't you refactor. 

I suppose this must be a popular discussion between developers and talking about refactoring is a tricky subject because by its nature the outward benefits of refactoring are making the code easier to maintain, extend and reuse but it should do eactly the same as the smelly code you have removed.


This article talks about the decision in a more detailed manner than me


http://www.symphonious.net/2006/05/28/when-should-you-rewrite/

Read: Should you always refactor code?

Topic: Intel iMac - the best Java development box in the world Previous Topic   Next Topic Topic: Flickr: Waiting for Austin TimeBank Meeting to Start

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use