Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Embrace Your Legacy Code. But Only Once

DZone's Guide to

Embrace Your Legacy Code. But Only Once

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

If you have to deal with legacy code (and we all do) one of the standard techniques to deal with it is to hide it behind a layer of abstraction.

While this is a valid pattern that helps in many cases, it comes with its own anti pattern.

I call it Legacy in an Onion.

It’s what happens when every generation of developer considers whatever they find to be horrible legacy code.
So they create a layer of abstraction. The next generation considers the abstraction to be legacy and adds another layer of abstraction.
After a couple of generations all the different layers start to cause serious problems when trying to understand the code and possibly even when executing it.

So the next time you encounter legacy code and want to add a layer of abstraction, rub the legacy code a little. Maybe you can peel of a layer of abstraction. If you find such a layer, you have multiple options:

  • Improve it so it fits your needs
  • Replace it with your layer
  • Directly work with the stuff below the layer

Just don’t add a layer of abstraction just for the sake of adding a layer of abstraction.

 

From http://blog.schauderhaft.de/2011/09/25/929/

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

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 }}