|
Warnings are for sissies. That's what my compiler told me.
|
|
|
|
|
I would prefer something that rings true and has an explanation when it fails.
Assert.IsTrue(TokenIsValid(token), "Invalid Token: "+ TokenCheck(token));
TokenCheck would say "Empty", "Wrong Length...must be 4 bytes" (or whatever), "Exceeds limits of 0-100"...etc....
Mike
|
|
|
|
|
Marc Clifton wrote:
Assert.IsTrue(token != Guid.Empty, "Token not received.");
Assert.IsTrue(token != Guid.Empty, "Token is empty (not received).");
The sense of the description now matches that of the assertion.
Software Zen: delete this;
|
|
|
|
|
Since there is a negation in the statement, I'd rather use option 2 in this case. The negation is clearer to me.
|
|
|
|
|
For me, it depends.
From my "programming childhood" I was brought up to write every funcition as a (1) verify all arguments and preconditions, (2) do the work, (3) prepare the results.
If in step 1 any precondition is not satisfied, then you prepare an error return and get out of there, making no changes. Don't even look at the work and result stages.
If anything in step 2 prevents you from creating a complete result, then you prepare an error return and get out of there, without any side effects or other kinds of results.
In step 3, with all preconditons met and all work successfully completed, you do whatever possible to preserve the results (e.g. wait for locks to be released). If all functions are written in this orderly manner, you very rarely run into problems in this step.
These "Get out of there" tests are usually semantically negative, even though they may be syntactically positive ("if (parameter outside legal range) ..."). The essential part is: Don't bother the clean work with debris (I count "n" levels of extra indentation due to validity checks as "debris"!). If there is nothing more you can do, then leave!
Any test that ends up in an abort/termination is placed as early as possible - and then there is no "else" and no extra indentation.
Within step 2, and sometimes even in step 1, the "if" selects one of two equally valid actions, or they are elseif-alternatives. In such cases, I write the test so that the most likely case comes first (even when that requieres negation of the logical expression). An elseif-sequence is ordered in decreasing likelyhood. The final else is the least likely one - like a default at the end of a switch case statement.
|
|
|
|
|
Option 1. Option 2, one could type token = guid.Empty. Or rewrite option 2 to guid.Empty == token.
|
|
|
|
|
Do we know that reincarnation is real for Italians, because of all the pasta lives they have?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Not sure. Let me noodle on it for a while...
“The palest ink is better than the best memory.” - Chinese Proverb
|
|
|
|
|
...and they always have a good view on things: Pasta la Vista!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Country folk, yes, but not so much for ziti dwellers. I rotini check on this information in my ditalini base and it seems true (orzo I imagined).
It may also explain the liking for Angel Hair.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I thought it had to something to do with flowers. All righty then.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
That's-a pizza cake!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I though it was about (RE) an extinct native American (INCA) population (NATION)
|
|
|
|
|
After an almost 4 month hiatus, I'm finally back to article writing. The last 4 months have been something of a nightmare turned reality, starting the week before Easter. Part of the hiatus involved my mother being diagnosed with heart disease, high blood pressure, high cholesterol, and diabetes. She's doing much better now, but it didn't look good for a while. First time diagnosis (at 89) for her, she hates going to the doctor, even though she used to be an OR nurse! Perhaps because she has been a nurse!
The other part of the hiatus involves me personally, and I'm happy to share, but you'll have to email me directly as the content is not really lounge appropriate (that'll raise some eyebrows!)
I consider everyone here to be part of my larger "digital community", and through the last 4 months I have also been graced with amazing community support where I live. I can't emphasize enough how important it is to be surrounded by loving friends during times of crisis. To paraphrase a cliche, keep your friends close and the crazies far, far away, in another galaxy.
While the emotional healing continues, I feel like I've finally regained enough of a foundation to stand on and start letting the creative juices flow again. I've really missed that!
Thanks for reading and thanks to Code Project for creating the connections to the people here that I relied on for some stability amidst all the turmoil, even though ya'll didn't know it.
|
|
|
|
|
Welcome back, look forward to your pearls of wisdom.
As Hoppy (or was it Roy?) used to say: happy trails.
Lou
"Yea though I walk through the valley of the shadow of death, I shall fear no evil. For I am the meanest S.O.B. in the valley"
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
Glad to hear your mother is doing better, always a scare when a loved one gets an unfavorable diagnosis.
Hope everything else works itself out and life returns to an equilibrium for you.
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
|
|
Welcome back!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Happy to hear your mother got better... We can wait for an other article a bit longer if that helps...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
Welcome back Marc, glad to hear that your mother is doing well. I'd like to think I helped.
|
|
|
|
|
Happy for you.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi Marc, I'm going through a similar situation with my mother (88) so I know how it must be, keep the faith
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
89, tough old bird then, here's hoping to a return to health.
I look forward to a healthy flow of rants and articles. Marc the level of respect and appreciation you have achieved in this community is equaled by very few, thank you.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I will not pry. I'll just say it's great to have you back in the saddle.
We're an email away if you ever need anything. And that's a pretty broad "anything".
cheers
Chris Maunder
|
|
|
|