To reuse or not to reuse

Eric S. Raymond once wrote in How to become a hacker:

No problem should ever have to be solved twice.

Indeed, reuse is one of the central ideals in computer science.

Yet when faced with the vast landscape of open source Java libraries and frameworks, I began to believe that it is sometimes better to solve a problem yourself than to rely on libraries. I have several reasons:

  • Libraries tend to be big, and they tend to solve more than just your problem. This inevitably leads to unnecessary code, with unnecessary dependencies which can easily lead to problems with the Java ClassLoader.
  • The people maintaining the library might have other priorities than you have. Even if it’s open source, it might be easier to maintain your own coherent piece of code than to dive into a huge project written by others.
  • By solving fundamental problems, you can improve your programming skills.
  • By solving your problem, you will understand it better and probably be in a position to chose the right library for it in a future project.

Of course, code reuse is important and there are things people should rely on libraries for. Nonetheless, solving the problem yourself can definitely be the better choice, and reuse is no commandment. Nowadays, software engineering often comes down to combining several different frameworks and libraries with rather simple code. Many programmers don’t seem to understand what’s happening anymore, and feel rather helpless when one of their libraries reports errors. I think that understanding of the underlying processes is vital in this field, and programming lower level logic can really help at that.

As soon as I have a bit of time, I’m finally going to get the Knuth and work on my basics.

2 Responses

  1. Well said. I would add that big libraries don’t only give you ClassLoader problems, but also give increase the time developers spend looking for the correct class to use for a certain task. If you’ve got a StringUtils from Apache Commons, Google Guava, as well as a home-made one, developers will use a random one every time.

Leave a Reply