- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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.
Edit Admin
More likely it was one of those "make the minimum changes possible" situations, as in the case below:
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.)
Admin
This screams "git merge error" to me.
Admin
as in "should not have been merged"?
Edit Admin
You know the old saying: "If you're using 16 spaces as your indent, you need more spaces."
Edit Admin
Agreed, and the "other stuff" was probably logging which a PHB decided wasn't necessary.
Edit Admin
Boss: I like tab size 2. Programmer: Yes, sir! TAB, TAB. 🤣
Edit Admin
This appears to be one case where no one can argue that they had a convenient place to put a breakpoint for debugging.
Edit Admin
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...
Edit Admin
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.Admin
Measure twice, cut once!