|
Yet, I'm back from eight nights in Jamaica. Visibly heavier from massive all-inclusive feeding frenzies.
Actually got home 1:30 yesterday, arose for work @4:30, and thus, fully armed with three hours sleep and a killer tan, I boldly put on the appearance of working.
Just reminded me again why I want need to win the lottery;
P.S.: Bill Gates. If you are reading this, please adopt me. You'd never miss 1/10 of 1%
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "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 |
|
|
|
|
|
Where were you during the days?
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
PIEBALDconsult wrote: Where were you during the days?
Eating at the All inclusive buffet ?
I'd rather be phishing!
|
|
|
|
|
With the likes of this[^] around, I'm surprised he remembers anything, the stuff can hurt you.
|
|
|
|
|
This^ is more to my liking.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "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 |
|
|
|
|
|
PIEBALDconsult wrote: Where were you during the days dazed?
FIFY: Correction should explain
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "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 |
|
|
|
|
|
Programming Quiz of the day.
I just wrote this code (C#), which did something very unexpected. What was it that it unexpectedly did?
bool more = ProcessFlyouts();
more = more || ProcessCarrierAnimations();
How would you change it to "do the right thing?"
Marc
|
|
|
|
|
Can you define 'right'?
[Flags]
public enum Bool {
True, False, ForSure, Maybe, ProbablyNot, Depends, NotDecidedYet, Undefined
}
private interface IStealth { }
|
|
|
|
|
You should be able to glean what the programmer intends to happen from the code.
Marc
|
|
|
|
|
Maybe, if I could see the content of both methods that return a bool
Otherwise, quite hard to detect a logic issue when the logic itself is not told.
[Flags]
public enum Bool {
True, False, ForSure, Maybe, ProbablyNot, Depends, NotDecidedYet, Undefined
}
private interface IStealth { }
|
|
|
|
|
Marc Clifton wrote: You should be able to glean what the programmer intends to happen from the code.
Riiiiiiiiiiight!!!
|
|
|
|
|
Have you been to QA lately?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Without further information, it is obvious that the programmer intended ProcessCarrierAnimations() to only be called if ProcessFlyouts() returns false.
I'm with OriginalGriff on this..
ProcessCarrierAnimations() || more;
This is clearly the better way to express intent that using a bitwise OR. Unless there are tests like this all over the code done with bitwise ORs, using one here requires the next programmer to notice you did something atypical here in a fairly subtle way, which means its a maintenance hazard, which in my book is part of the definition of poor coding.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
|
Exactly.
|
|
|
|
|
Yep, but this is a workaround, not a best practice though.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what it used to.
|
|
|
|
|
Yuck. One of my least favorite things when reading someone else's C/C++ code is when they mix logical and bit-wise operators in an expression. In this case, using a bit-wise operator on bool values just seems wrong.
Software Zen: delete this;
|
|
|
|
|
I agree, it's not something I'd use myself. I was only answering Marc's academic question
|
|
|
|
|
I thought that was the case - your response just seemed rather unNish-like .
Software Zen: delete this;
|
|
|
|
|
Heh
|
|
|
|
|
I'm not quite sure what was unexpected here. If you mean the ProcessCarrierAnimations() never gets called if (more == true) then it really was expected
However changing || to | will make it called regardless of more's value.
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
deflinek wrote: However changing || to | will make it called regardless of more's value.
Yup!
Marc
|
|
|
|
|
It will run either ProcessFlyouts, or ProcessCarrierAnimations, or neither, and the variable will tell you if it successfully ran either. I would imagine you either want && or |.
|
|
|
|
|
|
>> It will run either ProcessFlyouts, or ProcessCarrierAnimations, or neither,
Um... Not even close.
It will, unquestionably, run ProcessFlyouts. It may also run ProcessCarrierAnimations.
Truth,
James
|
|
|
|