Friday, February 4, 2011

A little frustrated

  As part of my job I'm someone that people turn to when there is no one else to fix something. It is something I do and am good at and a lot of people around here seem to suck at. At the moment I've been asked to look at something other people have been working on for a couple of weeks in the hope of finding the problem they have failed to find so far. In looking through the suspect area of the code I'm seeing stuff that is pretty horrendous. It has not comments on what it does, the actual code is overly complicated for what it needs to do and there are all sorts of just downright terrible decisions.

  To illustrate my point I'm going to show you what I mean. I can't post the actual code, because you know proprietary software that makes the company money and all that, but I will give a couple of pieces of code that do exactly the same thing. The first piece of code is something incredibly simple. It is the first piece of code ever written in one of the languages I write code in, C. (yes, it is just called C since it came after the languages A and B, software people are not very imaginative sometimes).

main() {
    printf("Hello World.\n");
}

  Pretty damn simple huh? I think even non coders can guess that all it does is print out the text Hello World. Now let us see some code that does exactly the same thing.

#include <stdio.h>
#define S(s)char x[]=#s;s
#define Q(x)x
#define A(x,y)y##x
#define B(x,y)A(y,x)
#define C(x,y)B(y,x)
#define Z(s,t,u)case s:if(*p!=32){t;}else{u;}break;
S(B( A( a ,m ),A(n ,i))() {B (A(h,c ),A(r ,a ))*p=x ;B(A( n, i),t)t
=0;B(A(n , i),t)s =0;B( f ,A(r, o )) (;*p;Q( p)++){C( B( A(c,t) ,h),B(A(
w, s),i))( s){ Z( 0,t+=8 *8-00 ,s ++)Z( 1,t+= 8 ;,s++ )Z
( 2, t++ ,putchar(t-73);t=s=0)}}})


  This may be kind of an extreme example to show the differences between good and bad code but you get my point. This is the kind of shit I am dealing with, overly complex incomprehensible code that only has to do something incredibly simple. Sometimes I wonder if my job would be so much better if I didn't have to deal with other people and they just let me get on with what I have to do.

  Just had to get that off my chest since it is hard for me to see how someone who declares that they are a software engineer as their profession can write such complete and utter bollocks.

No comments:

Post a Comment