Prototype Code BoolStruct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Louie

    #1

    Prototype Code BoolStruct

    This afternoon I coded a prototype user defined structure for use as a
    return value. The structure wraps a boolean value, the source and an
    error message. Comments appreciated.

    Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!


    Regards,
    Jeff

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Jon Skeet

    #2
    Re: Prototype Code BoolStruct

    Jeff Louie <jeff_louie@yah oo.com> wrote:[color=blue]
    > This afternoon I coded a prototype user defined structure for use as a
    > return value. The structure wraps a boolean value, the source and an
    > error message. Comments appreciated.
    >
    > http://www.geocities.com/jeff_louie/OOP/oop11.htm[/color]

    I would choose a different use-case if I were you - my first thought
    was, "Eek, don't do that - just use exceptions instead."

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Jeff Louie

      #3
      Re: Prototype Code BoolStruct

      Hi Jon... Thanks for looking at the code. I agree that it is a very
      "twisted"
      use-case designed to twist a student's brains! I will take your advice
      and
      conclude the chapter with a more conventional discussion of exceptional
      behavior. I have actually completed an Objective-C API that has two
      versions of each method:

      // EXCEPTIONAL METHODS
      - (ResultSet *)executeWithEx ceptions:(NSStr ing *)SQL; // throws
      exception on err
      - (Data *)executeScalar WithExceptions: (NSString *)SQL; // throws
      exception on err
      - (BOOL)executeNo nQueryWithExcep tions:(NSString *)SQL; // throws
      exception on err

      - (NSString *)lastError;
      - (ResultSet *)execute:(NSSt ring *)SQL;
      - (BOOL)executeNo nQuery:(NSStrin g *)SQL; // for update, insert and
      delete
      - (Data *)executeScalar :(NSString *)SQL; // for returning autonumbers

      Regards,
      Jeff[color=blue]
      >I would choose a different use-case if I were you - my first thought[/color]
      was, "Eek, don't do that - just use exceptions instead."<



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Jeff Louie

        #4
        Re: Prototype Code BoolStruct

        Jon... Um Er. I made a funny for you!

        class AliBabaCave
        {
        public BoolStruct Open(String magicString)
        {
        BoolStruct bs= new BoolStruct(
        true,
        "",
        "Class: AliBabaCave; Method: Open."
        );
        if ((magicString != null)&& (magicString == "Open
        Sesame"))
        {
        // do nothing
        }
        else
        {
        bs.Value= false;
        bs.Message= "Nope. You Boo Boo.";
        }
        return bs;
        }
        }

        Regards,
        Jeff[color=blue]
        >I would choose a different use-case if I were you<[/color]

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Jeff Louie

          #5
          Re: Prototype Code BoolStruct

          Oops. A little too quick there.

          class AliBabaCave
          {
          public BoolStruct Open(String magicString)
          {
          BoolStruct bs= new BoolStruct(
          true,
          "",
          "Class: AliBabaCave; Method: Open."
          );
          if (magicString == "Open Sesame")
          {
          // do nothing
          }
          else
          {
          bs.Value= false;
          bs.Message= "Nope. You Boo Boo.";
          }
          return bs;
          }
          }

          See ya.

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...