- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
It only goes to show that you can write FORTRAN(*) in any language.
(*) FORTRAN of course means FORTRAN-IV, the only true FORTRAN, not the object-oriented Pascal-like abomination that it has become today.
Admin
This reminds me of the early days of visual basic which didn't have any kind of "struct" type - code like this was common then. A slightly better alternative was to have a number of arrays in parallel.
Admin
Just as well, perhaps, since the first developer could be considered completely inept, grade F. Holy crap. I could program better than this when I made manual listing in HTML in the 90s.
Admin
The former guy probably moved on Database Design.
Admin
Over and over, the key thing in so many of these WTFs is the total failure of the author of the bad code to ever bother to think "surely there must be a better way that doesn't involve me working so hard?"
Admin
Wait, so they know that loops exist, but still went with 10 if statements for the array creation?
Nobody:
Code author: I have a car (there are also busses, trains and airplanes), but I'll walk from Boston to New York.
Admin
and if i is 10, it'll create the array 10 times and discard it 9 times. nice.
Admin
And/or became a Highly Paid Consultant.
Admin
Someone once told me that the only numbers that matter are 0, 1, and more than 1. A lesson to be learned early.
Admin
Haha, ever issue boils down to the fact that one person didnt think enough tho. Otherwise TDWTF would not exist and dozens of other sites for any other topic ;-)
Admin
Before PHP introduced classes (and other concepts from C# which is obviously tries to copy because it's the currently most mature general language framework) you kinda had to use arrays for a replacement for objects. Obviously it might been better to use a key/value array instead of a indexed array, but eh. Now the weird thing is the index arithmetic, because a nested approach would be way better. But I can't honestly say if it was a performance consideration - we don't know where the code is and what the critical path looked like. These days in PHP is pretty simple, just use objects, they are actually getting optimized by the Zend engine and are more performant than using arrays (which was not always the case); so these days there's no longer an excuse beside "me se lazy" or "PO told me se lazy".
Admin
Uh, PHP has had classes since well before C# became popular. PHP 4 (around 2001) had a rather poor implementation of classes, but it definitely had named properties. PHP 5 (2005, I think) introduced a new object model that was basically the same as Java's.
Admin
That seems like a good time to test how robust their QA is :P
The class size is 20 students? Okay let's just repeat the pattern another 11 times.
Admin
Addendum 2023-03-03 18:52: Pff, I forgot to add the new line and all the edit option allows to do is adding a comment. Which is not helpful at all ¯_(ツ)_/¯
Admin
Unfortunately a lot of PHP devs have not heard that you no longer have to use key/val arrays for everything :/
Admin
["says" => "you! :p"];