Computer Science Canada

Interpreting Terrible Code

Author:  apomb [ Tue Jun 17, 2008 1:43 pm ]
Post subject:  Interpreting Terrible Code

My latest project at work has brought me upon one of the most dreaded tasks in all of computer programming: debugging someone else's code.

Now, don't get me wrong, I like problem solving as much as the next guy, but trying to figure out why another person used substr() instead of regexps and something like
code:
do
{
    if($line =~ s/\,,/,unknown,/){}
}while($line =~ s/\,,/unknown/);
do
{
    if($line =~ s/\,/ /){}
}while($line =~ s/\,/ /);

and there's not a single comment in the entire script, along with non-descriptive variables, it gets time consuming.

Author:  Aziz [ Tue Jun 17, 2008 2:07 pm ]
Post subject:  RE:Interpreting Terrible Code

Find him. The options are endless from there.

By the way, what sort of job do you do?

Author:  md [ Tue Jun 17, 2008 8:05 pm ]
Post subject:  RE:Interpreting Terrible Code

We works for OLGC, totally hush hush.

[edit] Apomb, treat small sections of code like black boxes; figure out what their output is for any given input - then write your own code that does the same.

Author:  apomb [ Tue Jun 17, 2008 8:23 pm ]
Post subject:  RE:Interpreting Terrible Code

yeah, i have come to that conclusion... i talked to the original student who wrote the code, and I've decided to use his code jsut as a template for the values that need to be extracted from the text file.

now, im not sure if that first part was sarcastic or not, so ill just agree with you that i do work for the OLG (formerly OLGC) and that i cannot divulge the specifics of my work. Wink

Author:  Tony [ Tue Jun 17, 2008 9:08 pm ]
Post subject:  Re: RE:Interpreting Terrible Code

md @ Tue Jun 17, 2008 8:05 pm wrote:
[edit] Apomb, treat small sections of code like black boxes; figure out what their output is for any given input - then write your own code that does the same.

This is very unit testing is important.

I guess it's unlikely that the original student has left any unit tests, so make sure to writes your well. Keep in mind that without knowing exactly what the "blackbox" code does, your unit tests do not guarantee complete accuracy (just a very high degree of certainty Wink )

Author:  apomb [ Wed Jun 18, 2008 8:34 am ]
Post subject:  RE:Interpreting Terrible Code

thankfully, its written in perl, which I understand well enough, thanks to wtd's perl whirlwind.

The structure of the code however is forcing me to do exactly that, and work with each section of code, re-writing them in proper and usable format.

Author:  Zeroth [ Wed Jun 18, 2008 9:39 am ]
Post subject:  Re: Interpreting Terrible Code

Only way to do it sometimes apomb. Btw, whats OLGC? Or OLG?

Author:  Aziz [ Wed Jun 18, 2008 10:15 am ]
Post subject:  RE:Interpreting Terrible Code

Ontario Lottery and Gaming (Commission) I'm pretty sure.

Lottery, Casinos, Race tracks, slots, etc fall under this.

Author:  apomb [ Wed Jun 18, 2008 10:36 am ]
Post subject:  RE:Interpreting Terrible Code

indeed, you are correct Aziz.

Author:  Aziz [ Thu Jun 19, 2008 7:44 am ]
Post subject:  RE:Interpreting Terrible Code

I applied for a co-op position at the Windsor Slots (at the tracks I think) last year. No word from them though.

Author:  jeffgreco13 [ Thu Jun 19, 2008 9:36 am ]
Post subject:  Re: Interpreting Terrible Code

It's not easy to get in here. You usually have to know someone that currently works in a corporate division (blackjack dealer doesn't count). But if you do get in than it's pretty fun taking 45 minute coffee breaks to visit apomb at his desk just cursing the terrible job the previous student did on the perl script he must now re-write haha

P.S His 19" monitor is one MONSTROCITY of a CRT.

Author:  Aziz [ Thu Jun 19, 2008 9:54 am ]
Post subject:  RE:Interpreting Terrible Code

That's nothing, the network admin at my last job (Municipality of Chatham-Kent) had a 22" CRT.

I wished there was a compsci member that I went to school/worked with. Then I may have smart friends!

Author:  jeffgreco13 [ Thu Jun 19, 2008 10:01 am ]
Post subject:  Re: Interpreting Terrible Code

let's not get ahead of ourselves and say things like "apomb is smart".... hahaha

Anyway, FREE McD's COFFEE TODAY!!!!

Author:  apomb [ Thu Jun 19, 2008 12:47 pm ]
Post subject:  Re: Interpreting Terrible Code

jeffgreco13 @ Thu Jun 19, 2008 10:01 am wrote:
let's not get ahead of ourselves and say things like "apomb is smart".... hahaha

Anyway, FREE McD's COFFEE TODAY!!!!


easy on your superiors now, jeff Wink

and im happy to say that i have successfully re-worked this perl script, actually two perl scripts that add up to 1000+ lines into one script wih double-duty.

Comments and all, I have managed to streamline it to a mere 650lines. Smile

Author:  jeffgreco13 [ Thu Jun 19, 2008 12:54 pm ]
Post subject:  Re: Interpreting Terrible Code

*Applause*

Author:  Reality Check [ Thu Jun 19, 2008 8:13 pm ]
Post subject:  Re: Interpreting Terrible Code

Sounds like a pretty kick ass job. What do you do exactly?

Author:  apomb [ Fri Jun 20, 2008 8:16 am ]
Post subject:  RE:Interpreting Terrible Code

Generally its researching upgrades for the backup computer systems for the OLG. Thats what I'm back to that today since i've finished that code revision.

I'm in the architecture department, basically research and development. Covers everything from testing new server/database technologies, to developing new ways of scanning and verifying lottery tickets.

Its a challenging job, but enjoyable.

Author:  jeffgreco13 [ Fri Jun 20, 2008 8:34 am ]
Post subject:  Re: Interpreting Terrible Code

my job's a joke i think im online here more than actually doing any work...

in my department i deal with a lot of sensitive info (dont you guys PM me asking for winning numbers because I dont have them lol) and being a summer student I'm not allowed to have full access to certain systems and servers which really impedes my productivity so i get a lot of free time to spin in my perfectly ergonomic office chair

Author:  Reality Check [ Sun Jun 22, 2008 8:50 pm ]
Post subject:  Re: Interpreting Terrible Code

^^LOL that sounds awesome man and apomb your job sounds very interesting. Being in a such a sensitive position apomb, theoretically speaking of course, is there anything you could do to "cheat" the system?

*PM's jeff*




just kidding Laughing

Author:  apomb [ Sun Jun 22, 2008 8:53 pm ]
Post subject:  RE:Interpreting Terrible Code

Not a chance Reality check... Those systems are locked down, and guarded by security.


: