• some guy (unregistered)

    It should probably return FILE_NOT_FOUND, though

  • (nodebb)

    It still shouldn't exist

    Depends. It might be used in calls to a function that takes some sort of predicate-callback as a parameter. Perhaps that indicates that there should be two versions of this hypothetical function, one that takes a predicate and one that takes no predicate but simply buttumes that the predicate-driven decision is always the "true" branch of the implied if(). (But that has a strong possibility of violating DRY / introducing duplicated code.)

    So, we don't have enough information in the article to decide if this is really a WTF.

  • (nodebb)

    Yeah. If it's useful at all, it goes along with some sort of function that takes a plug-in filter expression. This is the plug-in for "no filtration; pass every record"

  • Tim Ward (unregistered)

    Also it could be called by reflection which constructs the name - it might otherwise construct isCurrency, isBirthday or anything else. Providing the isAnything function avoids having a special case if-then-else.

  • Hans (unregistered)

    It looks like "null" (or "nothing" or whatever it is called here) also counts as "anything"

  • (nodebb)

    It does answer the question "Is anything really true?".

  • (nodebb) in reply to mynameishidden

    LOL. You can say it is philosophically correct.

  • (nodebb)

    Makes perfect sense. You can do tests for objects and for data types. But this will tell us if it's ANYTHING!

    I'd really like to know what calls this -- or if it's ever called at all.

  • LXE (unregistered)

    The submitter is simply not up to the submission.

  • (nodebb)

    This is probably in a library with other functions like isInteger, isString, isNumber, isNothing, isNull, isObject, etc... and at some stupid brainstorming session someone threw this in there. Probably a senior dev having a brain-fart and the junior dev tasked with implementing it just went ahead and did it.

  • (nodebb) in reply to davethepirate

    More likely isBusinessObjectType1, isBusinessObjectType2, etc., and this one is, perhaps, more correctly "isAnyBusinessObject", for the purposes of filtering e.g. database results (as I noted above).

  • Oracles (unregistered)

    The tricky part is knowing when to use its peer function, isSomething...

  • (nodebb)

    My kids used to play a variant of "Rock, Paper Scissors" which they called "Anything, Anything, Anything" (which by the way, nothing tops a Black Hole), so maybe that's what it's for?

  • Jonathan (unregistered)

    Agreeing that it could be used as a callback. I once wrote a routine that printed the results in a rather convoluted format, and was factored so that it accepted 5 SQL cursors (the routine was used for multiple reports).

    For reports where there were less than 5 output types I created cursors like these (I know I'm going to get the formatting wrong. Apologies in advance):

    SELECT

    NULL, NULL as STRING, NULL as DATE, NULL as DATE, NULL as DATE

    FROM DUAL

    WHERE 1=2

  • (nodebb)

    GP: Is Eris true? M2: Everything is true. GP: Even false things? M2: Even false things are true. GP: How can that be? M2: I don't know man, I didn't do it.

  • Jason Stringify (unregistered)

    *led

  • Loren Pechtel (unregistered)

    Count me amongst those who think this is a perfectly ordinary match-everything filter to be passed to something that expects a filter.

  • (nodebb)

    The real WTF is PHP.

  • Officer Johnny Holzkopf (unregistered)

    if (isAnything(outThere)) say(something);

  • t (unregistered) in reply to loneprogrammer

    Yes, yes, PHP bad. Some day people will get some new material maybe :p

    You can find a bunch of reasons why any language you dislike sucks. Or hell anything for us matter. Don't like mozzarella? There's probably some blog article you can Google that very convincingly lays out to others why mozzarella is the devil

    Anyway, modern PHP improved a lot on past versions

  • (nodebb) in reply to PotatoEngineer

    Oh that quote is from... Hmmm. I had to look it up and it was totally worth it: https://www.cs.cmu.edu/~tilt/principia/body.html

  • Osric (unregistered)

    Not sure why static is being described as "most correct" here - if this were an implementation of an interface, it (potentially) wouldn't be controversial, barring the fact that the name is rather poor

  • SleepingYeti (unregistered)

    I did this once. It replaced some useless code written by outsourcees that ran terribly. The client's GitHub actions, which no-one we could contact had the power to change, assumed that some code would be there, be over 80% covered by unit tests, and that these tests would pass.

    I would have left the code as-is and just never used it, but the unit tests didn't pass even before we joined the project.

    With functions like this, 80% coverage is an easy target

Leave a comment on “Anything and Everything”

Log In or post as a guest

Replying to comment #:

« Return to Article