This WTF is not here... yet



  • This piece of code was created by a senior PHP developer (and no laughing here, I myself work as a code architect/senior developer and I believe we are doing great job writing our code). I was not to find it until he left the company and I was the one to take over maintenance of this baby. It seemed to work ok until one of the users decided to click that hardly-ever-used option in the interface.

    Below is a routing table form one of the modules (clearly added there for clarity, so all modules could be invoked with the same syntax and all their methods were private):

    public function query($data)
    {
    	$action = isset($data['action']) ? $data['action'] : 'list';
    
    switch ($action)
    {
    case 'foo':
    	return $this->computeSthForFoo($data);
    case 'bar':
    	return $this->calcBarValue($data);
    // [... - you get the idea, I anonymized the above part - patrys]
    case 'baz':
    	// this function is not implemented. had you ever had to call
    	// it, feel free to implement it or contact John Doe
    	die();
    default:
    	trigger_error('Unhandled action value: ' . $action, E_USER_ERROR);
    }
    

    }

    I think I don't have to add that there was an icon in the GUI that called a method which in turn at some point called this 'baz' action? And that the system was running in production on several sites for at least 2 months...



  • This is very handy for when, one day, I decide to completely foo my documents.



  • @dhromed said:

    This is very handy for when, one day, I decide to completely foo my documents.


    You seem to be missing the "I anonymized the above" part. These are not the real names of actions, obviously.



  • I can sort of see this happening in a hurried environment where developers are being pulled ten different ways at once, and some gui developer put the icon on the screen, but the server developer didn't get to the implementation; clearly a management coordination WTF. More importantly, where TF were the QA folks who are supposed to find exactly this sort of thing?



  • @snoofle said:

    I can sort of see this happening in a hurried environment where developers are being pulled ten different ways at once, and some gui developer put the icon on the screen, but the server developer didn't get to the implementation; clearly a management coordination WTF. More importantly, where TF were the QA folks who are supposed to find exactly this sort of thing?
    Usually understaffed and overworked, from what I've seen.  Management focuses fewer resources on the QA staff, figuring Development needs the resources more since they're the ones producing the code.  Development assumes if there are any integration problems, QA will find them, so they only test the things immediately around their changes.  Meanwhile, QA doesn't get anything of significance to test until the last minute, so they cram in as much testing as they can.

    Obviously, this isn't always the case, but this seems to be the direction things trend if you don't guard against it.



  • @Thuktun said:

    Usually understaffed and overworked, from what I've seen.  Management focuses fewer resources on the QA staff, figuring Development needs the resources more since they're the ones producing the code.  Development assumes if there are any integration problems, QA will find them, so they only test the things immediately around their changes.  Meanwhile, QA doesn't get anything of significance to test until the last minute, so they cram in as much testing as they can.

    Obviously, this isn't always the case, but this seems to be the direction things trend if you don't guard against it.


    Unfortunately, you are soooo right here. Anyway, having a function that just die()s instead of printing a simple "not implemented" was quite funny to discover. Or not, we've spent a while while searching for this one.


Log in to reply
 

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