Over a million developers have joined DZone.

Are You Getting Worked up Over Code Duplication?

As programmers, we have long learned that Duplication is the Ultimate Sin of programming. Even considering to duplicate something is almost unthinkable.

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

As programmers, we have long learned that Duplication is the Ultimate Sin of programming. Even considering to duplicate something is almost unthinkable.

But removing duplication introduces dependencies. If you and I use the reuse the same piece of code instead of duplicating it, changes I make may affect you. This effect can anything from beneficial (I fixed a bug you also needed fixing) to benign (I added a new feature that you’re not using) to detrimental (I want it to work in a way that’s no good for you).

When we have dependencies, we have to think: “Perhaps I shouldn’t add that feature – what if breaks something for someone else?” “Damn the torpedoes, I’m hacking it in!” or “Perhaps I’ll just make a fork for my changes and we’ll merge later”.

Sometimes benign, sometimes harmfull.

I recently discussed with a friend the case of being innovative in the face of legacy code. Remember: Legacy code is code that you don’t want to touch, because it’s dangerous to change and it gives value to the business now.

We want to gradually build a new platform. So it seems like we have two choices: We could make the new code call functionality on the old platform (ick! because, you know, “stop digging“) or we could build a new service and change the old system to use it (OMG! because, you know, “dangerous to change”).

If we allow the new system to duplicate as much functionality as needed from the old system, this false dicotomy goes away.

Duplication isn’t a cardinal sin. It’s a negative property, but in many cases, it could be your best option.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:
java ,php ,ruby ,python ,c# ,javascript ,web dev

Published at DZone with permission of Johannes Brodwall, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}