P and the BloodBath Survivors - Chapter 1



  • As soon as the old CEO retired, the new CEO's first action was to fire half the IT department.
    The ones to go were most the senior level techies and clueful managers, basically anyone who
    had stood up to the business types and tried to do things the right way rather than just cowtowing to
    every whim. The survivors of the bloodbath that are relevant to this sorid tale (and the loads that
    are sure to follow this one) were a couple of senior devs, a non-tech-savvy manager, and P.

    P was a contractor hired by the Manager. None of the existing devs interviewed P, he was just there one day. P had no interest in learning how the rest of us did things, and the Manager wasn't going to let any of the rest of us tell P what to do. P did everything off the cuff and hack 'n slash; so he looked like he was getting a lot done, as those types always do...until the mess catches up with them.

    So the Manager loved P. P was great! P was fast! Guess who became the lead developer that the survivors had to take marching orders from after the BloodBath? P.

    How bad could it be really be you ask? Well, take a look at some of P's code:

     

    foreach($alphaCheck as $checkField) {
      if($paramsArray[$checkField['field']]) {
        if($paramsArray[$checkField['field']]) {
          $invalidChars = false;
          $checkValue = trim(strtoupper($paramsArray[$checkField['field']]));
          $allowedChars = explode('|',"A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|-| |.|'");
          for($i=0;<strlen($checkvalue); $i++)="" {="" if(!in_array($checkvalue[$i],$allowedchars))="" $invalidchars="true;" }="" if($invalidchars)="" $errormsgs[]="$checkField['name']" .="" '="" contains="" invalid="" characters';="" <="" pre="">$i<strlen($checkValue); $i++) {
    if(!in_array($checkValue[$i],$allowedChars)) {
    $invalidChars = true;
    }
    }
    if($invalidChars) {
    $errorMsgs[] = $checkField['name'] . ' contains invalid characters';
    }
    }
    }
    }

    This block of code is replicated:

    • 7 times in app A
    • 5 times in app B
    • 2 times in app C
    </strlen($checkvalue);>


  • Sad part about this story. The only ways you can know this is:

    • You are P
    • You are one of the survivors (not senior, not clueful, and no balls to stand up)


  • Or he's been laid off... and now looking at the current situation that he could have fallen into, he's thinking "lucky escape!"



  • <Sarcasm>Makes sense to fire half of the IT department, after all all they do is complain about needing money to purchase better equipment and hire more people, when it is obvious that everything is working.  Those greedy bastards they deserve to get fired.  Look at how much work P is capable of doing.  Just imagine if you had a full team of Ps how productive the IT department could be.</Sarcasm>



  • well, I could pee all over everything too.  I think perhaps this is the new manager marking his new territory?



  • Chapter two will introduce rumours of a second developer, NP. He will never be seen directly, but his work can be verified. Years will be dedicated to determine whether NP actually exists, or if he is actually P in disguise.



  • Good devs can stay friends post layoffs. Thats how human networking is done.

    Not senior on my part yes. Clueful and needing a vent, have balls just no ability to make a change. Politics are a bitch when you are a logical person.



  • @pkmnfrk said:

    Chapter two will introduce rumours of a second developer, NP. He will never be seen directly, but his work can be verified. Years will be dedicated to determine whether NP actually exists, or if he is actually P in disguise.

     

    +pinterest

     


  • ♿ (Parody)

    @Daid said:

    Sad part about this story. The only ways you can know this is:

    • You are P
    • You are one of the survivors (not senior, not clueful, and no balls to stand up)

    How do you figure? There's at least:

    • He could be in a different department.
    • He could have been hired after all this, but been told the back story.
    • He could just be friends with one of the senior or some othe random person in the company, never even working there himself.
    • He never said that all of the clueful people were fired. Just those who got into spats with management.


  • @Anketam said:

    <Sarcasm />

    Aha, I'm getting better at spotting these trolls now!

    ObBOT: I had a similar "team leader" that didn't put his money where his mouth was (committed me to several tasks I couldn't deliver, made false promises). When I left, within 3 months he was given the boot and the company called me up that week to offer me my old position.

    @pkmnfrk said:

    Chapter two will introduce rumours of a second
    developer, NP. He will never be seen directly, but his work can be
    verified. Years will be dedicated to determine whether NP actually
    exists, or if he is actually P in disguise.

    If that's NPPPPPPPPPPPPPPPPPPP I'm thinking of, that's the same as P anyway.

     



  • P puts the P in PHP.



  • @pkmnfrk said:

    Chapter two will introduce rumours of a second developer, NP. He will never be seen directly, but his work can be verified. Years will be dedicated to determine whether NP actually exists, or if he is actually P in disguise.

    +1



  • @FreddieTheArmless said:

    foreach($alphaCheck as $checkField) {
    if($paramsArray[$checkField['field']]) {
    if($paramsArray[$checkField['field']]) {
    $invalidChars = false;
    $checkValue = trim(strtoupper($paramsArray[$checkField['field']]));
    $allowedChars = explode('|',"A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|-| |.|'");
    for($i=0;$i<strlen($checkValue); $i++) {
    if(!in_array($checkValue[$i],$allowedChars)) {
    $invalidChars = true;
    }
    }
    if($invalidChars) {
    $errorMsgs[ = $checkField['name'] . ' contains invalid characters';
    }
    }
    }
    }

    if this is comment, then if this is comment:
    actually, it doesn't seem so much WTFy, yes, there's the double if, and also the $allowedChars that could and should be set up before the loop, and the actual check should be probably done by regex and not loop, but i sometimes too like to not use regexes, if i can and if it's not too much hassle, an there's the missing bracket on $errorMsgs[ = ... line, but that one might be just a typo when writing the post.
    so... the code itself is either not so big WTF, or i'm missing something.



  • Right on, there's only three or four glaring flaws with this function.  That's less than one flaw per line!

     



  • @SEMI-HYBRID code said:

    @FreddieTheArmless said:
    foreach($alphaCheck as $checkField) {
    if($paramsArray[$checkField['field']]) {
    if($paramsArray[$checkField['field']]) {
    $invalidChars = false;
    $checkValue = trim(strtoupper($paramsArray[$checkField['field']]));
    $allowedChars = explode('|',"A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|-| |.|'");
    for($i=0;$i<strlen($checkValue); $i++) {
    if(!in_array($checkValue[$i],$allowedChars)) {
    $invalidChars = true;
    }
    }
    if($invalidChars) {
    $errorMsgs[ ] = $checkField['name'] . ' contains invalid characters';
    }
    }
    }
    }

    if this is comment, then if this is comment:
    actually, it doesn't seem so much WTFy, yes, there's the double if, and also the $allowedChars that could and should be set up before the loop, and the actual check should be probably done by regex and not loop, but i sometimes too like to not use regexes, if i can and if it's not too much hassle, an there's the missing bracket on $errorMsgs[ = ... line, but that one might be just a typo when writing the post.
    so... the code itself is either not so big WTF, or i'm missing something.

    Because it's not written like this:


    foreach($alphaCheck as $checkField) {
        if(!preg_match('/^\\s*[-a-zA-Z .]\\s*$/', $paramsArray[$checkField['field']])) {
           $errorMsgs[ ] = $checkField['name'] . ' contains invalid characters';
        }
    }
    

    Note how my version (obviously untested) has less redundant if statements, nested loops, string manipulation and array creation, and is even readable to boot. Of course, there are fundamental problems with the inputs to this piece of code (why is the value to the field in some other hash than the list of fields itself??), but you can't always get what you want.



  • P = Skunkworks guy. Or by the looks of things, I should say junkworks.

    I put the other P in PHP!



  • "Cowtowing"? What is that? Dragging a cow around behind you?



  • @Shagen said:

    "Cowtowing"? What is that? Dragging a cow around behind you?

    Sometimes jump-starting them just doesn't work.


  • Discourse touched me in a no-no place

    @Shagen said:

    "Cowtowing"? What is that? Dragging a cow around behind you?
    It's what you do to coworkers when they're refusing to ork.



  • @Shagen said:

    "Cowtowing"? What is that? Dragging a cow around behind you?
     

    If you can't tip 'em, tow 'em!



  • @dhromed said:

    @Shagen said:

    "Cowtowing"? What is that? Dragging a cow around behind you?
     

    If you can't tip 'em, tow 'em!

    Someone outside the U.S. has heard of cow-tipping?

    We really are taking over the world.



  • @Someone You Know said:

    @dhromed said:

    @Shagen said:

    "Cowtowing"? What is that? Dragging a cow around behind you?
     

    If you can't tip 'em, tow 'em!

    Someone outside the U.S. has heard of cow-tipping?

    We really are taking over the world.

     

    My bet is that the (somewhat cruel) recreation of cow-tipping is to be found wherever cows, humans, alcohol and/or cannabis are to be found.


  • Discourse touched me in a no-no place

    @Shagen said:

    My bet is that the (somewhat cruel) recreation of cow-tipping is [...]
    ... largely urban myth?



  • @PJH said:

    @Shagen said:
    My bet is that the (somewhat cruel) recreation of cow-tipping is [...]
    ... largely urban myth?
     

    Ahh... Um... I actually meant the practice of giving cows a small amount of money after they provide milk. I think it's cruel because they should be provided a living wage, and everybody knows that you are more likely to leave a tip when you are high.


Log in to reply