• Hanzito (unregistered)

    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.

  • Tim (unregistered)

    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.

  • Junkfoodjunkie (unregistered)

    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.

  • BoLoMT (unregistered)

    The former guy probably moved on Database Design.

  • (nodebb)

    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?"

  • (nodebb)

    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.

  • spadgas (unregistered)

    and if i is 10, it'll create the array 10 times and discard it 9 times. nice.

  • (nodebb) in reply to BoLoMT

    The former guy probably moved on Database Design.

    And/or became a Highly Paid Consultant.

  • Richard Brantley (unregistered) in reply to dkf

    Someone once told me that the only numbers that matter are 0, 1, and more than 1. A lesson to be learned early.

  • löchlein deluxe (unregistered)
    Comment held for moderation.
  • MaxiTB (unregistered) in reply to dkf

    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 ;-)

  • (nodebb)
    Comment held for moderation.
  • (nodebb)

    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".

  • (nodebb) in reply to MaxiTB

    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.

  • ZZartin (unregistered)

    Apparently, the customer didn't like that the amount of feedback was capped at ten students, and wanted the app to support any arbitrary number of students. At that request, the original developer quit the project

    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.

  • (nodebb) in reply to Dragnslcr

    Uh, PHP has had classes since well before C# became popular. I never claimed otherwise. other concepts from C# was referring to recent features especially since PHP5.3 (yields, delegates, lambdas).

    PHP 4 (around 2001) had a rather poor implementation of classes, but it definitely had named properties. As I mentioned before, back in those days classes where just named arrays with syntactical sugar. With Zend 2 first proper implementations started.

    PHP 5 (2005, I think) introduced a new object model that was basically the same as Java's. Java has not "an object model" it's a mess of primitives and reference objects not sharing an unified type system. PHP5+ on the other hand basically uses weak typing similar to .net dynamics or other languages using late static bindings, so subset of .net, definitely not Java.

    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 ¯_(ツ)_/¯

  • (nodebb) in reply to MaxiTB

    Unfortunately a lot of PHP devs have not heard that you no longer have to use key/val arrays for everything :/

  • Sam B (unregistered) in reply to konnichimade

    ["says" => "you! :p"];

Leave a comment on “Peer Feedback”

Log In or post as a guest

Replying to comment #:

« Return to Article