|
Yeah and that wasn't even his biggest horror I'd laugh if I didn't have to work in the code
|
|
|
|
|
This code was written by someone who is used to VB6, I bet.
In this case it's not the code that is awesome - it's the language...
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Actually his resume said he had 20+ years of freelance programming experiance and 5 off those in C#.NET (if that is true is another story).
He also traded in a 3000€+ a month job for a 2000€ a month job
|
|
|
|
|
Tom deketelaere wrote: Actually his resume said he had 20+ years of freelance programming experiance and 5 off those in C#.NET
Impossible. This is an old school VB programmer. You can clearly see this from the above snippet (I'm not saying it's somehow bad VB6 code, but that it for sure is VB6 code).
There must be sth. wrong here...
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Well I can imagine that at some point he did work with vb6 (hell even I did) but this was written in .NET.
And his resume did say 5 years experiance in C#.NET but we (my boss and I) do think he had been lying a bit, since after he was fired here he told one off our customers (where he was being interviewed for a hardware maintenance position) he had experiance in maintaining servers.
He could barly keep his desktop pc running while he was here so... (he was actually not allowed to come anywhere near our servers :-P )
The guy had the tendancy to overcomplicated things (currently working on another one off his programs to get the CPU usage and Ram usage down since it olmost takes 100% CPU and more than 100mb ram, for a programme without GUI that's alot)
|
|
|
|
|
If the exceptions are forbidden for whatever reason, there is nothing wrong with it.
|
|
|
|
|
|
I agree. I generally prefer to see the normal paths first followed by the error paths. Deep nesting should be avoided other things being equal. But if there is a regular pattern to the code (as in your COM example elsewhere in the thread) this is fine. What is not fine is when you have deep nesting combined with loops and randomly sprinkled if-then-else blocks.
Kevin
|
|
|
|
|
Kevin McFarlane wrote: deep nesting combined with loops and randomly sprinkled if-then-else blocks.
They also call it reality - at least very often...
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Kevin
|
|
|
|
|
Thats a messy "spaghetti code". It looks very strange or like C#.
I would write more compact functions like LogOnHost(host,user,password) and SetFilePath(path,file)
Greetings from Germany
|
|
|
|
|
KarstenK wrote: It looks very strange or like C#.
What's your matter with C#? It allows for (and encourages) the cleanest and well structured code ever.
Regards
Thomas
|
|
|
|
|
But it allows -as seens- also the opposite.
Strange is in the above code alway one Set-Function for User and Password. I hope the Ftp-objects isnt a C# class.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: But it allows -as seens- also the opposite.
Sure, it allows for bad coding style as well - as every other programming language does even more.
Do you really blame C# for being a language that does not impose on its user what to say with it??
Do you have a car that forces you to adhere to traffic rules?
Does your money tell you what to buy with it?
...
Regards
Thomas
|
|
|
|
|
Right - and think about the possibilties of "bad coding" e.g. in C++ (add some mystic macros - done) vs. C#.. I think C# is a lot cleaner and full of nice features. The best programming language I know... (I used one or two during my career... )
|
|
|
|
|
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 AreTheyEqual
If 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"
|
|
|
|
|
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.
|
|
|
|