Varieties of bad computer programming code I’ve encountered

"Spaghetti Code". Sculpture by George W Hart

I convert dinosaur DOS database applications to Windows and thus get to look at far too much bad code. Here are examples from ancient Clipper and FoxDOS but they apply to other languages too.

Too clever by far.
Hey, lets grab data from multiple tables and stuff it into 3-D arrays. I mean, aCustomer[12,3,4] = aSales[2,9,16] is just a freaking model of clarity, isn’t it? This is also known as job security, except maybe even you won’t be able to understand your own code 6 months later.

Everything should be a method or a function.
@ 5, 5 say Hello()+World(). It’s important to scatter the functions through various source code files, making them hard to find and thus requiring the use of a text editor that can search multiple files at once.

Bonus points for using macros so the name of the function being called isn’t obvious and requires detective work to discover, like defining it using a PUBLIC variable eight levels up. As in dosomething = “Hello(), then 1500 lines of code later, @ 5, 5 &dosomething.

Straight line coding.
Screw methods and functions. Put everything in one source code file. This lends itself to having insane programming constructs like IF-THEN statements embedded ten levels deep with an assortment of embedded CASE statements tossed in too.

Needs to find another profession.
Open multiple data files. Refer to them by work area number not name. Call a function which closes all the data files then opens them using different work area numbers. Repeat as needed until the code is incomprehensible.

3 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.