“Just a quick fix” Classic start to a reported ticket. Ticket states that a form field was not doing anything.

Think to myself ok this sounds like a nice easy one for the morning. A few hours later I find something like the following written by a senior member of the dev team.

SearchClass {
//...list of getter and setters

Private $snakeCaseName;

SearchFunction() {
Foreach($this as $property => $value){
//... if property keys = string for each object property then do code

If($property == “snakecaseProperty”){
//...do stuff

Why does this loop exist!!!!! All it does is remove any error checking if a getter method is misspelt...

To make matters worse the entire search method was over 300 lines building a MySQL query string.... even though there was an ORM and entity classes available!!!

  • 0
    Maybe he hated using ORMs
  • 0
    @CrunchyNut yeah... That's most likely shit.

    Maybe take a look at GIT History... Highly guess everything was public before (or even worse: __set/__get).

    SQL part... Searches can be very tricky. Depending on what it does, it might not be doable in an ORM or with a high performance penalty. Depends largely on the ORM.

    And yes.... The legacy shit sucks.

    If you'll rework it, maybe think about DTOs and seperation of the SQL part from data validation / preperation...

    But still, classes like that are mostly looking like someone puked after an all u can eat international buffet
Add Comment