Dependencitis
Dependencitis

Whenever a development problem looks like it can be solved by bringing in a new external code dependency I think it can be beneficial to wait a moment and think it through. Most of the times it does make sense and the functionality provided by code that is tested and used widely shadow any issues with increasing the project list of external code.

Some other times the use of yet another dependency is just a sign of sloppy or lazy thinking. Let me provide you with an example.

The purpose of the following code is to obtain a InputStream from a String. The code was written by a developer with whom I had to work. This developer didn't seem understand java.io, something I consider to be a base know-how for a Java developer.

Here's the mentioned developer solution:

    1: import java.io.InputStream;
    2: import org.apache.commons.io.IOUtils;
    3: 
    4: /* a class definition, some methods, and finally: */
    5: 
    6:         String abc = "ABC is just the beginning...";
    7:         InputStream is = IOUtils.toInputStream(abc);
    8: 
    9: /* and more code.. */

IOUtils comes with the great library commons-io from Apache commons. That dependency was brought into the project in question just for this purpose. There's no other usage of the library in any other part of the project.

Now here's is a somewhat different way of achieving the same result:

    1: import java.io.InputStream;
    2: import java.io.ByteArrayInputStream;
    3: 
    4: /* the same class definition, the same methods, and finally: */
    5: 
    6:         String abc = "ABC is just the beginning...";
    7:         InputStream is = new ByteArrayInputStream(abc.getBytes());
    8: 
    9: /* and the rest of the code */

Notice how no dependency is used and the exact same result is achieved. IOUtils.toInputStream does almost exactly the same as in this last code example.

I have seen this happening more and more (sometimes with dependencies that are a lot heavier than commons-io) and I believe it's one of those sign that the developer is out of his depth. I see it happening so often that I actually decided to coin this with a new word: dependencitis.

dependencitis
a symptom that a developer is using google to search for copy&paste solutions instead of using the grey matter trapped inside his skull to come up with more appropriate code

A developer is only as good as his knowledge of the tools of his trade.