What was the most interesting, funny or silly Code you have ever read?
-
At the Company i am working in the Intellicence gave me These two methods. Microcernel.Create(). 1. PrintLabel() 2. PrintLable() Both methods contained the same oneliner. this._Label();
It wasn't funny at the time, but any VB.Net code that looked like this is hilarious in retrospect:
try
' lots of statements
catch
end tryOr even worse:
On Error Resume Next
' lots of statements
The developer's excuse? "My code doesn't crash!" Yeah. It also didn't work.
-
My favorite that I have seen is this...
if variable < 24 And variable > 26 then
'...
end if -
It wasn't funny at the time, but any VB.Net code that looked like this is hilarious in retrospect:
try
' lots of statements
catch
end tryOr even worse:
On Error Resume Next
' lots of statements
The developer's excuse? "My code doesn't crash!" Yeah. It also didn't work.
This one has it beat.
-
This one has it beat.
That's downright scary. I insist that people use C# so they don't get into bad habits like that.
-
if (this == null)
{
//WTF just happened?!?!!
Environment.Exit(-1);
}I cannot remember the exact code block, but it was something along those lines. And yes, somehow, that condition happened. And 'this' was the actual keyword, not some redefinition of it. I still don't know how that one happened.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
Zac Greve wrote:
//WTF just happened?!?!! Environment.Exit(-1);
Way back in the 1980's, I was using Sun 3 workstations running UNIX. We had FrameMaker, back before Adobe got ahold of it. On UNIX, there is a command called "strings" that attempts to extract all the ASCII strings from a file. If you ran it over FrameMaker.exe, one of the strings you got was... "Evacuate now? In our moment of triumph? I think you overestimate their chances." There is no way to tell what error case causes this message to print, or just what happens right after, but I really want to know.
-
At the Company i am working in the Intellicence gave me These two methods. Microcernel.Create(). 1. PrintLabel() 2. PrintLable() Both methods contained the same oneliner. this._Label();
in FORTH: Begin ... if ( swap ) ... until then The parentheses allow you to leave the compiler, so the swap changes the addresses on the stack so the straddled begin and if statements worked.
-
At the Company i am working in the Intellicence gave me These two methods. Microcernel.Create(). 1. PrintLabel() 2. PrintLable() Both methods contained the same oneliner. this._Label();
This is going back many years, and from memory it went something like this:
- (bool)is_even(int value)
{
if (value == 0)
{
return true;
}
else if (value == 2)
{
return true;
}
else if (value == 4)
{
return true;
}
...
else if (value == 12)
{
return true;
}return false;
}
And so it went to 12 and I guess for the context in which it was used it apparently was a high enough number. You could of course replace this method using a simple modulus operation. What's also funny is that I saw this code in a printout on the wall of an engineer, which had been there for a couple years. A short time after, another engineer, new to the group, found this method still existing in another part of the code base (apparently just copy-pasted from its original location). The code base was very large. Lesson learned is if you find bad code somewhere do a global search to insure it is not duplicated anywhere else.
-
This one has it beat.
Hahaha, level: advanced, and spent all day on it. So many levels of humor in that article...mind blown.
-
your object was finalized before the time, probably it had a unmanaged reference, when it had no more managed references, the GC collected it... Forgeting to pin a object is really a PITA, especially when it's the first time you are doing P/Invoke :sigh: (i was speaking of me, not sure if this is your case)
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
This wasn't my code, it was from one of my friend's projects. I cannot remember what the actual class did, but most of the projects code files were naive (and buggy) implementations of classes in the framework. I did show him the documentation, and his reply was "Cool! How did you know this existed?". Me: :doh:
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
This wasn't my code, it was from one of my friend's projects. I cannot remember what the actual class did, but most of the projects code files were naive (and buggy) implementations of classes in the framework. I did show him the documentation, and his reply was "Cool! How did you know this existed?". Me: :doh:
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
PEBKAC :-\
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
I think it was more of an ID-Ten-T error. Either that or a
BrainNotFoundException
. He has decided to become an English Major with Anthropology and History minors. :doh:I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
if (this == null)
{
//WTF just happened?!?!!
Environment.Exit(-1);
}I cannot remember the exact code block, but it was something along those lines. And yes, somehow, that condition happened. And 'this' was the actual keyword, not some redefinition of it. I still don't know how that one happened.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
Uhhhh... sure! :) Just kidding. The programmer at the time just probably forgot that they checked the same variable twice. Maybe it was supposed to be another variable. I have no clue what the intention was, but its still active in the program. I don't have the heart to comment it out because of how funny the goof is. :laugh:
int main (){
long variable = -1;long var24 = 24; unsigned long var26 = 26; if( variable < var24 && (variable > var26)){ printf("%ld, is a magic number, %lu, %ld, %ld", variable, variable, var24, var26); } return 0;
}
I was just wondering if this could come up somewhere in the code and still be funny. -JD
-
At the Company i am working in the Intellicence gave me These two methods. Microcernel.Create(). 1. PrintLabel() 2. PrintLable() Both methods contained the same oneliner. this._Label();
this following jQuery nugget:
if ( $('#'+src.id).parent().parent().next().children().children('.dvSpeakerBio').is(":visible") )
{
$('#'+src.id).parent().parent().next().hide();
$('#'+src.id).parent().parent().next().children().children('.dvSpeakerBio').hide();
$('.speaker').removeClass('selectedSpeaker');
$('.alt_speaker').css('background-color', '#f6f6f6');
} -
I'm not sure, but I've always thought it would be funny to leave this in some code and see people's faces:
if(10 != 10){
abort();
}=====
\ | /
\|/
|
|-----|
| |
|_ |
_) | /
_) __/_
_) ____
| /|
| / |
| |
|-----|
|===
I've seen that in older Fortran programs on compilers for systems that didn't have comparison against constants in their assembly language. They saved zero in a particular location and all comparisons were done against that location. Occasionally, someone would unknowingly pass 0 into a routine in the parameter position where the value was changed by the routine. That is when zero stopped becoming zero and was something completely different. It read something like if ((0+1) .ne. 1) call abend
-
This is going back many years, and from memory it went something like this:
- (bool)is_even(int value)
{
if (value == 0)
{
return true;
}
else if (value == 2)
{
return true;
}
else if (value == 4)
{
return true;
}
...
else if (value == 12)
{
return true;
}return false;
}
And so it went to 12 and I guess for the context in which it was used it apparently was a high enough number. You could of course replace this method using a simple modulus operation. What's also funny is that I saw this code in a printout on the wall of an engineer, which had been there for a couple years. A short time after, another engineer, new to the group, found this method still existing in another part of the code base (apparently just copy-pasted from its original location). The code base was very large. Lesson learned is if you find bad code somewhere do a global search to insure it is not duplicated anywhere else.
Haha I am sure i have read this in a book or programming tutorial as an example for bad code.
-
I think it was more of an ID-Ten-T error. Either that or a
BrainNotFoundException
. He has decided to become an English Major with Anthropology and History minors. :doh:I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
:doh: well, can't say i haven't found such cases... there was a guy on my class who left to become a surgeon... I hope I never have to be operated by him :~
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
-
in FORTH: Begin ... if ( swap ) ... until then The parentheses allow you to leave the compiler, so the swap changes the addresses on the stack so the straddled begin and if statements worked.
-
That was my thoughts exactly. However, there are many other instances like the example I posted. The worse I have seen are many goto statements.
-
Where 1=1 I mean that is obvious..