Include me once...



  • if (include_once('HTTP/Request.php'))
        require_once('HTTP/Request.php'); 
    else
        require_once('HTTP_Request/Request.php');
    

    From some stupid broken API...



  • Oh. My....



  • I'ld like to see the following:


    includes/utils.php:

      [...]
      function include_twice($filename) {
        include($filename);
        include($filename);
      }
      [...]

    index.php:

      // Make sure utils.php gets included, contains all our utility functions.
      //include_twice('includes/utils.php'); <- commented out... doesn't work???
      [...]

    I'm sure it has been done already.



  • @derula said:

    I'ld like to see the following:
    <snip>

    The closest I've seen to that was a little coding war.

    Brillant but "clever" coder wrote a funny little include file which had to be included twice.  The second time it was included, it somehow defined a bunch of API usage strings and stuff, for all of the things that it defined on the first load.  However it worked, it was very flaky - about every third regular update, something broke horribly, and said coder needed to spend several days getting it working again.

    Pedantic and unimaginative coder kept spotting the double-include and "fixing" it.  Approximately 1/3 of all changes were pedantic coder removing the double include, and approximately 1/3 of all changes were brillant coder or someone else reverting the change so the program would compile again.

    Eventually, both of those induhviduals left, and the code was fixed to not require the double include.  (That would've only required Brillant leave, but Pedantic left first.)  Yes, the revised code required one to update the internal code docs separately from the code, but in the next six months (I wasn't around beyond that), there were far fewer problems which halted all work.  Possibly more importantly, right before the code was revised, we ran into one and couldn't fix it otherwise.



  • @tgape said:

    Pedantic and unimaginative coder kept spotting the double-include and "fixing" it.  Approximately 1/3 of all changes were pedantic coder removing the double include, and approximately 1/3 of all changes were brillant coder or someone else reverting the change so the program would compile again.

    WTF, even after a short bout of this one would be curious to as who keeps reverting the changes, possibly also noting a commit message describing _why_ the change keeps getting recommited allowing for a clue-in or at least a conversation starter for the clue-in.

  • Discourse touched me in a no-no place

    @Lingerance said:

    @tgape said:

    Pedantic and unimaginative coder kept spotting the double-include and "fixing" it.  Approximately 1/3 of all changes were pedantic coder removing the double include, and approximately 1/3 of all changes were brillant coder or someone else reverting the change so the program would compile again.

    WTF, even after a short bout of this one would be curious to as who keeps reverting the changes, possibly also noting a commit message describing _why_ the change keeps getting recommited allowing for a clue-in or at least a conversation starter for the clue-in.
    Even more WTF - how did Mr. Pedantic not notice his changes were breaking stuff?


  • @PJH said:

    Even more WTF - how did Mr. Pedantic not notice his changes were breaking stuff?

    That's easy. As far as Mr Pedantic is concerned, changing the double include to a single include isn't changing anything. So if something goes wrong, he can answer (mistakenly, but from his view honestly) with the Programmer's Lament, "I didn't change anything!"


Log in to reply