• (nodebb)

    function isfrist($val1) { return (is_frist($val1) || ($val1 == 'FILE_NOT_FOUND')); }

  • (nodebb)

    Let me guess. Some database interface layer (or something) would sometimes coerce a NULL to an empty string? So things began breaking until isnull was added?

  • (nodebb)
    void ArmNuke() 
    {
      Arm_Nuke();
      LaunchNukeExplosion();
    }
    
  • (nodebb)

    I'm confused - last time I wrote something in PHP there was only the function isset() to check for nullability. Making an extra function for something basic feels to my rather pointless.

    BTW php has also a null aware equality operator (similar to JS):

    $val1 === ''
    
  • Tim (unregistered) in reply to colejohnson66

    Oracle itself (and MS dynamics) coerce an empty string to null so the problem isn't necessarily just in the DB interface layer. SQL server on the other hand does differentiate between null and empty string but doesn't differentiate between an empty string and one containing only spaces. The moral is clear - don't trust anybody or anything

  • Sauron (unregistered)

    function what_is_trwtf() { return "PHP"; }

  • Labasta (unregistered)

    Underscoring the importance of picking a good programming language

  • LZ79LRU (unregistered)

    A bad workman blames his tools. A good one gets to pick his. The rest of us laugh at our own misfortune.

  • Industrial Automation Engineer (unregistered) in reply to Mr. TA

    void ArmNuke() { Arm_Nuke(); AimAtFoot(); LaunchNukeExplosion(); }

    FTFY

  • LZ79LRU (unregistered)

    Personally I prefer the world altering missile.

  • (nodebb)

    PHP is an endless source of WTFs. The design of the language (or rather absence of intentional design) is a WTF of its own.

  • Randal L. Schwartz (github)

    PHP: when you look at Perl and say, "I can make something simpler!". And then you fail, but everyone still uses it because of mod_php in Apache, and mod_perl wasn't meant for multi-tenant deployment.

    Hey, it got us into e-commerce.

  • (nodebb) in reply to Tim

    Oracle itself coerce an empty string to null

    Which is treated as an "obvious" thing by Oracle fans... and is a TOTAL NIGHTMARE for who must develop applications that work well with multiple databases! Every year we have one or two angry customers because of a "NULL vs empty" bug in one of our applications :(

  • (nodebb) in reply to StefanoZ

    Every year we have one or two angry customers because of a "NULL vs empty" bug in one of our applications :(

    These bugs will never go away. NULL and empty string have distinct meanings, however, those meanings don't translate into UIs very well. For example, if a form has a checkbox that says "Ship to another address". The UI will usually disable the address text controls when said box is not checked. However, the UI serialization layer will most likely serialize those disabled fields as empty strings.

    I have also witnessed an individual "clearing a textbox" with the space bar. When he tabbed into it, the entire text was automatically selected, so hitting the spacebar seemed to clear it. Since the UI used a proportional font, the single space that replaced the previous text was so much smaller that it looked very similar to just the cursor. Enjoy the resulting single space in the database!

    Of course, really good database design can often help. But, the developer culture of "if it works, ship it" is working against us every step of the way. I'm actually looking forward to the day when AI based coding does all of the "easy things" so that professional developers will distinguish themselves not by doing the easy things faster, but by being able to do the hard things.

  • p (unregistered) in reply to MaxiTB
    Comment held for moderation.
  • (nodebb)
    Comment held for moderation.
  • (nodebb)

    sigh The Real WTF is a dev paradigm that treats nulls and empty strings as the same thing without actually making sure the one you don't want is always turned the other.

    I've encountered databases treating empty strings as null before. Evil, evil practice.

  • TheCPUWizard (unregistered)
    Comment held for moderation.
  • xtal256 (unregistered) in reply to Jaime
    Comment held for moderation.
  • Barf4Eva (unregistered) in reply to Tim

    I would prefer Oracle's behavior in this case, honestly. Usually blank string is a means to meet a requirement where a more stringent value is expected but the system was lazily built w/o all the constraints and/or udts to specify behavior/rules more accurately.

  • Matteo (unregistered)
    Comment held for moderation.

Leave a comment on “Underscoring the Importance of Good Naming”

Log In or post as a guest

Replying to comment #:

« Return to Article