|
An uncommented method is punishable by death [or at least withdrawal of fluffy cushion privileges], but commenting obvious code like that is worse than not commenting.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Looks like the biggest crime is that your boss didn't insist you comment why you were selecting the form rather than what the function did. I'm assuming there's a good reason you didn't use frm.Activate and your comment would be an opportunity to explain that to future readers.
It can also be a useful technique to put down some comments first as an outline before writing the code. It doesn't take much more time and can even save time by allowing you to concentrate on the outline of a function before getting involved with the code.
|
|
|
|
|
Nah, he just "wants to see green", I quote.
It's an OO world.
|
|
|
|
|
Change your code colour to green and your comment colour to black - simple!
|
|
|
|
|
Clearly, you should have given him a more useful comment, such as...
frm.Select
|
|
|
|
|
ANd wha about the flux compensator?
"Dark the dark side is. Very dark..." - Yoda
--- "Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi
|
|
|
|
|
|
Have I given such a bad impression of him?
It's an OO world.
|
|
|
|
|
there should be minimum comments in the code, as they are not maintained properly and often lead to confusions.
comments should be put unless some very convoluted things are going on
No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it
|
|
|
|
|
And not to mention, in most cases comments a) states the obvious or b) lie to you, and only function as code-clutter. comments are the most misused feature of any programming language.
|
|
|
|
|
Another sample from our legacy code base...
If someVar = "2" = True Then
|
|
|
|
|
Its scary to think that someone who graduated with any sort of programming degree would write that.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Obviously, the culprit misheard the comment "Too true!"
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I'm tasked, as many of us are, with maintaining a codebase that was written by my predecessor. I'm finding some parts disgusting, and other, more like... fun?
Like the use of 'ToLower()' to make string comparison more safe...
if (someString.ToLower().StartsWith("text", StringComparison.OrdinalIgnoreCase))
-> Nice way to waste some cycles and memory for the Garbage Collector to play with!
if (someString.Substring(lastMarkend - 3, 3).ToLower() == "<Index>")
-> My little finger tells me, the functionality under this if must have been tested quite thoroughly.
NB: I've only changed the string names.
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
Oh oh! I've got the answer: #2 is false
|
|
|
|
|
#1, if you start counting at the first number.
|
|
|
|
|
Shouldn't #2 be:
if (someString.Substring(lastMarkend - 3, 3).ToLower() == ("<Index>").ToLower())
|
|
|
|
|
That would work better for sure
BTW, the string literal is just that, a string literal, when there are several 'consts'* defined some lines above
* without any const specifier or special naming of course!
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
#2 is even worse. The literal on the right is 7 characters long, the string on the left only 3.
|
|
|
|
|
Well spotted, I did stop at the case mismatch there!
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
I discovered this little gem courtesy of our lead developer.
Application.DoEvents();
Thread.Sleep(1000);
Application.DoEvents();
This is in a loop on the UI thread, called from a forms timer.
|
|
|
|
|
|
Application.DoEvents and Thread.Sleep are a classic combo that I have seen far too many times.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Coded by lazy programmers, for lazy programmers... This is what happens when you sleep at work!
It's an OO world.
|
|
|
|
|
Just read this story in the lounge[^]. Reminds me of a true shame...
Our 'senior', SQL expert recently wrote some dynamic SQL SP recently.
He is fully aware of SQL injection and actually went about it keeping security in the back of his head.
This is what he came up with (just his idea, not the query)...
sql_statement = 'select '''@param''' from someTable'
I took a look at the query and asked him what in the hell all those apostrophes where doing there (the thing was full of it, lots of magic going on there!).
He said that was to prevent SQL injection. Can you imagine my reaction?
I broke it with a single search for "D'artagnan"
It was then and there that I (a SQL rookie) thaught him about quotename[^]...
It's an OO world.
modified on Tuesday, August 30, 2011 10:23 AM
|
|
|
|