4 Replies - 1279 Views - Last Post: 31 December 2014 - 03:40 PM

#1 leibniz76   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 89
  • Joined: 02-May 14

I'm reluctant to go back and brush up old code

Posted 11 November 2014 - 04:59 PM

As I write code and I discover ways that old code could have been written better I'm reluctant to go back and fix things. I want to move forward and get things done. Going back and polishing seems like not the best use of my time, even though I know in the back of my mind that it will make things easier. I tend to only go back and fix things when it becomes absolutely necessary. Do you have the same problem?
Is This A Good Question/Topic? 0
  • +

Replies To: I'm reluctant to go back and brush up old code

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5465
  • View blog
  • Posts: 14,418
  • Joined: 18-April 07

Re: I'm reluctant to go back and brush up old code

Posted 11 November 2014 - 05:10 PM

Actually, going back and brushing up old code is a very good thing to practice. Sometimes going back and looking at code (written by you in the past or anyone else's code for that matter) presents its own mind and skill expanding exercises. Get use to it too. If you work as a programmer in industry, you will be expected to go back and work on old code. Half of our job is maintaining existing code bases. No way to get around it.

But anyways, going back and reworking code and fixing things often presents unique challenges because you are forced to...

1) Come up with brand new solutions inside of given constraints. For example, you may need to update a function, but no matter what you do it must return an integer because other code relies on it to. So while it may have been better to return an object or string or something, you are forced to come up with a better solution that still yields an integer.

2) Come up with ways to fit new design patterns, structures and refactoring methods into existing code. It is easy to write something brand new with good practices, it is more challenging to take bad code and bring it up to current best practices. Then doing this without trying to introduce new bugs is what makes it difficult.

3) Forces you to evaluate multiple solutions and even more creative solutions. Given points 1 and 2 above, you can't just throw any solution in there like you can if you were writing brand new code. You are forced to evaluate multiple solutions and choose what is best, often having to defend your choice to stake holders.

Working with old code is going to happen and those who can adapt, come up with creative solutions and implement code upgrades to legacy systems is all hallmarks of a great programmer. Sometimes I like it even better because I have to actually write less, can think more and focus on a narrower scope of problem solving. Maybe a change is just to fix a function, not write a brand new subsystem for instance. One tweak and you are suddenly a rock star because a whole system starts working again.

:)
Was This Post Helpful? 1
  • +
  • -

#3 leibniz76   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 89
  • Joined: 02-May 14

Re: I'm reluctant to go back and brush up old code

Posted 12 November 2014 - 06:52 AM

I know you're right, I just have trouble implementing this.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,165
  • Joined: 12-June 08

Re: I'm reluctant to go back and brush up old code

Posted 12 November 2014 - 07:35 AM

Quote

Do you have the same problem?

No. A penny saved and all of that.


Quote

I just have trouble implementing this.

Then.. don't? If this is your own code base then the only person you are impacting is yourself.
Was This Post Helpful? 0
  • +
  • -

#5 kiasta   User is offline

  • D.I.C Regular

Reputation: 30
  • View blog
  • Posts: 287
  • Joined: 18-November 07

Re: I'm reluctant to go back and brush up old code

Posted 31 December 2014 - 03:40 PM

The programming director in our company has made some mistakes in particular with a product he has developed. It's going to have to go through a total overhaul because he didn't write it using standard design patterns and is not really user friendly or scalable. So going through old code is a good idea. You don't want to have to be the person responsible for deploying useless code because you didn't want to go back and change your code to begin with or at the very least optimize it.

Not sure what your point was on this but uh don't be lazy? *shrugs*
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1