Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Christian Tabligan
  Where is Christian Tabligan?
 Bacolod City, Neg. Occ.
 Philippines
 Christian Tabligan
 To: Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Paalbalk Huissen
 Netherlands
 Boudewijn Lutgerink
 Tags
Subject: RE: Bad code I've seen
Thread ID: 138614 Message ID: 138888 # Views: 127 # Ratings: 0
Version: Not Applicable Category: Off-topic
Date: Thursday, July 19, 2007 3:12:26 AM         
   


> > Due to time pressures placed upon me I tend to have a slightly selfish relationship with Foxite, only really coming on here when I have reached a dead-end with a problem I need to overcome. Hopefully this is a small amount of payback, it might raise a smile for people who read it.
> >
> > In my time I have come across some terrible code, it isn't always the case that it was written many many years ago but it tends to be the norm or when limitations of the IDE or perhaps laziness of the programmers in question dictated some of the standards of code. I can't think of all the examples, they are numerous, but I did happen across one recently that really made me scratch my head and then chuckle.
> >
> > I came across a piece of code that attempted to remove .CDX files from the data directory of an installation that were no longer required, I don't know why this code was required but it's in there. Despite being written quite poorly the code didn't crash until a very specific occurrence recently. This is the code in question:
> >
> >
> > * gcdir is the full path to the installation, objectname is a field containing table names
> >  SCAN ALL
> >   c = m.gcdir + "data\" + ALLT(objectname)
> >   IF FILE( "&c..dbf" ) AND FILE( "&c..cdx" )
> >    DELETE FILE ( "&c..dxc" )
> >    RENAME ( "&c..cdx" ) TO ( "&c..dxc" )
> >   ENDIF
> >  ENDSCAN
> > 

> >
> > One of my biggest gripes when maintaining other people's code is single letter variable names, I think everyone understands why. One of my colleagues brought an error to me, a 1206 (Recursive macro definition.), on the IF FILE(... line. I had never ever seen a 1206 before so I was baffled as to how code written several years ago and called all the time would suddenly start producing this error.
> >
> > Turns out it was a curiosity of the application path highlighting the poor standard of the code, my colleague had installed the application to C:\B&C\ Obviously the ampersand in the path, followed by the same single character as the variable name was causing VFP to think it needed to evaluate c while it was already evaluating c hence the error I'd never seen before. It took me a while to discover this as even while trying to replicate the error I used a variable called lcApplicationPath rather than just c, since I couldn't bring myself to use a single letter variable name, so my first attempt to replicate failed, I got there in the end.
> >
> > I hasten to add it wasn't me who wrote the code :) nor any of my current colleagues, the culprit has long since gone and we are happy for that, the code has been changed for the better now.
> >
> > Have you any examples of poor or even terrible code that has really left you scrambling for a resolution to a weird error?
>
> Do I really have to tell you?
> Boy I just had to "maintain" code that was so badly written.
> The braindamaged ***hole who wrote this just learned to read and count so it seemed.
> He knew the letter X already so why not use that for every variable X1, X2, X3, X4...
> And even worse, and now you better sit down, he declared each and every variable PUBLIC!!!
> Oh boy, never saw such poor code.
>
> Boudewijn Lutge®ink
> http://www.vfpdevelopers-online.com
> Border Collies, the only breed "That'll do".

hahahaha! lolz.....it reminds me of my college days coding style...lolz....:)

Christian M. Tabligan
Programmer, Central Lumber Corp.-Cebu City

Visual FoxPro is like a game...need to explore until you reach your goal to success!!!



