I’m stuck doing some re-work on an inherited system. It’s a long story. As I’m threading my way through this mess, however, I stumble on a function. It’s a remarkable function. This function is a tiny monument to twisted intent, and it’s certainly worth two minutes of your contemplation.
Ok, so before you behold the actual code, take a minute to think about all the other screwed up routines you’ve seen in your day. The routines that stretch on for pages and pages, with nested loops six-deep and variables whose scope has been violated back and forth and forth and back.
This isn’t like that.
This one is subtle. Elegant. Take a look at this baby and see if you can appreciate the totality of its ruin.
Private Function Add(ByRef Which As Integer, ByVal HowMany As Integer) Which = Which + HowManyEnd Function
Ok, so what’s wrong with this code? How many of these did you get:
- It was found in an asp.net web page as vb.net code. Vb.net, of course, features the “+=” operator, which replaces this whole function rather neatly.
- The whole “which” and “howmany” naming convention reeks of “apples” and “oranges”, not to mention its disdain for mundane pursuits like variable naming conventions.
- The “byval” and “byref” are actually correct here, but I’ve got $20 that says it was wrong the first time through. -g-
- It’s a function, right? (what’s it return?)
Whew … boy, that was fun. I hope you enjoyed it, too.