Posted: 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.
Sponsor Sponsor
Aziz
Posted: 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?
md
Posted: 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.
apomb
Posted: 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.
Tony
Posted: 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 )
Posted: 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.
Zeroth
Posted: 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?
Aziz
Posted: 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.
Sponsor Sponsor
apomb
Posted: Wed Jun 18, 2008 10:36 am Post subject: RE:Interpreting Terrible Code
indeed, you are correct Aziz.
Aziz
Posted: 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.
jeffgreco13
Posted: 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.
Aziz
Posted: 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!
jeffgreco13
Posted: 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!!!!
apomb
Posted: 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
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.
jeffgreco13
Posted: Thu Jun 19, 2008 12:54 pm Post subject: Re: Interpreting Terrible Code