|
I have a deceptively simple scenario, and I want a simple solution, but it's not obvious which is "most correct" or "most Java".
Let's say I have a small authenticate(Client client) method in some class. The authentication could fail for a number of reasons...
Started by Draemon on
, 18 posts
by 18 people.
Answer Snippets (Read the full thread at stackoverflow):
Is this the only method where you have such a requirement? If not, just generate could just have the method return null....
Also, if the method that might fail is "low languages.
I don't like using arguments to collect messages.
Class.
|
|
When using ec2 run_instances() ( http://docs.amazonwebservices.com/AWSSDKforPHP/latest/index.html#m=AmazonEC2/run_instances ), which is the best way to check the response for a confirmation that the instance(s) have been created?
There is a CFResponse...
Started by Orlando R. on
, 1 posts
by 1 people.
Answer Snippets (Read the full thread at amazon):
|
|
Suppose you are using the ternary operator, or the null coalescing operator, or nested if-else statements to choose assignment to an object. Now suppose that within the conditional statement, you have the evaluation of an expensive or volatile operation...
Answer Snippets (Read the full thread at stackoverflow):
For situations where the is OK ) ? temp : null;
Ok, so one could have a method
bool IsOk( Connection c ) { return ( c != null ) ? temp : ( temp = server....
In that you can alter the IsOk check at any stage and are entirely lazy.
|
Ask your Facebook Friends
|
Given the following code (that doesn't work):
while True: #snip: print out current state while True: ok = get_input("Is this ok? (y/n)") if ok == "y" or ok == "Y": break 2 #this doesn't work :( if ok == "n" or ok == "N": break #do more processing with...
Started by Matthew Scharley on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
You could set a variable in the inner loop, and check it in the outer loop immediately after the inner loop exits, breaking....
Not done: isok= False while not (done or isok): ok = get_input("Is this ok? (y/n)") if ok in ("y", "Y like that.
|
|
Enum SQLErrorCode{ OK = 0, PARTIAL_OK = 1, SOMEWHAT_OK = 2, NOT_OK = 3, };
Code 1:
int error = getErrorCode(); if((error == SQLErrorCode.PARTIAL_OK) || (error == SQLErrorCode.SOMEWHAT_OK) || (error == SQLErrorCode.NOT_OK) || (error < 0)) callFunction...
Started by Devil Jin on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Error code is:
bool isOK(int code) { return code == SQLErrorCode.OK; }
and your code could become:
if (isOk(getErrorCode())) { callFunction2; } else { callFunction1; }
Not that it matters much.
|
|
There appears to be a memory leak within the PHP SDK. We picked this up after we tried to create a Daemon which polls a queue and processes any actionable items.
while ( true ) {
$sqs = new AmazonSQS()
$size = $sqs->get_queue_size( 'some_queue_url'...
Started by al3xdm on
, 22 posts
by 7 people.
Answer Snippets (Read the full thread at amazon):
Can you check your php.ini file and look' ); if ($response->isOK()) { $queue_url = $response->body->QueueUrl(0); } else { print_r); if ($response->isOK()....
As we're doing some PHP 5.4 alpha testing at the moment anyway .
|
|
I just stumbled across this bug in some legacy code:
class MyAPIHandler { private: int handle; public: void MyApiHandler() // default constructor { handle = 42; }; };
It compiles fine, with no warnings - but the behaviour wasn't what I intended, because...
Started by Roddy on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
For example:
class DoSomething() ; } ;
Or:
bool isOk(int....
MyAPIHandler mah; BOOST_CHECK_EQUAL It happens for constructors, but also for any other method, or even function.
Edit : thanks to commenter for the link
Unit tests .
Anyway.
|
|
I've programmed C and C++ for a long time and so far I've never used exceptions and try / catch. What are the benefits of using that instead of just having functions return error codes?
Started by KPexEA on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
If not, you could log something and then exit, or throw an error condition is not expected in any cases in the former case the caller of the function must check to check the error code....
IsOk ) has been called.
method ( e.g.
|
|
On Mon, 4 May 2009 20:01:13 -0700 (PDT), Alan <devices@iinet.net.au
Any suggestions on products for DIY PCBs?
Tried the Press-n-Peel transfer film, but it's crap. The film just
gets stuck in the fuser of the laser printer. Besides that, it's
...
Started by Alan on
, 9 posts
by 7 people.
Answer Snippets (Read the full thread at omgili):
<http
8) A piece of A4 typing paper
Method....
Check out the Homebrew pcb group on yahoo groups.
If you find some pieces
did not make, you can fill" papers is possible .
Check all the tracks, if all isOK then well done.
|