Quick & Dirty Solutions Can Blow Up In Your Face

Few years ago, I have been asked to create a component to manage a collection of items for an embedded system. The specifications were well written (actually the best I've ever received) and the first release was ready in few months. During the development, I added a simple test function to be used during the development and also for troubleshooting when in the field.

That function was not designed to be used extensively. Since it was something to be called one-shot, it was acceptable that it introduced a delay in the sequence of operations done by the process.

Q&D Required

When the project was almost done, the team leader asked me for an additional function. Curiously, that function was very similar the one I've already done. But it sounded strange to me, so I asked why he needed such a function. Then I suggested other ways to do what he was asking me but he said that there was no time and we needed a quick and dirty solution.

Since I consider myself the king of the dirty solutions, I said "OK, but be careful to not use it frequently". The team leader's answer has been "Don't worry! At most once every five minutes". Guess what? In the worst case, that function is called over 150 times in five minutes. And, in the best case, it is called every five seconds.

[Damn! Even if I am an X-Files fan, I'm not able to apply the golden rule "trust no one"!]

Since the program was not designed to manage all those calls, I raised a flag and I said:

  1. "This is not the right way to use that function"
  2. "I don't see any reason to call it so frequently; are you sure it's correct?"
  3. "Let's find another solution".

And this is what I've been answered:

  1. "We need to do this way"
  2. "We need to do this way"
  3. "We need to do this way"

This forced me to spend weeks to completely change the logic behind my program, only to discover that there was a bug in the calling program. However, a function that was born as a simple test utility is today the most used one.

Lesson Learned

Quick and dirty solutions are wonderful and can help you many times, but should be used carefully. Moreover, never ever use them if the project is still in a development phase.

Cover image taken from Pixabay licensed under the Creative Commons Public Domain Dedication license.

Luca Sommacal

Luca Sommacal

Italian developer (mainly in C for embedded platforms), Linux learner, addicted to rock music, history, science and few other things. Follow me on Twitter

comments powered by Disqus