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();
-
For me, it was a WinForms app written in VB.NET that was using hidden Textbox controls on the form as a Boolean variable!!! The whole app was full with checks for true/false against a Textbox.Text property instead of simply declaring a boolean variable.
X| That one just is.... blech. Was this... programmer (I use the term loosely here)... a new guy? Or someone who knew nothing about what they were working with (e.g. PEBKAC o ID-Ten-T)?
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
-
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();
Don't know if my most interesting/funny/silly but some of the last I found. Comments should help to better understand ... maybe!
if (anyBooleanValue == false)
{ // in case of true
...
}
else
{ // in case of false
...
}... return; // leave the method
Twice are better ...
DataTable dt = new DataTable(); dt = otherTable.Copy();
-
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();
I once had to work on a package (in an 3G language/database called Dataflex if anyone remembers it) that contained the following remarkd
The following is Himalayan Mountain Climber code, and so is impenetrable to us mere mortals!
When I asked what this meant, I was told that it had been written by a contractor, whose hobby was indeed climbing in the Himalayas, who was known for using all sorts of undocumented tricks to provide very clever and efficient code that nobody else could understand.
==================================== Transvestites - Roberts in Disguise! ====================================
-
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();
}=====
\ | /
\|/
|
|-----|
| |
|_ |
_) | /
_) __/_
_) ____
| /|
| / |
| |
|-----|
|===
-
That's specially useful when you need to constantly comment in and out some of the conditions to find the right records. Without that you'd have to worry to every time replace the AND for a WHERE and vice-versa.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
Fabio Franco wrote:
That's specially useful when you need to constantly comment in and out some of the conditions to find the right records.
Without that you'd have to worry to every time replace the AND for a WHERE and vice-versa.For that, I use
TRUE
, e.g. in SQL:WHERE TRUE
AND X=Y
AND A=BYou can then comment in / out the real conditions without any worries about whether a leading AND is needed or not or even if any conditions remain. e.g.
WhereClause = "WHERE TRUE "
& ( test1wanted ? "AND X=Y " : "" )
& ( test2wanted ? "AND A=B " : "" ); -
Fabio Franco wrote:
That's specially useful when you need to constantly comment in and out some of the conditions to find the right records.
Without that you'd have to worry to every time replace the AND for a WHERE and vice-versa.For that, I use
TRUE
, e.g. in SQL:WHERE TRUE
AND X=Y
AND A=BYou can then comment in / out the real conditions without any worries about whether a leading AND is needed or not or even if any conditions remain. e.g.
WhereClause = "WHERE TRUE "
& ( test1wanted ? "AND X=Y " : "" )
& ( test2wanted ? "AND A=B " : "" );Same thing, except "1=1" is only three characters long :)
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
-
Same thing, except "1=1" is only three characters long :)
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
-
No need to ;)
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
-
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 worked on a system where the Fortran compiler generated constants in memory locations. All subroutine calls used pass by reference, so it was very easy for a constant to get changed. And very difficult to debug with the tools available in that day and age.
-
I worked on a system where the Fortran compiler generated constants in memory locations. All subroutine calls used pass by reference, so it was very easy for a constant to get changed. And very difficult to debug with the tools available in that day and age.
Prime OS had that, as well as GEC (IIRC) It made for some "interesting" debugging the first couple of times it happened, but then you leant not to trust constants! :laugh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
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.
-
X| That one just is.... blech. Was this... programmer (I use the term loosely here)... a new guy? Or someone who knew nothing about what they were working with (e.g. PEBKAC o ID-Ten-T)?
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
It gets better: This app was handed to me, so I can fix all kinds of weird and non-consistent errors that were happening all the time. The vb app was created by a contractor ($100/hr) who converted it from a Microsoft Access database that was developed by another consultant over a span of a year and a half for which she was paid in excess of $200k. Until this day, I cannot believe what I saw and comprehend how a consultant can get paid that much money for creating an Access database using textboxes as boolean variables and for another contractor to convert the code and not realize the insanity of that code either. And there was me, making just little over $50k at the time...disgusting isn't it
-
It gets better: This app was handed to me, so I can fix all kinds of weird and non-consistent errors that were happening all the time. The vb app was created by a contractor ($100/hr) who converted it from a Microsoft Access database that was developed by another consultant over a span of a year and a half for which she was paid in excess of $200k. Until this day, I cannot believe what I saw and comprehend how a consultant can get paid that much money for creating an Access database using textboxes as boolean variables and for another contractor to convert the code and not realize the insanity of that code either. And there was me, making just little over $50k at the time...disgusting isn't it
X| Well, that goes to show what non-programmers think: "If I cannot read it, it must be the best thing out there!" And that contractor was an ID-Ten-T that had a
NullBrainException
coupled with aIncompetentProgrammerException
and aOverpaidPersonException
.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
-
Just make sure they do not come up with PrintLibel() and this._Libel.