Software Development: When do you use publically available libraries?

I have seen many code repositories in my software development life (and I have not really been doing software development very long), and generally see two different types of code repositories:

  1. Extensively using public libraries even for the most simple of operations
  2. Everything is created from scratch and is managed internally

When I was programming this afternoon and I was looking at a number of code repositories I was wondering; when is it appropriate to use a public library, one that has been tested thoroughly and has potentially hundreds of contributors or do we just write up our own utility classes and methods, making it only available to projects that we work on? It is questions like these that have me stay up late at night, making it hard to go to sleep.

I primarily use Java at work and is one of the programming languages I use when working on my programming projects. Being so popular there are an insane number of super useful libraries out there with a range of purposes. So it is really easy if you are using Maven to manage these libraries and dependencies, and include them for use in your projects. For example, imagine you have the following scenario:

You want to check whether a String value is null or empty, and this is done in a number of places across the code repository before using this value at any time.

The code could look something like this, all over the repository:

String str = getSomeValue();
if (str != null && !("".equals(str))) {
	...
} else {
	...
}

Wouldn’t it be easier to import the Apache Commons package and use the StringUtils class and do this operation instead, having the StringUtils method referenced across the repository?:

String str = getSomeValue();
if (StringUtils.isNotBlank(str)) {
	...
} else {
	...
}

Sure they generally have the same structure and basically offer the same functionality, but I feel the second option is easier to understand and looks better (personal preference).

What I find the oddest though is when you see code repositories that have their own StringUtils class for example that has a method that does exactly this same check as the Apache Commons StringUtils class, just called differently. So we see this instead:

String str = getSomeValue();
if (StringUtils.isNotNullOrBlank(str)) {
	...
} else {
	...
}

Why not just use the Apache Commons class and methods? What benefits are there to writing your own utility classes unless there are specific operations that you need to perform that the public libraries do not offer? Why go out of your way to write your own caching class when you can use the easy to use, extensively tested and heavily documented Google Guava Cache? These are the types of questions I ask myself when I see utility classes that have one or two methods that do the same operation as publically available library class’s methods. Not only do you have to write the near identical code as the publically available class, but you also need to document the class and write up test harnesses for the class to ensure it works as intended. Most of the time the utility classes I see are not documented and/or there are no test harnesses so developers just assume “Yep, it looks like it should work, so we are good to go.“.

Let me know what you generally do when you work on projects. Do you use the publically available libraries whenever you can? Or do you write your own classes and methods even though you know there are the publically available libraries? If you fall into the latter camp, please let me know why. There may be a valid reason that I am just too ignorant or dumb to notice, because generally whenever I have the option I will always use the public library.

The MVP (Minimum Viable Product)

As I work on more side projects the concept/idea of a minimum viable product is becoming more and more important; especially for someone like me who generally builds products alone with limited resources. I have started, put on hold, never finished or completely shelved a large number of side projects since I started programming. The reasons range from I lost motivation (which is a shame) to I didn’t have a complete understanding of what the applications true purpose was anymore (poor planning and design) and how it would benefit the user (complete lack of understanding of the market and what users are after). The last one started to become very common and I needed a new way to approach my side projects. Working on something cool and fun is great and all but there is a high chance if you don’t have a clear picture of what you want to achieve and the minimum requirements needed to distribute your app to users then your enthusiasm will at some point dwindle away. Also if you start with an idea that is so big it can become daunting and you will never finish it.

I started taking a new approach to my side projects now. Whenever I start, I note down what I exactly want to build (at a high level only), how I feel it would benefit the users (very important to understand), and what are the minimum features needed to ensure that I can get it to user’s devices to make it worthwhile using in a timely manner (the details are important here). Not only is this process helping me focus and know exactly what I need to achieve but it also allows me to mentally picture a roadmap of sort. I can easily see that features A and B need to be done for the application to be worthwhile and features C, D and E can be easily added later in patches and with feedback from users I can continue to refine and craft an app better tailored to them.

Why am I posting this you may ask? Well several weeks ago I posted about how I am/was going to be working on either one or two new applications. In that time I managed to get a clearer picture of what I wanted to achieve, how it would benefit someone and what the minimum features needed to be implemented for it to be worthwhile. If I didn’t spend this time understanding this then my new project probably would have eventually been shelved at a later point and I would not have built an end to end product for people to use. With this new approach I not only get to showcase my skills with complete apps (fundamentally the absolute minimum to be worthwhile, but apps nonetheless) and provide a product people will hopefully find useful in a timeframe that isn’t insane.

Just in time for the start of the new financial year I will be releasing an alpha version of my bill tracking UWP app in either late July or early August for the Windows Store (more information about this when the release date gets closer). I have a very basic prototype up and running and will be working on refining that to be the final app (took under three hours to get something I wanted functional thanks to the great documentation Microsoft has on UWP development, C# and XAML). Until the app is released I will be trying to write more frequently covering certain aspects of the app, what I have enjoyed programming and what I have had difficulty doing. Stay tuned for that because July and August are going to be jam packed full of programming goodness.

%d bloggers like this: