|
Yes, a horror indeed. Perhaps he wrote the code on April Fools Day
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The programmer is trying to compare Apples to Oranges. That function will always return false.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Youre completly wrong: the code will work. But not always return the truth.
CaseInsensiveCompare( "apple", "apple" ) -> true: OK
CaseInsensiveCompare( "apple", "orange" ) -> false: OK
CaseInsensiveCompare( "Apple", "apple" ) -> false: BUG
really SCNR
Greetings from Germany
|
|
|
|
|
It gets worse. He's getting the upper case values, then comparing the original values
|
|
|
|
|
Hi I like this code... ... oranges and apples are very coloured variable, and in particular i like the IF clause that is very clear.
I think that if this man have to compare two INT, he write a
if (isLess and not isMoreThan1 or not (isDivisibleBy3 and isSQRTof45)) then
return isNotMajor and (not isMonday or isFriday)
endif
return true
Tommy
|
|
|
|
|
This code is poorly organized with terrible variable names and it is very inefficient. But, the worst thing is that it not only doesn't work, it is hard to believe that even a beginning programmer would think it would work. I would hope that this function was written as a joke and was never called by the rest of the program.
Bill W
Just because code works, it doesn't mean that it is good code.
|
|
|
|
|
From time to time there are sort of surreal moments in life. Moments where one simply thinks This can't just be true. This is not really happening.
I had such a moment when I saw this 'code'.
Regards
Thomas
|
|
|
|
|
I think it's just meant to be humorous. It's deliberately made ridiculous. Too bad it has a real error though as already pointed out.
|
|
|
|
|
Ooh, that gave me headache before I even got to the end of the declarations!
Kevin
|
|
|
|
|
There's just one thing that puzzles me about VB6: why are all the OTHER VB6 programmers so bad? I don't use VB6 anymore (when I saw .NET, I never looked back), but I was never this bad -- I wasn't even this bad when I was writing programs in QBASIC! I mean, seriously!
So what's with all the amazingly awful VB programmers? It must be a curse.
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
string str = "Even exception occur again in catch block still finally block is Working";
try
{
throw new IndexOutOfRangeException();
}
catch
{
goto Hello;
throw new IndexOutOfRangeException();
}
finally
{
Response.Redirect("Error.aspx?str="+ str);
}
Hello:
Response.Write("Finally Skiped!");
}
http://www.codeproject.com/KB/aspnet/DotNetBulletQuestions.aspx?msg=2764693#xx2764693xx[^]
A goto in a try/catch/finally block... urrrghh!
|
|
|
|
|
My 5, that code is pure Horror. Anyway (I made a test) the goto statement it is ininfluent.
BTW I didn't know C# has goto statement, is there a reason to have it in such a language?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
For me, the GOTO statement is to be removed completely. When you got to situations where you need to skip a finally, you should better rethink your design/architecture and your code. A clean rewrite of your code and your conditions and tests let you avoid situations like this easily and cleanly!!!
________________________________________
http://www.glyphart.com neat icons and glyphs for websites and applications
|
|
|
|
|
You cannot skip (at leat that way) finally .
On the overall I agree with you. I don't see any reason (maybe there are...) to live the goto statement in C# .
IMHO:
- In C the goto statement makes perfectly sense.
- In C++ it makes seem because of C compatibility.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: BTW I didn't know C# has goto statement, is there a reason to have it in such a language?
A reason ? Maybe no, but you could need one if you use a switch.
switch(iData)
{
case 0:
case 1:
break;
case 2:
goto 3;
case 3:
break;
}
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
Yeah, the poor mans drop through.
Bar fomos edo pariyart gedeem, agreo eo dranem abal edyero eyrem kalm kareore
|
|
|
|
|
o really ??
i think it can be used like this :
switch(iData)
{
case 0:
case 1:
// do stuff for 0 and 1
break;
case 2:
// do stuff for 2
case 3:
// do stuff for 2 and 3
break;
}
if the break statement is missing, it go through next case ..
VirtualVoid.NET
|
|
|
|
|
It is NOT C/C++ , my friend, it is C#
Juraj Suchan wrote: case 0:
case 1:
// do stuff for 0 and 1
break;
Fine: It is allowed.
Juraj Suchan wrote: case 2:
// do stuff for 2
case 3:
// do stuff for 2 and 3
break;
That's not allowed in C# (well, in fact, it is allowed as it stands, with just comments ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ou .. am I blind? sorry
VirtualVoid.NET
|
|
|
|
|
in C++ drop throw switch-statement is allowed in C# not - if it was that, you didn't see.
|
|
|
|
|
|
I like this reason as well
void foobar()
{
// blah blah blah
for(...)
{
// blablabla
for(..)
{
// foo foo foo
if(bar)
goto end;
}
}
end:
// beep bop a loola
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
You may throw an exception for that.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
That's a worse offense than a goto IMHO - exceptions should be reserved for exceptional conditions (the clues in the name) not used as an alternative control flow mechanism.
|
|
|
|
|
Rob Grainger wrote: not used as an alternative control flow mechanism.
That's exactly what they are (IMHO).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|