Why do we need software interfaces?

The need for software interfaces is driven by the reality of what happens in a living software system. There are certain events that can be considered regular occurrences, like: maintaining, extending, and testing of code. The goal is to limit the amount of effort, time, money and risk involved when handling these events. This can be achieved by choosing a sound design. Making use of interfaces in your design will put you on the right track to reach these goals!

  1. Code that is easily maintainable: Code that changes can be considered as one of the constants in the programming realm.

So the code needs to change, big deal you say! So I change a few ifs and elses… and presto? Well, it is a bit of an abstract concept to grasp if you have not been exposed to fairly large systems or even computer systems in general. One can easily argue “so I have a little program that says “hello world” when it runs. It should be no serious effort to change this to “hello beautiful world”, and this is indeed true! The difference being that the silly example above is very far from what is the reality in computer systems of scale. The reality is that systems tend to grow and expand pretty quickly, and by doing so they become ever bigger and more complex. A trivial change in one place could end up affecting numerous other parts of the system, in a badly designed system. This is unwanted side effect and is one of the regions where interfaces help out to make these changes easier and less of a nightmare.

2. Extensiblity: Another certainty will be the expansion of your system.

Similar to the reasons explained in the above, extending your system can be considered a change. For example, to “bolt on” new functionality. The same problem surfaces here again, in the sense that adding new functionality to your system could prove to be a nightmare if your system design was not good. This could imply that you need to change your system in numerous places. This is usually the result of “tight coupling”, meaning that software pieces are interweaved. This could result in a chain of changes all across the system when you are changing one thing in one place. This in turn causes a possibly larger than wanted test scope and larger deployment. Both of the latter are undesired in the software world. Both cause an increase in needed resources (time, money) and also risk!

3.Testing of your Software

I think it is pretty clear from the above, that it is all about change! As in other manufacturing disciplines things that are changed or made have to be tested, and no surprise, in the software world it is no different. Here interfaces can play a big role in making things easier, limiting the pieces of the system that actually gets affected by the change, which in turn leads to a smaller test scope. Interfaces also makes testing of certain functionalities, that usually would be a nightmare, possible. Consider testing a piece of code needing to handle a potential hard drive failure, or a full disk scenario. This is covered in the section on unit testing.

Leave a comment