Reply to post: Haven't seen much of other people's code...

You've seen things people wouldn't believe – so tell us your programming horrors

DF118

Haven't seen much of other people's code...

...but what I have seen makes me feel (a lot) less embarrassed about my own.

Worst was some consultant who'd taken what should've been a simple string padding operation in VBA to get a valid 8-character payroll number and turned it into a multi-line conditional...

If Len(strPayNo) = 1 Then

strPayNo = "E000000" & strPayNo

ElseIf Len(strPayNo) = 2 Then

strPayNo = "E00000" & strPayNo

ElseIf Len(strPayNo) = 3 Then

strPayNo = "E0000" & strPayNo

ElseIf Len(strPayNo) = 4 Then

strPayNo = "E000" & strPayNo

ElseIf Len(strPayNo) = 5 Then

strPayNo = "E00" & strPayNo

ElseIf Len(strPayNo) = 6 Then

strPayNo = "E0" & strPayNo

ElseIf Len(strPayNo) = 7 Then

strPayNo = "E" & strPayNo

End If

Not only had he done this, but he had replicated it EVERYWHERE. That code block appeared something like 140 times. At first I thought he'd cut and pasted it, but then one of the users told me the guy had been charging £1k+ per day for his services (working on site) and I got the sinking certainty that he had just sat there for days on end and typed every single line out by hand.

This was a public sector (NHS) organisation he'd fleeced, and it was just a one-man project for a few weeks. I shudder to think what else is out there in public sector land.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon