|
Re-using code blocks in different applications without checking that the pre-existing comments are relevant in the latest incarnation.
I keep finding examples of this in my archive. Stupid boy...
I may not last forever but the mess I leave behind certainly will.
|
|
|
|
|
harold aptroot wrote: - Unreachable code. Often mistaken for "defensive programming". Code that provably can't run is provably useless.
Dunno about that one - I once inserted a check that I was 100% sure couldn't possibly fail, so I inserted a message saying this shouldn't be happening, and to please contact me. Thank god, it was a beta tester eventually seeing said message, not an actual user in production code - it turned out I was wrong on my 100% assumption...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I hope it wasn't provably unreachable, that would have bad implications for the fabric of reality.
|
|
|
|
|
I picture things like if ( name.Length < 0 ) ...
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
To CYA in the future wrap that in a debug only block and let the app die more messily otherwise.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
All that you listed, especially the magic numbers. I would add "Not checking return values", assuming things are going to work is a recipe for pain.
OT:Chris Maunder wrote: site down subconscious recollections of a nightmare?
"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
|
|
|
|
|
I do #2, when I specifically have to work with an object
Comments are my major bugbear: I enforce XML comments on all public methods (and add them to non-public ones) and have "warnings as errors" on, so I have to comment my methods as a bare minimum. The rest of the time, I reserve comments for where they are needed.
6) I hate comments that explain exactly what the code is telling you it is doing! I can read the code, dammit - I don't need you to put
if (customer.IsAnIdiot)
{
7) Out of date comments. This gets my goat. Comments are there to help, when the code is complicated and more explanation is needed. So if you change the damn code, change the damn comments! Or you will hear the sound of a soft cough behind you, and it'll be me, with the ClueBat...
8) Variables names that don't reflect the use and / or purpose. Leaving control names at the VS default for example... ClueBat time!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
OriginalGriff wrote: Leaving control names at the VS default
I do that sometimes, mostly with container controls I don't reference in the code. I often get weird build errors if I set the 'Create a variable' option (or whatever that option is called, no VS instance open right now to check) to false, so I don't usually do that. I have no idea why, and it only happens with certain types of controls (e.g. Panel, Table Layout Panel, etc.)
VS is weird sometimes.
What do you get when you cross a joke with a rhetorical question?
|
|
|
|
|
But if you are only scanning the code you can focus on the green lines instead of running an in-memory compiler
|
|
|
|
|
ctrl-c/ctrl-v
I'd rather be phishing!
|
|
|
|
|
I am currently working on something that has massive presence of #1, 2 and 4. Other than that I totally hate if someone mixes up naming conventions. I have my favorites but I am OK with any convention. Just stick to single bloody way.
Other than that, for some reason, heavily parameterized methods and constructors to bother me. I also totally hate logic and calculations in constructors (unless that is really needed).
|
|
|
|
|
Not sealing classes by default/crazy overuse of inheritance
Just because something needs something else doesn't mean it is a base class of that other thing, I think in a modern programming language you rarely actually need to use inheritance
Also, Code that does nothing, but hasn't been taken out of the project, eugh
I rarely comment my code unless I am doing something weird, I assume the next developer will be at least as smart as me, if not much much smarter (likely)
I might use o as a variable name if I'm maybe inside a for loop inside another for loop (using i for the outer one), everybody should know what for(var i = 0; i < blah; i++) means, anything more descriptive is a waste of keystrokes
Everything else I agree with
|
|
|
|
|
Use of var is justifiable? In my useless opinion, var is useless in .Net framework World.
|
|
|
|
|
I disagree, in a situation like:
CryptographicUnexpectedOperationException exception = new CryptographicUnexpectedOperationException();
I find this more readable:
var exception = new CryptographicUnexpectedOperationException();
Typing CryptographicUnexpectedOperationException twice in such a short space I think is a bit redundant
|
|
|
|
|
Intellisense does help. For reading, indentation is something I would prefer. It is opinion. I think MS wants to divide and rule. When did Britishers took over MS?
*Last 2 sentences are supposed to be humor.
|
|
|
|
|
d@nish wrote: When did Britishers took over MS?
We didn't. If we had, the Color class would be spelled properly!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Wait, that explains it. Those who have trouble typing a "u", can not type IEnumerable< Whatever the hell it is >. I now know the whole purpose of var. Enlightened.
|
|
|
|
|
It's a pity that we can't use a condensed "new" format like:
CryptographicUnexpectedOperationException exception = new ();
which means the same as:
CryptographicUnexpectedOperationException exception = new CryptographicUnexpectedOperationException();
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
var is handy in two places:
1) When using Linq and returning "An IEnumerable of something, gawddammit, but I have no idea what the compiler is going to call it"
2) To identify people whose code you can't trust because they have no idea or no interest in what type a variable should be. It may save five keystrokes to use var instead of IEnumerable<Customer> but it doesn't help understanding when you have to read the code later.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: To identify people whose code you can't trust
|
|
|
|
|
I use var when I have some method to call that returns a humungously long-named type. I then immediately change it with the "Make Explicit" option. That way I don't have to type it out in full or select from a potentially huge list of intellisense suggestions.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Fine by me - it doesn't leave the var in the final code, or treat C# as if it was VB and "don't know, don't care" Dim
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
That var is obviously an int, and you didn't even save any characters there..
|
|
|
|
|
I didn't waste any characters either
|
|
|
|