|
I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest":
// Check connection
checkConnection();
Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?
|
|
|
|
|
What I really love is when code gets changed but the comment does not. There was a huge thread on these types of things not that long ago.
//Check Connection
breakConnection();
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Does seem excessively redundant!
I think even Gomer would know not to do this.
Have you ever just looked at someone and knew the wheel was turning but the hamster was dead?
Trying to understand the behavior of some people is like trying to smell the color 9.
|
|
|
|
|
Mike Hankey wrote: I think even Gomer would know not to do this.
He'd run around screaming "citizens arrayest! citizens arrayest!"
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Mike Hankey wrote: even Gomer would know not to do this.
As I recall, he's an automotive mechanic, you don't think his wrenches are marked with their sizes? Seems redundant to me.
|
|
|
|
|
A good mechanic can tell the size of a wrench by looking at it so yeah that would be redundant to mark them.
Have you ever just looked at someone and knew the wheel was turning but the hamster was dead?
Trying to understand the behavior of some people is like trying to smell the color 9.
|
|
|
|
|
Maybe, but I'll bet if you looked closely at the implementation code, it might draw a check box onscreen next to the word 'Connection" and place a checkmark into it. Encapsulation can do that!
Will Rogers never met me.
|
|
|
|
|
That's worth more points if it turns out that checkConnection actually does not check connection.
|
|
|
|
|
It tries to open a connection; the catch block displays an err msg if it fails.
|
|
|
|
|
Well then it's named wrong... It should have been:
tryToOpenConnectionAndDisplayAnErrorMessageIfItFailsThankYouAndGoodnight();
|
|
|
|
|
B. Clay Shannon wrote: It tries to open a connection That was my first hunch.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
// Check connection
checkConnection();
// Cash connection
checkConnection();
// Credit Card connection
checkConnection();
// Debit Card connection
checkConnection();
|
|
|
|
|
PIEBALDconsult wrote: // Cheque connection
chequeConnection();
FTFY.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
czechConnection
frenchConnection
|
|
|
|
|
It gets even better. I've even seen something akin to this in Basic...
Let x = 5
Jeremy Falcon
|
|
|
|
|
Or:
double x = 0.1;
Which is actually a lie.
|
|
|
|
|
I've seen something like that, except the writer of the comment started about memory and how it works internally... Except the comment clearly showed the writer had no clue what actually happened
Can't remember where I've seen it or what the comment said though
It's an OO world.
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
Ughhh. It should really be:
<br />
check_connection();<br />
|
|
|
|
|
Just because he's a pro at naming a function doesn't mean the comment is bad.
|
|
|
|
|
I don't always comment my code, but when I do...
//TODO: insert comment here.
|
|
|
|
|
// Whereas we wish for this application to interact with a database
// and whereas such interaction will require a connection to the server and instance of said database
// and whereas a connection of this type relies on many fluctuating unknowns within the server and network infrastructure
// and further, given the business-critical nature of this application and its associated interaction with the database
// it has therefore been determined that checking whether or not such a connection can be successfully negotiated as early as possible
// in the event that such a connection cannot be negotiated, then remediatory actions may be activated in a more timely manner than otherwise feasible
checkConnection();
|
|
|
|
|
Found stuff like that too.
SaveCustomer()
Even worse:
SaveProduct()
The code was copy/pasted and then changed, but of course the comments were overlooked.
But that's not all:
Dim helper As String
helper = "Something"
If someCondition Then
MessageBox.Show(helper)
End If
Yes, in that last part the 'helper variable' is actually a constant string that may or may not be used further in the function... Good thing it was commented
And you wonder why VB has a bad name? This has nothing to do with VB, but with coders that can't code...
It's an OO world.
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
Sander Rossel wrote: coders that can't code...
I disagree... the whole purpose of code is to not be readable.
|
|
|
|
|
Most comments (or error messages) are written by the same master of the obvious.
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript.
|
|
|
|
|
My favorite was akin to this:
// Actually means hasn't been modified except in the function in file xxx.c
bool isModified = false;
The comment was actually accurate and isModified really did switch meaning multiple times throughout the code.
|
|
|
|