Skip to main content

Don't Build it Yourself

This post discusses the whether to buy or build software components needed for your application. The title should give you a clue as to which side of the discussion I land on.

Someone Else's Code

One of the behaviors that I've noticed is significantly more often exhibited by junior developers versus more experienced ones is the tendency to build everything from scratch. While I can appreciate the enthusiasm for wanting to create something better than has been done before, this is often simply a waste of time. For many of the software tasks you will want to accomplish, someone will have made a library of framework that does 95% of what you want out of the box, lets you configure or extend it to do another 4.9%, and you come to realize that 0.1% remaining wasn't all that important anyway. In fact, with the proliferation of open source software, many of these software packages are 100% customizable because you have access to all of the source code and can change it at will.

Using someone else's code (in compliance with the license agreement) is one of the best optimizations you can make in terms of efficiently getting a software product out of the door or even getting an automation script for your own purposes up and running. I have learned this lesson the hard way, and it took me several experiences to really begin to grasp the concept. Here are a few case in point examples:

Case Studies (or Mistakes I've Made)

Android Game Development

Using code from a book as a starting point, I once implemented significant portions of a game engine to run on Android for a school project. My team ended up with a sort-of-working, clunky-looking version of the classic game Breakout. Another team used an existing game engine framework, and produced a really polished platform game starring a cute little penguin. Their game looked like it could have been put in the Google Play store and actually made some sales. Ours looked like garbage that people would have demanded a refund for even if they had acquired it for free.

They had the same amount of time to develop their game as we had, and while I don't know for certain, I strongly suspect they expended little to no more effort than we did and did not have significantly greater skill than we did. Much of their success was gained by starting much further along by building on someone else's framework.

Matrix Multiplication in Python

I've filed this in the really stupid ideas folder. I implemented matrix multiplication and some other statistical functions in Python. It was very challenging to get it right, and I spent many hours doing it. I am sure there are still some inputs for which the code I wrote will break. You should never do this, especially not in Python, which has a huge standard library and over 100,000 packages that can each be acquired with a single command. If you ever need to multiply matrices in Python, just install Numpy and be done with it.

Synchronizing Animations with Music for Mobile Apps

To code synchronized animations with music, I used basic 2D drawing methods to draw different frames in a cyclical animation. I set up my own timer to fire off events at intervals I manually calculated based off of the beats per minute rate of the music. The code was brittle and inefficient. It worked sometimes until a change needed to be made, and then it would break, requiring hours of debugging and rework to get it running again. Again, don't do this. Use one of the many frameworks available for 2D animation.

Buy Instead of Build

As much as we learn these lessons over time, that charm of creating from whole cloth is often still lurking. We're software developers, and we take pride in our abilities and in our work. We're often tempted to think we can build something from scratch to better suit our needs and do it as well or better than what is readily available.

Often this is a fallacy in and of itself. Really, think about it! There are companies that are wholly dedicated to building a given library, framework, backend or middleware product. They have dozens, sometimes hundreds of developers working on these products full time for years. The company itself may have decades of experience building similar products such that they have learned what works and what doesn't and all of the pitfalls to avoid because they have fallen into them before. Do you really believe that you, or your small team, will be able to create something better given that it is only going to represent a small portion of the overall product you are trying to build, and that you only have a proportional amount of time and resources to spend building it yourself?

Some Math Worth Doing Yourself

You also can't justify building it yourself economically. Your time is valuable; you should value it. Let's say you are a developer making $50 an hour. Perhaps there is a library that will be very useful to your application. You can invest 500 hours, or about 3 months of work, developing it yourself from scratch. The cost of this would be $25,000. Conversely, you could spend 175 hours, or about 1 month, configuring and integrating a third-party library to do the same job. This will cost $8,750 plus whatever you must pay for the third-party library. For a library of this scale, you can probably find it for free. Even if not, it is extremely unlikely you would need to pay in excess of $1,000 for it. The bottom line is that your time is the expensive part. The ready-made software is cheap.

This is because the cost of software is allayed by distribution. Developing software is far more costly than we would often like to admit, but distributing it is extremely inexpensive compared to other products. When you develop your library for $25,000, your product is the only benefactor, so the cost for your product to consume the library is $25,000. When someone else builds the library, they can distribute it to many different users at almost no additional cost. If it costs them $75,000 to build the library, but they distribute it to 10,000 users at $10 each, they are money ahead. You will also be money ahead if you buy and use their $10 product rather than spending $25,000 worth of your time to build your own version.

The Bottom, Bottom Line

Focus on the aspects of your project that are unique to your project. If you find yourself spending a significant amount of time writing utility code or the like that has a more general flavor to it, spend a little time searching to see if someone else has already done the work for you. You can save yourself thousands of hours over the long run by doing this.

Comments

Popular posts from this blog

Books That Have Influenced Me and Why

A mantra that I often repeat to myself is, "Don't abandon the behaviors and habits that made you successful." I believe this trap is actually much easier to fall into than most people realize. You can sometimes observe it in the context of a professional sporting event such as American football. One team might dominate the game, playing exceptionally well for the first three quarters. Then, as they sit with a comfortable lead, you see a shift in their strategy. They start to play more conservatively, running the ball more often than they had. Their defense shifts to a "prevent" formation, designed to emphasize stopping any big plays by the other team while putting less pressure on the short game. The leading team often looks awkward in this mode. They have switched their perspective from that of pursuing victory to that of avoiding defeat. They have stopped executing in the way that gained them the lead in the first place. I have seen more than one game ult

Code Maintenance Requires More Than Testing

Writing and running automated tests can go a long way to help maintain the quality and reliability of a code base. Tests help ensure the code you've written executes the way you expect it to. However, even though automated tests are a great tool for helping to ensure quality over the years in which people will contribute to the code, they are not sufficient in and of themselves. It may be inevitable that all software products will reach a point of obsolescence no matter how much work is done to keep them current. The inherent problem is that if we view tests as constraints upon what the software system under test can be, then as we add more and more tests over the years, we will have more and more constraints on the shape our software is allowed to take. It then seems we must reach an inevitable point where we can no longer change our software system without violating a constraint, i.e. causing a test to fail. In more practical terms, we'll more likely first reach a situat

Notions of Debugging

Bugs can be really evasive and produce some surprising, even "impossible" behaviors. Part of a software developer's job is to relentlessly hunt them down and destroy them. However, often at least half the battle is finding them to begin with. The best debuggers I have seen rely a lot on experience, both experience with the application and experience with debugging in general. The former is situation-specific, and there many not be any good ways to advance in that regard other than practice. However, we can extract some information pertaining to good debugging practices in general. Dig for Clues Using All Available Resources The first step in debugging an issue is ideally to reproduce the problem. This isn't always possible, but if you want any significant level of confidence that you have fixed a bug, you need to observe the broken behavior and understand how to trigger it from a user's perspective. Sometimes we're lucky, and a tester has taken the time to