Ranting about all the WTF I just experience.



  • Short Story:
    Working on a project for about 3 weeks. Started with some fun like "ohh, by the way, did you bring a notebook? Because we have neither chair, table nor hardware for you. Ahh - and no we do not have VPN. You must sit here in a very low table all day with your hardware"
    First time in this project i though about getting out as fast as possible.

    Then I saw the code. I almost literally puked. Here is a best of what I found so far:
    several methods with > 100 required parameter. Current record I found is about 180 Parameter.

    • Funfact: these methods encapsulate perfectly fine classes (really, they wrap classes!) like phpmailer into a single blob of a method.

    The existing classes are more or less collections of methods. No class contains data, only logic. Which means all methods of the user-"class" start with ->($user_id, ...) which is very annoying. Ahh and of course none of the objects buffers any database calls. You need name, address, city and country of the users? - That will be 5 DB calls to the same table / key.
    Includes are random used. There are single files with about 15.000 lines of code, containing about 300 methods with totaly different scope. Extra Candy: This file includes nearly everything else in the project, because there are so many different methods in there. WTF do they wonder the (PHP) Compiler needs 2-4sec for these files? (They load and parse about 20MB of Code every time...


  • BINNED

    @DieWaffel said in Ranting about all the WTF I just experience.:

    php

    Found your problem.



  • @DieWaffel So basically everything that could potentially suck, turned out it does suck.

    I hope at least the money is decent.



  • Ahh and of course none of the objects buffers any database calls. You need name, address, city and country of the users? - That will be 5 DB calls to the same table / key.

    20 quid says the dev has no idea how to do UNION or JOIN/LEFT JOIN etc. 5 calls will also by design be even slower than SELECT * for the average user table unless you're pulling down > 100 fields I'd say.

    There are single files with about 15.000 lines of code

    That's cause for mandatory jail time

    WTF do they wonder the (PHP) Compiler needs 2-4sec for these files? (They load and parse about 20MB of Code every time...

    That's wrong, though. PHP isn't compiled, it's interpreted. I'd say for a 15000 line file 2-4 seconds would be generous, I'd not be surprised if it took 10+ seconds to run at that state.

    Funfact: these methods encapsulate perfectly fine classes (really, they wrap classes!) like phpmailer into a single blob of a method.

    That's only a bad thing depending on how they're called. Inside a magic method like __contruct or __autoload? Not so bad. Inside function getUserAddress(...)? Step away from the keyboard before I beat you with it. What they should be doing is creating a single point of entry for PHPMailer (or depending on how you feel if you're using a framework, use inheritance and call it from the base class) and run a require_once against the PHPMailer files. Which is how I (And most other devs) do it. In this case you're going to (by necessity) have a class declared inside a method, but as it's a 3rd party code library this is mostly fine. You could pass data directly to PHPMailer but this would require you to go in and mess about with PHPMailer which is a greater evil.

    First time in this project i though about getting out as fast as possible.

    You already know what you need to do. Go. Go now, while nobody is looking!

    @Onyx Come on now, just because most PHP devs live on a diet of lead paint and glue doesn't mean we all do :(



  • This post is deleted!

  • BINNED

    @thegoryone said in Ranting about all the WTF I just experience.:

    @Onyx Come on now, just because most PHP devs live on a diet of lead paint and glue doesn't mean we all do

    Dude, I am a PHP dev.

    And who the fuck stole all my glue?



  • @Onyx I knew you had worked with it but didn't know you were a full on dev. At least you haven't run out of wall candy.


  • BINNED

    @thegoryone PHP backend for the web UI, HTML/JS frontend, C++ service that monitors stuff this fucking Asterisk bastard does, all mine!

    I need a lot of wall candy to get me through the day.



  • @Onyx More fun than what I do, mostly backend work with education on data collection systems (The paperless office dream). I add a little bit of flair (and confusion) by mixing up frameworks so when someone else dives into documentation they find out System_A is CodeIgniter, System_B is Laravel and System_C is MINI2. I guess I'm technically full-stack but I don't kid myself on my actual abilities with JS, though my HTML/CSS is fine even though I'm in the bad habit of whoring bootstrap these days.

    That and I used to be a sysadmin (MS/Citrix/VMWare primarily) so it's kind of funny watching how bad I am with Linux (Using Ubuntu here) so I just bit the bullet and run WAMP stacks on 2012.



  • @thegoryone said in Ranting about all the WTF I just experience.:

    20 quid says the dev has no idea how to do UNION or JOIN/LEFT JOIN etc. 5 calls will also by design be even slower than SELECT * for the average user table unless you're pulling down > 100 fields I'd say.

    It may disturb you even further: Each of the calls does 3 or sometimes up to 10 JOIN operations.

    That's wrong, though. PHP isn't compiled, it's interpreted. I'd say for a 15000 line file 2-4 seconds would be generous, I'd not be surprised if it took 10+ seconds to run at that state.

    Should have said Parser, not Compiler. Shame on me. In C or C++ this would be a much smaller Problem, the Compiler takes much of the junk out. But in a scripting language it is fatal.

    That's only a bad thing depending on how they're called. Inside a magic method like __contruct or __autoload? Not so bad. Inside function getUserAddress(...)? Step away from the keyboard before I beat you with it. What they should be doing is creating a single point of entry for PHPMailer (or depending on how you feel if you're using a framework, use inheritance and call it from the base class) and run a require_once against the PHPMailer files. Which is how I (And most other devs) do it. In this case you're going to (by necessity) have a class declared inside a method, but as it's a 3rd party code library this is mostly fine. You could pass data directly to PHPMailer but this would require you to go in and mess about with PHPMailer which is a greater evil.

    No no and no. Your Idea would make some sense. These Methods work more like:
    method (p1, p2, p3, p4, p5, p6 ...)
    $obj = new car(p1, p2, p3);
    $obj->set_color (p4);
    $obj->set_brand(p5);
    $obj->set_wtf(p6);

    and so on, calling each method on it and passing the parameters...

    You already know what you need to do. Go. Go now, while nobody is looking!
    Hiding in plain sight, while getting paid and looking for something else :)

    @Onyx PHP does not write bad code, bad developer write bad code.



  • @DieWaffel In that case you're entirely justified in nuking the place from orbit

    It may disturb you even further: Each of the calls does 3 or sometimes up to 10 JOIN operations.

    0_1459331125463_the-office-michael-scott-no-god-please-no_41.gif

    But in a scripting language it is fatal.

    Incredibly common to see students doing it this way though (I was guilty of this myself the first time I built a CMS...in 2004)


  • BINNED

    This post is deleted!

  • BINNED

    @DieWaffel said in Ranting about all the WTF I just experience.:

    @Onyx PHP does not write bad code, bad developer write bad code.

    Why does everyone feel the need to defend PHP from me? :P

    I mean, I'll call on its bullshit, but generally it gets the job done and I kinda like it overall.



  • @Onyx Because you looked like one of the guys who blames stuff on a language, not on the devs :) BTW: I know PHP can do some wired things. Ever compared a array to an int? or an Object to an bool? Most things are well though after all, some other stuff is just strange.



  • @DieWaffel said in Ranting about all the WTF I just experience.:

    Ever compared a array to an int? or an Object to an bool

    Well, honestly? No, because that's completely daft! But I can already imagine some of the weird and wacky things PHP would do when you compare an object to a boolean.


  • BINNED

    @DieWaffel said in Ranting about all the WTF I just experience.:

    Ever compared a array to an int? or an Object to an bool? Most things are well though after all, some other stuff is just strange.

    I'm sure it's no crazier than JavaScript. I'm starting to suspect nothing is crazier than JavaScript.

    Well, except Ruby which will let you multiply strings...



  • Incredibly common to see students doing it this way though (I was guilty of this myself the first time I built a CMS...in 2004)

    Yepp, but this is a project with 4 freelance developers and some guy calling himself "senior" who created the blob-methods and call it architecture. Nobody is allowed to change it. I'm going to give a big party after leaving.



  • @DieWaffel said in Ranting about all the WTF I just experience.:

    Incredibly common to see students doing it this way though (I was guilty of this myself the first time I built a CMS...in 2004)

    Yepp, but this is a project with 4 freelance developers and some guy calling himself "senior" who created the blob-methods and call it architecture. Nobody is allowed to change it. I'm going to give a big party after leaving.

    Are you sure it is "senior" and not "senor"?



  • BTW: I missed something in the first Post. They are growing "elseif trees". - Something like a if-then-elseif-elseif with 100+ "cases" and some of the "cases" are nested 20-30 layers deep... It seems the original programmer did not know about switch-case or even something like "SELECT file_to_include FROM dynamic_includes WHERE action = $action" - Ohh wait. To do this you need to understand includes and structuring code.



  • SELECT file_to_include FROM dynamic_includes WHERE action = $action

    But not PDO and SQL injection :grinning:


  • BINNED

    @thegoryone No no, you don't include SQL injection, mysql is controlled using ini_set.


  • BINNED

    This post is deleted!


  • @Onyx You mean SQL injection isn't a feature?!


  • Winner of the 2016 Presidential Election

    @Onyx said in Ranting about all the WTF I just experience.:

    Well, except Ruby which will let you multiply strings...

    Works in Python as well.



  • Cootie-induced duplicate post redacted



  • @Onyx said in Ranting about all the WTF I just experience.:

    Well, except Ruby which will let you multiply strings...

    Really? One of the questions that came up during the interview for the job I start Monday, when discussing the general topic of scripting for automating tasks, was whether I know Ruby. It's possible I might need to learn it. I think (and hope) most such scripting can be done in languages I already know (perl, csh, bash, tcl) or am in the process of learning (python), but it's possible. :shudder:


  • BINNED

    @HardwareGeek said in Ranting about all the WTF I just experience.:

    Really?

    onyx@shodan ~> irb
    irb(main):001:0> "really"*10
    => "reallyreallyreallyreallyreallyreallyreallyreallyreallyreally"
    


  • @Onyx Ah, repetition. Yes, that works in other languages, too, although some use a different operator.

    My brain interpreted your statement as meaning that Ruby supported multiplying a string by another string (which also works in other languages if the strings look like numbers) — "some string" * "another string" — and quite logically refused to derive any meaningful result from that operation.



  • @HardwareGeek said in Ranting about all the WTF I just experience.:

    My brain interpreted your statement as meaning that Ruby supported multiplying a string by another string (which also works in other languages if the strings look like numbers) — "some string" * "another string" — and quite logically refused to derive any meaningful result from that operation.

    Hmm...my algebra tells me it'd be "someanother somestring stringanother stringstring", or some variant thereof. (String concatenation fails commutation, after all.)



  • @DieWaffel said in Ranting about all the WTF I just experience.:

    Ahh - and no we do not have VPN. You must sit here in a very low table all day with your hardware"

    What's the point of them being concerned about security if you do the work on a personal machine?



  • I'd assume dot product.

    some string
    another string

    saonmoet hsetrr isitnrging



  • @HardwareGeek I kind of liked Ruby.

    I think it suffers a lot from its relationship to Rails, the same way that JavaScript suffers from its relationship with DOM.



  • @AyGeePlus said in Ranting about all the WTF I just experience.:

    I'd assume dot product.

    Wouldn't that be "some string"."another string"? (Extra fun in PHP! )



  • @DieWaffel said in Ranting about all the WTF I just experience.:

    No class contains data, only logic

    Stateless! that's what the functional proggramers do :tropical_drink:



  • @asdf
    and smalltalk


  • Discourse touched me in a no-no place

    @DieWaffel said in Ranting about all the WTF I just experience.:

    several methods with > 100 required parameter. Current record I found is about 180 Parameter.


  • Discourse touched me in a no-no place

    @blakeyrat said in Ranting about all the WTF I just experience.:

    I think it suffers a lot from its relationship to Rails, the same way that JavaScript suffers from its relationship with DOM.

    There's more of a problem with the tendency to need to be running fast on an upgrade treadmill; the Ruby community tends to be poor at long-term support of gems and there's a similar mesh-of-stupid-dependencies problem that we have in Node/npm.

    I really don't see why I should need a 16GB VM to serve what is mostly simple web pages to a small number of users…



  • @dkf said in Ranting about all the WTF I just experience.:

    I really don't see why I should need a 16GB VM to serve what is mostly simple web pages to a small number of users…

    Last time I checked in with the crazies in web development, the reason I usually got was something along the lines of "Just because I can, therefore I will". And why would they think about sharing computational resources with other products/services?



  • @WPT said in Ranting about all the WTF I just experience.:

    Are you sure it is "senior" and not "senor"?

    "senile"





  • It sounds to me like someone has found the bastard method of building procedural programs in object-oriented systems. You can suspect this when (1) class is singleton; (2) the only class is 15,000 lines; (3) program globals as static members (but only if needed). Amirite?

    Usually created by dyed-in-the-wool procedural programmers who are absolutely determined that, "OO is total bullshit. There must be some way to build a decent procedural program in this stuff." Triggered by non-procedural languages like Smalltalk or BS standards that require use of classes.



  • @CoyneTheDup More or less. The Senor Dev thinks this is how OOP has to be. I tried to explain to him the data / function inside an Object, encapsulation and object responsibility etc. He simply did not understand it. He does not want to understand it. Therefore he wrote these bastard functions encapsulating Objects. He simply does not understand how to USE an proper object / class if you give it to him.

    He thinks with this "class-as-function-libary" he did absolutly understand OOP and this is the only correct way. He was really pissed and confused as I told him "You not even scratching the surface of OOP and its benefits." Guess I'm the first one who spoke this out.



  • I guess the Senor must have mistaken "language that supports OOP" as OOP, the practice itself.
    I remember this also happened to the Agile manifest for development too.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.