|
cpkilekofp wrote: Hmmm, does this count as a rant?
Oh definitely . Please don't take this personally
cpkilekofp wrote: the worst code was (and may still be) written in C/C++
Nobody said that the worse code seen was in VB. The joke was about how often the name Ugly Betty comes up whenever we are talking about ugly girls.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
|
|
|
|
|
There was tons of that in there too. Along with lots of catch blocks that broke the call stack by throwing a new, useless error message.
|
|
|
|
|
|
I think the guy created a function body to copy for other functions. That would save him writing the exception handling block over and over again when a new function is added. No coding horror, though it might look like one at first view.
|
|
|
|
|
Copying the exception handling over and over again would be a coding horror anyway. The exception should generally be caught in only a few places in the top tier.
|
|
|
|
|
There are easier ways
[ctrl][k][x] try [enter]
or
try[tab][tab]
even if you have already written the code- select code and
[ctrl][k][s] try [enter]
|
|
|
|
|
Maybe he didn't know about code snippets....
|
|
|
|
|
I find it brilliant. 100% bug-free!
|
|
|
|
|
I feel your pain. I've just finished going through a similar process. After a while you stop getting annoyed and start laughing. The one that made me laugh most was:
public class OrderName
{
public String getName {
return "Order";
}
}
That was the class in totality. One method that returned a hard coded value.
[EDIT] I just found a better one:
for (int i = 1; i < 2; i++) {
}
"You get that on the big jobs."
modified on Sunday, August 14, 2011 10:23 PM
|
|
|
|
|
Reminds me of things like this...
for (int i = 0; i < 5; i++) {
switch (i) {
case 1: {
}
case 2: {
}
case 3: {
}
case 4: {
}
case 5: {
}
default: {
}
}
}
|
|
|
|
|
This code feels like some Zen koan or something..
If a tree falls in the forest but no one is around, does it make a noise?
|
|
|
|
|
|
Reminds me of an application I support that had the following gem in it.
Not only was this method called only once in the entire solution, but apparently someone "forgot" to code anything in it. I'm sure this isn't the first time someone has seen this one, too.
private bool IsValid()
{
return true;
}
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
I've actually done something like this (but never left it in the production code) on a rapidly evolving piece of a class. The purpose behind it is that you originally start out with a method with let's say, 100 lines of code, then the person that was driving the requirements no longer wants the checking, so you go back, and in order to test your entire application quickly without refactoring, you throw the "return true" in there.
Not saying it isn't stupid to allow something like that to end up in production, just saying I've actually done it before for quick testing.
|
|
|
|
|
|
Collin Jasnoch wrote: if(_globalBannnaOrderView == null)
{
_globalBannnaOrderView = new BannaOrderView();
...
}
else
{
_globalBannanaOrderView.Focus();
}
Are _globalBannanaOrderView and _globalBannnaOrderView different variables, or just a typo? Because doing that on purpose would be an even worse Coding Horror.
Also, if you mean the fruit, it's spelled Banana. Not that it really matters, but it might be easier to be consistent... (I see Banna, Bannna, and Bannana in just the quoted section)
|
|
|
|
|
Collin Jasnoch wrote: not bug fixing.. These bugs then come back as zombies
+5 for this line
Greetings - Jacek
|
|
|
|
|
Only the comment after the method declaration is not mine. Some things have been changed to protect the innocent:
public DataTable GetFooByID(int memberID)
{
try
{
string query = "SELECT DISTINCT * FROM Foo WHERE bar=" + barId;
DataTable dt = Utils.ExecuteReader(query);
if (dt != null)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception("MethodID:= #210, Error:=" + ex.Message);
}
}
This sort of thing is repeated many times due to the delights of cut-and-paste. We've also cunningly embedded our data access stuff in our object models, no need to look in more than one place! We've not made any attempt at making Data Access easy for ourselves with proxy classes etc.
Mutters....
|
|
|
|
|
That if/else is a classic anti-pattern that I have seen far too many times as is the catch everything clause. However, giving the exception a MethodID number is not something I have seen very often, clearly this person is inventive. And I am sure that the Method ID will be of great use to the end user.
Copy and paste inheritance is in use everywhere. I'm even guilty of using that myself sometimes to get something working quickly. But, overall this code example is a classic horror.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
lol The comments are priceless. I really hope you left them in.
"You get that on the big jobs."
|
|
|
|
|
No code on this one, just a shameless story.
A few years ago I was working for a not very nice person (no comments). We were doing a small application for Microsoft (we were an MS vendor), and they asked us to convert it to SharePoint Web Parts.
Well, at that time (looooong time ago) we were just starting with SharePoint so we didn't know how. Instead of taking the time to learn and do it right, the boss spent COUNTLESS HOURS copying how a SharePoint site looked like, pretty much taking CSS and submenus and he went to Microsoft to give the demo. Luckily I was not there, I wouldn't be able to lie like that.
Luckily the MS guys didn't pay much attention to the demo, they just kind of saw the UI and the meeting went on.
The point is: how shameless do you have to be to blatantly lie to your customer? (and your only one for that matter)
Oh well... some people go in life being dishonest ...
Not me. Honesty is like virginity. You can go around in life being dishonest, but once you lose it you never get it back!
|
|
|
|
|
Unfortunately, most businesses work that way. Ethics seldom exist in business.
|
|
|
|
|
Tis sad tis true, tis true tis sad.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
CIDev wrote: Tis sad tis true, tis true tis sad.
That quote is, "Tis true, tis pity, and pity tis tis true." Hamlet, act 2, scene 2.
See ma? I didn't just take geek classes in college.
|
|
|
|
|
U r completely right dude! Now a days it more about Money then Ethics! And unfortunately that's true every where.
Richard Menezes
|
|
|
|