DevOps Zone is brought to you in partnership with:

Matthias Marschall is a software engineer "Made in Germany". His four children make sure that he feels comfortable in lively environments, and stays in control of chaotic situations. A lean and agile engineering lead, he's passionate about continuous delivery, infrastructure automation, and all things DevOps. Matthias is a DZone MVB and is not an employee of DZone and has posted 38 posts at DZone. You can read more from them at their website. View Full User Profile

Do Code Improvements Add Value?

03.29.2013
| 5257 views |
  • submit to reddit

Investing into code improvement is a dual edged sword: on the one hand you know that if you don’t improve your code you’ll get slower over time. On the other hand improving your code does not deliver tangible value to your users. So how do you know whether you’re on track?

Track the time a user story needs from idea to production

If that time is getting longer you’re off track: your code is slowing you down. It’s time to invest more into improving your code.

Measure the number of bugs per code push

If that number increases, you’re investing too less into code quality. Build quality in by writing automated tests upfront and by streamlining your code base. Rip out over-complicated stuff which people fear to touch because it breaks every time they do.

Are you spending too much time gold plating your code?

If the above measures do not move in the right direction even though you’re trying to keep your code as clean as possible you’re optimizing the wrong stuff. Try to find those areas in your code which are worth improving and focus your improvement efforts there.

Don’t try to improve stuff which is never touched again

It’s only worth changing even the worst piece of code if you’re going to touch it again. While it sounds like a good idea to ensure that all your code adheres to your coding standards, that’s not feasible most of the time.

Make sure you put the right measures in place to find out whether you’re investing too much or too less into improving your code. What is your strategy to balance new features against code improvements? Please leave a comment below.

Published at DZone with permission of Matthias Marschall, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Manrico Corazzi replied on Sat, 2013/03/30 - 4:55am

I do believe the practice of refactoring (which can sometimes be left to automatic tools) and improving your code will in the end lead you to writing better code from scratch. 

Throw away code - the script you whip out in a hurry to clean up the effin' XML files - is great and I agree you can forget about it, but every line of code that you "won't ever touch again" (and I really would like to know how can you decide that beforehand) is a line of code that ends up being read by you and your co-worker two months from now. 

So: ok, delay refactoring when you are rushing to a deadline, but don't trick yourself into thinking that it won't come back to bite you in the long run.

Matthias Marschall replied on Sat, 2013/03/30 - 8:11am in response to: Manrico Corazzi

Thanks Manrico for your comment.

I believe in building quality in from scratch by following red-green-refactor. Code you build should be clean before you commit it.

What I'm referring to in my article is code which is not clean or not adhering to your current coding standards. Even though you're trying to do your best with every piece of code you write today, your standards and your skills will change over time. And people touching your code will come and go and will have different coding styles and skills to write clean code.

Sooner or later you'll have to decide whether to adapt an older piece of code or not.

- Matthias

Manrico Corazzi replied on Sat, 2013/03/30 - 8:41am in response to: Matthias Marschall

Good point. "Coding standards" and "skills growth" are important things to weigh in. I must admit to over-polishing a piece of code just because it did not appeal to my aestethic sense. Thanks, Matthias.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.