• Darren (unregistered)

    I wonder if this was originally some kind of check to limit the number of attachments - between 1 and 10 is fine, any more then do something else - but the requirement was changed and this is the remnants that are left 'just in case' the requirements come back.

  • (nodebb) in reply to Darren

    but the requirement was changed and this is the remnants that are left 'just in case' the requirements come back

    More likely it was one of those "make the minimum changes possible" situations, as in the case below:

    if ( there are entries in the array )
    {
        // do some stuff that might remove no entries, some entries, or all entries
         ...
    
        if ( there are (still) entries in the array )
        {
            // do some other stuff that might output a supplementary line of text if there are entries
            ...
    
            foreach ( $files as $file )
            {
                 // addAttachment stuff
            }
        }
    }
    

    And then the requirement for removing no/some/all entries disappeared, and then the requirement for the other stuff disappeared, so only the if()s remain outside the foreach(). (Removing the if()s would count as making more changes than the minimum possible, so they remain with us.)

  • RLB (unregistered)

    This screams "git merge error" to me.

  • erffrfez (unregistered) in reply to RLB

    as in "should not have been merged"?

  • (nodebb)

    You know the old saying: "If you're using 16 spaces as your indent, you need more spaces."

  • (nodebb) in reply to Steve_The_Cynic

    "do some other stuff" that was removed

    Agreed, and the "other stuff" was probably logging which a PHB decided wasn't necessary.

  • (nodebb)

    Boss: I like tab size 2. Programmer: Yes, sir! TAB, TAB. 🤣

  • (nodebb)

    This appears to be one case where no one can argue that they had a convenient place to put a breakpoint for debugging.

  • (nodebb)

    Agreed, and the "other stuff" was probably logging which a PHB decided wasn't necessary.

    Probably, although I wouldn't be surprised if it was (also?) the generation of an extra line of output in the mail, something like "files are attached", which someone rightly critiqued for being redundant...

  • (nodebb)

    Foreach on an empty object is a no-op, but how about Foreach on a null object? If sizeof(null) == 0, perhaps it was initially used as a "clever" null guard.

  • Just like carpentry (unregistered)

    Measure twice, cut once!

Leave a comment on “Are There Files Yet?”

Log In or post as a guest

Replying to comment #699226:

« Return to Article