Focused on clarity...



  • Everything in the project is this explicit.  This is from a class that simply wraps a boolean value.  Oh, the wonders of template code!

    public string BoolString
    {
    get
    {
    string boolString;

    try
    {
    if (this.m_value == true)
    boolString = "1";
    else
    boolString = "0";

    return boolString;
    }
    catch (Exception e)
    {
    throw e;
    }
    finally
    {
    }
    }
    }

    Because return m_value ? "1" : "0"; is too tricky.



  • @djork said:

    Everything in the project is this explicit.  This is from a class that simply wraps a boolean value.  Oh, the wonders of template code!

    public string BoolString
    {
    get
    {
    string boolString;

    try
    {
    if (this.m_value == true)
    boolString = "1";
    else
    boolString = "0";

    return boolString;
    }
    catch (Exception e)
    {
    throw e;
    }
    finally
    {
    }
    }
    }

    Because return m_value ? "1" : "0"; is too tricky.

    Yeah... but then do a "throw e"... 

    Looks for me like someone rigidly followed the spec without having the sightliest, tiniest clue WHY those rules are there.



  • @djork said:

    Because return m_value ? "1" : "0"; is too tricky.

     

    Is it 0 or is it 1? I can't tell. What are these question marks, quotes, zeroes, ones, semi-colons, ARE YOU WRITING IN GIBBERISH??? Logic overload dude! 



  • @dlikhten said:

    @djork said:

    Because return m_value ? "1" : "0"; is too tricky.

     

    Is it 0 or is it 1? I can't tell. What are these question marks, quotes, zeroes, ones, semi-colons, ARE YOU WRITING IN GIBBERISH??? Logic overload dude! 

    That was, of course, meant ironically. 



  • @djork said:

    Because return m_value ? "1" : "0"; is too tricky.

    If you ever wanted to make the UI display "true" and "false" instead of 1 and 0 for all booleans, yes that would be a pain in the arse.  you could take your chances with find and replace, but be careful.



  • @vt_mruhlin said:

    @djork said:

    Because return m_value ? "1" : "0"; is too tricky.

    If you ever wanted to make the UI display "true" and "false" instead of 1 and 0 for all booleans, yes that would be a pain in the arse.  you could take your chances with find and replace, but be careful.

    I don't get it.  I'm advocating using "?:" for the body of the method, not in place of calling this method.



  • I especially like that empty finally{} clause.

     



  • What, 6 replies and no "FILE_NOT_FOUND" references?

     

     


  • Discourse touched me in a no-no place

    @wgh said:

    What, 6 replies and no "FILE_NOT_FOUND" references?

    MEME_NOT_FOUND

    Happy?



  • @PSWorx said:

    @dlikhten said:
    @djork said:

    Because return m_value ? "1" : "0"; is too tricky.

     

    Is it 0 or is it 1? I can't tell. What are these question marks, quotes, zeroes, ones, semi-colons, ARE YOU WRITING IN GIBBERISH??? Logic overload dude! 

    That was, of course, meant ironically. 


    We sincerely hope.


Log in to reply