COMPLETE THREAD
Bad code I've seen Posted by Paul Gibson @ 7/17/2007 11:33:31 AM
RE: Bad code I've seen Posted by Boudewijn Lutgerink @ 7/17/2007 12:14:16 PM
RE: Bad code I've seen Posted by Ken Murphy @ 7/19/2007 2:27:44 AM
RE: Bad code I've seen Posted by Christian Tabligan @ 7/19/2007 3:12:26 AM
RE: Bad code I've seen Posted by Cetin Basoz @ 7/17/2007 12:24:11 PM
RE: Bad code I've seen Posted by Brian Walsh @ 9/7/2008 10:44:34 PM
RE: Bad code I've seen Posted by Cetin Basoz @ 9/8/2008 12:42:39 PM
RE: Bad code I've seen Posted by Ilya Rabyy @ 9/8/2008 6:11:29 PM
RE: Bad code I've seen Posted by Brad Schulz @ 9/8/2008 6:16:37 PM
RE: Bad code I've seen Posted by Ilya Rabyy @ 9/8/2008 6:32:11 PM
RE: Bad code I've seen Posted by Mike Yearwood @ 9/9/2008 1:07:25 AM
RE: Bad code I've seen Posted by Cetin Basoz @ 9/9/2008 1:07:04 AM
RE: Bad code I've seen Posted by Mike Yearwood @ 9/9/2008 3:38:23 PM
RE: Bad code I've seen Posted by Ilya Rabyy @ 9/9/2008 4:55:21 PM
RE: Bad code I've seen Posted by Mike Yearwood @ 9/10/2008 10:08:37 PM
RE: Bad code I've seen Posted by Ilya Rabyy @ 9/9/2008 4:43:28 PM
RE: Bad code I've seen Posted by Bernard Bout @ 9/12/2008 8:33:55 AM
RE: Bad code I've seen Posted by Cetin Basoz @ 9/12/2008 3:09:16 PM
RE: Bad code I've seen Posted by Mike Yearwood @ 9/12/2008 4:00:48 PM
RE: Bad code I've seen Posted by Bernard Bout @ 9/13/2008 6:01:30 AM
RE: Bad code I've seen Posted by Andy Kramek @ 7/17/2007 12:55:31 PM
RE: Bad code I've seen Posted by Thomas Bähr @ 7/17/2007 1:05:35 PM
RE: Bad code I've seen Posted by Andy Kramek @ 7/17/2007 11:52:45 PM
RE: Bad code I've seen Posted by Paul Gibson @ 7/18/2007 10:31:47 AM
RE: Bad code I've seen Posted by Anders Altberg @ 9/8/2008 1:29:58 PM
RE: Bad code I've seen Posted by Andy Kramek @ 9/8/2008 2:36:10 PM
RE: Bad code I've seen Posted by Brad Schulz @ 9/8/2008 3:52:38 PM
RE: Bad code I've seen Posted by Andy Kramek @ 9/9/2008 7:05:38 AM
RE: Bad code I've seen Posted by Jim Booth @ 9/9/2008 4:29:05 PM
RE: Bad code I've seen Posted by Andy Kramek @ 9/10/2008 1:33:51 PM
RE: Bad code I've seen Posted by Brad Schulz @ 9/9/2008 6:19:29 PM
RE: Bad code I've seen Posted by Jim Booth @ 9/9/2008 7:23:14 PM
RE: Bad code I've seen Posted by Andy Kramek @ 9/10/2008 1:39:51 PM
RE: Bad code I've seen Posted by Thomas Bähr @ 7/17/2007 1:02:29 PM
RE: Bad code I've seen Posted by Eric den Doop @ 7/18/2007 11:41:02 AM
RE: Bad code I've seen Posted by Tamar Granor @ 7/18/2007 10:19:47 PM
RE: Bad code I've seen Posted by Andy Kramek @ 7/19/2007 2:28:35 PM
RE: Bad code I've seen Posted by Barbara Peisch @ 7/19/2007 5:54:40 AM
RE: Bad code I've seen Posted by Eric den Doop @ 7/19/2007 7:00:56 AM
RE: Bad code I've seen Posted by Barbara Peisch @ 7/19/2007 8:00:59 AM
RE: Bad code I've seen Posted by tushar @ 7/19/2007 2:36:45 PM
RE: Bad code I've seen Posted by Eric den Doop @ 7/19/2007 2:57:49 PM
RE: Bad code I've seen Posted by Christian Pano @ 7/19/2007 11:34:31 AM
RE: Bad code I've seen Posted by Cetin Basoz @ 7/19/2007 12:12:56 PM
RE: Bad code I've seen Posted by Paul Gibson @ 7/19/2007 12:21:32 PM
RE: Bad code I've seen Posted by Cetin Basoz @ 7/19/2007 12:42:34 PM
RE: Bad code I've seen Posted by Paul Gibson @ 7/20/2007 11:36:26 AM
RE: Bad code I've seen Posted by Cetin Basoz @ 7/20/2007 3:13:48 PM
RE: Bad code I've seen Posted by Christian Pano @ 7/23/2007 11:10:22 AM
RE: Bad code I've seen Posted by John Peart @ 7/19/2007 12:18:54 PM
RE: Bad code I've seen Posted by Ken Murphy @ 7/19/2007 2:09:01 PM
RE: Bad code I've seen Posted by tushar @ 7/19/2007 2:24:51 PM
RE: Bad code I've seen Posted by Cetin Basoz @ 7/19/2007 2:44:42 PM
RE: Bad code I've seen Posted by tushar @ 7/19/2007 3:42:47 PM
RE: Bad code I've seen Posted by Ken Murphy @ 7/19/2007 8:22:04 PM
RE: Bad code I've seen Posted by Barbara Peisch @ 7/19/2007 8:34:36 PM
RE: Bad code I've seen Posted by Ken Murphy @ 7/19/2007 10:19:29 PM
RE: Bad code I've seen Posted by Barbara Peisch @ 7/19/2007 10:26:38 PM
RE: Bad code I've seen Posted by Thomas Bähr @ 7/20/2007 11:11:53 AM
RE: Bad code I've seen Posted by Ronan Masangcay @ 7/20/2007 4:48:50 AM
RE: Bad code I've seen Posted by Mike Yearwood @ 7/21/2007 2:35:23 AM
RE: Bad code I've seen Posted by Kurt Westerlund @ 9/12/2008 4:57:50 PM