Prototype Code BoolStruct

  • Thread starter Thread starter Jeff Louie
  • Start date Start date
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 *)executeWithExceptions:(NSString *)SQL; // throws
exception on err
- (Data *)executeScalarWithExceptions:(NSString *)SQL; // throws
exception on err
- (BOOL)executeNonQueryWithExceptions:(NSString *)SQL; // throws
exception on err

- (NSString *)lastError;
- (ResultSet *)execute:(NSString *)SQL;
- (BOOL)executeNonQuery:(NSString *)SQL; // for update, insert and
delete
- (Data *)executeScalar:(NSString *)SQL; // for returning autonumbers

Regards,
Jeff
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... 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
 
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.
 
Back
Top