Development Horrors

Developer. The word will bring to mind a short guy with the word geek oozing all over him.. wearing a t-shirt with a technical punch line that most normal people will not understand ("There are only 10 types of people in the world", "There is no place like 127.0.0.1"), jeans, glasses and a complete loner. Someone who hasn't had a date in the last couple of years and claims to be happy with vast collection of porn in the closet.

That, was the stereotypical geek we are often shown via movies and TV. Mind it, there are such characters in the world and they truly are very good in the work they do, but the average developer in the field who is in it for the moolaah (if he says no he's lying) is quite different. While there are some who are good there is the other extreme, absolute dumb and just hiding somewhere to survive out there...



In my experience as a developer (I'm not a veteran with like 25 years behind me, but i have met my share of nut cracks), i have seen a few such samples who have left behind works of art (of course, their code ought to be in a museum not in a live working product), some that will keep you laughing for the rest of your life and some give you recurring nightmares.. Here below is a small compilation of such "works of art" that i have encountered

1. Honestly Ugly

       /// <summary> 
       /// Process the sales order
       /// </summary>
       /// <param name="orderId"></param>

       public void ProcessOrder(int OrderId)
       {
               try 
               {
                        SqlHelper sqlHelper = new SqlHelper();

                       // I know this code below is ugly, but hey, it works !!!!!
                       string NumberToUse = string.Empty;

2. No.. You cannot be an Admin !!

I still am trying to figure out, what the hell did the developer intend to do???

         bool IsAdmin = false;
         if (IsAdmin != true
         {
               IsAdmin = false;
         }

3. Super-star Developer

I joked (sarcastic) that this developer should be in Microsoft, well i found out, he did join Microsoft

         // This excellent piece of code was done by Mxxxxx Vxxx
         // You can get in touch with me for more such excellent tips at
         //
mxxxxx.vxxx@gmail.com

         public bool ReturnFalseNoMatterWhat(bool CheckParam1, bool CheckParam2)
         {
                 // return false by default wherever needed.
                 return false;
          }

4. Forced Credit


A certain big company (name hidden) provided the setup of a small application (1 exe and 1 dll) which was to be installed for working as a bridge between our application and their server hosted application. We tried installing the setup on 5 machines for the development environment, but it failed on 2 machines saying "The supporting dll could not be found". The people maintaining that application came over and could not solve it. Curiosity got the better of me and i tried to investigate on my own.

I thought the dll was not being registered and tried registering it manually, but it kept giving me the DllEntryPoint not found error. On close examination, i noticed the dll was only 1Kb in size !!!!

The next thing to do was to open the dll in notepad and this is what it contained

          This application is developed by
                
1. Sanju
                
2. Baba
                
3. Vijay
         
for XYZ Technologies Ltd.


Just being paranoid, I opened the exe in a hex editor and found this condition

          If File.Exists "C:\Windows\abc.dll" Or File.Exists "D:\Windows\abc.dll"
                    ..... (Perform Task)
          Else
                   MsgBox "The supporting dll could not be found"
          End If

Our windows folder was called "WinOS" !!!! I created a folder called "Windows" in "C:" and placed the dll there and viola !!!! it worked !!!!

5. Is there anything at all left to hack??

I found this in one of the asp pages of a legacy project

            function GetInventoryData(int itemId, int sessionId) {
                     string sqlQueryToExecute = "";
                     // HACK: Temporary code. Needs to be fixed some day

When i did a lookup for "// HACK" in the files of the repository
            1377 file(s) found.

6. Raise the poor guys salary !!!

Found in an old Visual Basic 6.0 application i was trying to fix




7. Everything is correct.. dont know why the method is timing out !!!!!

He mentions the user fetch is slow but cant figure out that he's fetching the same user more than 600 times...

            AppUser user = new AppUser();
            List<Records> formattedRecords = new List<Records>();
             
            for (int i = 0; i < recordCollection.Count; i++)
            {
                     // Lookup is slow, maybe need to improve web service method
                    user = GetCurenntUserFromRemoteService();
                    formattedRecords.Add(FormatRecord(recordCollection[i]));
             }

8. The spiral to infinity

Maybe he just got lucky that the code never failed..

            int reportCode = GetParentReportCode();
            if (reportCode == 1131) {
                    (Perform Operation)
                   
                    int subReportCode = GetSubReportCode();
                    if (subReportCode == 1131) {
                             (Perform Operation)
                             reportCode = GetSubReportCode();
                             if .........................
                     }
             }
             else {
                    (Perform Operation)

                    int subReportCode = GetSubReportCode();
                    if (subReportCode == 1131) {
                             (Perform Operation)
                             
                             reportCode = = GetSubReportCode();
                             if .........................
                     }
             }
             else {
                     ..............................
             }

9. Switching the brain off

This ASP developer could not figure out what was wrong with the switch even after 5 days of googling
Just open thy eyes .. and thy shalt be enlightened...

               switch(adminRights)
               {
                       case (rightCode == 130):
                             (Perform Operation)
                            
break;


                       case (rightCode == 132):
                              (Perform Operation)
                             
break;

                        default:
                               (Perform Operation) 
                 }

10. The fastest way to fix a problem... Kill the functionality itself

This is what i got when i told the developer that the re-direction needs to be fixed

                 string successRedirectUrl = http://xyz.com/success.html;
                 string failureRedirectUrl   = "http://xyz.com/failur.html";
                 int responseCode = StartReportBatch();
                 if (responseCode == 200) {
                         Response.Redirect(successRedirectUrl);
                 }
                 else {
                       // Client reported error on 17th Aug 2008.
                       // Commented line to fix wrong redirection on error
                       // Response.Redirect(errorRedirectUrl + "?errorcode=" + responseCode);
                  }

.. Special thanks to all the developers who do the above to give you a few laughs and make our day a bit lighter :-)

5 comments:

  1. Good one!
    No 2,3,8 are most commonly seen! :)

    ReplyDelete
  2. Maza aaya.. I know few of these bugs... If I am not wrong then 1 and 5...Good One

    ReplyDelete
  3. hahaha.... I know few of them and these developers are legend for sure...

    ReplyDelete
  4. Thanks Shahid for providing such gr8 entertainment........ Hates off to all those indigenous developers...

    ReplyDelete
  5. Why r u not writing more posts????

    ReplyDelete

Powered by Blogger.