Code that makes you go "hmmmm"
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
This is a true horror & unfortunately I've seen my fair share of this 'style' of coding, usually from ex VB6 programmers... get over it & learn your way around the .net framework is what I say! What's the deal with Apples & Oranges? they're not even used?? Are there other fruit themed vegetables variables in the project?!
"An eye for an eye only ends up making the whole world blind"
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
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
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
:omg: 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]
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
Hi I like this code... :laugh: ... 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 ;P Tommy
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
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.
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
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
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
-
:omg: 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 :-O
Greetings from Germany
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
Ooh, that gave me headache before I even got to the end of the declarations! :~
Kevin
-
Where I am working, there USED to be a guy here who had written the following piece of code (swear to God this is a true function):
Private Function CaseInsensiveCompare(ByVal str1 As String, ByVal str2 As String) As Boolean
Dim Apples As String = str1.ToUpper()
Dim Oranges As String = str2.ToUpper()
Dim AreTheyEqual As Boolean = str1.Equals(str2)
Dim NotEqual As Boolean = Not AreTheyEqualIf AreTheyEqual = True Then Return AreTheyEqual <> NotEqual Else Return AreTheyEqual = NotEqual End If Return (Not (AreTheyEqual)) = NotEqual Or AreTheyEqual End Function
What boogles me is: 1. Why write a function for this? Just use If str1.ToUpper()=str2.ToUpper() Then ... 2. Why in the hell use this NOT logic stuff? 3. Is that final Return ever even hit in any scenario? My best guess as to why he would have done this is maybe he was testing something and was commenting/decommenting a line in there.
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.