Example of FAIL Project

I’m working on an existing project for the past few months and will be working on it for the next few months or years. I can’t review much on the project I’m working but one thing I could tell is the project is not my personal project and it’s not related to the projects I’ve been working on (which is related to MeeGo, Harmattan, Linux and so on).

Yes, as the title of this post suggest, I’m going to write an example of a fail project. And yes again, you guess is right, the fail project is the project I’m currently (and will be in the future) working on. So how does it fails?

Timer driven instead of event driven

The first and foremost reason it fails because the whole software is timer driven instead of event driven. A good example of the difference between a timer driven and an event driven software is imagine you have hundreds of chicken queuing along a line, and you’re the person who wana collect the eggs.

A timer driven person will walk from the first chicken, check if the chicken lays egg, collect it if the egg is laid and then walk to the second chicken and repeat the same action until you go to the last chicken. Then you walk back to the origin and start the action over.

An event driven person is different in the sense of it goes to the chicken position only when the chicken lays an egg and triggered the event which will alert that person.

It’s so obvious that event driven workflow will be way more efficient than time driven workflow because when idle (in this context, none of the chickens is laying down egg), the egg collected does not need to move around and check if there’s any eggs to be collected.

Global variable over the entire software

The second reason it fails is the use of global variable in the entire software. Yes, you read me right, in the ENTIRE software. This means that every single function in the software is able to modify the member variable of a different class.

If you don’t know how dangerous it is, imagine you have a class that control the long range nuclear bomb (let it be class N), and the destination (let’s say latitude and longitude) is the member variable of class N. Then you have another class B that accidentally changes the latitude and longitude of class N to your current location. You didn’t know the variable is changed and you press the launch button. So, the consequence, you’re bombing yourself.

As conclusion, global variable is DANGEROUS! and this project fails because there’re mine bomb (global variable) everywhere.

Microsoft Visual C++

The third this project fails because it uses Microsoft Visual C++. The IDE use to code this software is MS Visual Studio and it is another fail product by another fail company. The code completion, code color label or even the speed of the IDE is very poor compare to my favourite IDE (Qt Creator). That’s so much failure point of MS product that I can write a thesis with it, therefore, I’m not gonna list it all in this post.

Copy-paste of code

Yet another reason this project fails is because majority of the code is repeating. The original code creator just press ctrl-c and ctrl-v instead of investing some time on writing a function and calling a function.

This makes the current code maintainer (which unfortunately is me) have a hard time correcting the code. Imagine you found a typo in line 3, you’ve corrected it and the software works for a situation but fails on the other situation. You check the source code again and you found that line 33, line 63 and line 93 are all duplicate of line 3, so frustrating isn’t it?

Poor comment and variable naming

The fifth reason it fails is there’s poor (or I should say almost none) comment with the code. Majority of the time, you don’t know what’s going on with the section of the code or what a function does because there’s no comment inside the code and no documentation telling you what it does. All you get is a few hundred (and sometimes thousands) line of code which you don’t know what’s the usage of it. (and thousands of line in a single function, is another reason it fails).

Apart from poor comment, the variable naming is very poor. Imagine you have 3 points to draw a line which represents the start point, end point and middle point. The naming of the variable inside the software is pt1, pt2, pt3. Obviously it fails because if you want to pass the middle point to a function, you might need to check back to the declaration line on which of the 3 points is the middle point.

Comment out / Block unused code

The last reason this project fails is because there’s tons of unused code being commented out or blocked. Those code are either buggy or fail to implement a new function.

I always think it’s a good idea to remove those unused code, if you want to keep it as reference, why don’t write a documentation which includes the code snippet instead of leaving those junks inside the program source code?

Enough of complaining how fail is that product, here’s a few suggestion if you’re working on a fail software just like me. Some suggestion might not be ethical and some might not solved the problem completely, some suggestion even require you to invest your valuable time in it. Let’s see.

If you can’t solve it, block it

There will be (and there were) lots of bugs exists in a fail software. Some bugs is rather easy to solve and some bugs are too hard to solve to a level that you wish you’re not the code maintainer.

Sometimes, the time invested on solving a bug would be equivalent to bringing a new feature to the software. Therefore, the solution might not sound ethical, but if you can not solve the bug, then just block the bug.

By blocking the bug, I mean that blocking the function from reaching the user or find the source of the problem and temporary blocking the problematic section from running until you have a better idea on how to solve it.

And once again, this move is not ethical at all and by blocking a section, you might introduce yet another bug. It’s the same like digging yet another hole for covering the hole.

Curse the original code maintainer

I’m not so good at anger management. Therefore, sometimes when fixing the code to a level that your blood pressure rises significantly, do release the stress by cursing the original code maintainer. It will not help but at least you will feel much better :)

Solve the problem once and for all

The above 2 solutions is not practical at all, a harder but more practical solution towards this problem is to solve the problem once and for all.

What I mean is since the software design itself is sucks, redesign the software. The software structure is not organise, re-plan the software structure. If the code is too messy, restart coding with neat code in mind. If it doesn’t have complete documentation, start to document when you start coding from scratch. And last but not least, if it depends on some crappy Microsoft product, use Qt to code it, you’ll get even better result with simpler code and higher performance.

The downside of this approach is it consumes your time. So it’s up to you (or me), the code maintainer to decide which approach is the best way to solve the problem. Goodluck to me and goodluck to guys who have the same faith as me ;)

2 thoughts on “Example of FAIL Project

  1. It’s perfectly OK to use Qt Creator to work on projects that are built using the MSVC compiler. I do that all day long :) If you need to co-exist with people who build from visual studio, you can use either qmake or cmake to generate visual studio project files. It’s of course advisable to test them at least once in a while, just to make sure those .vcprojs do work. You might want to generate the projects from within your .pro file, automatically whenever you build. This will keep them in sync.

    I wouldn’t complain all that much about Visual Studio’s compilers. The IDE may not be the best for Qt development, but it has been vastly improved in the 2012 version. If you’ve been using 2008 or prior versions, the update to 2012 is well worth it. Make sure you download and install the latest update (at the moment it’s Update 3).

    • Thanks for your comment, but my main point in this post is about the ugly code and targeting a little bit on MS Visual Studio IDE. I’m currently using 2008 and it’s very inconvenient compare with QtCreator. I know that 2012 or even 2013 version is better, but since the project uses MFC component, therefore it’s very costly upgrading from 2008 to 2012 or even 2013.

      So here’s the advantage of Qt, updating the IDE and version is easy and free unless you go for commercial license. Hence, if for a project that don’t have a huge amount of funding (like the project I mentioned in the post), I feel that Qt is the better choice. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

Follow me on Google+

Meta

Switch to our mobile site