What are the worst programming habits?
-
In order of how I have them listed below: 0) Use of VB. 1) Use of Convert and/or ToString rather than casting and/or Parsing. 2) Over-use of Reflection. Not caching and reusing information retrieved via Reflection. 3) Over-reliance on tools, especially third-party tools. 4) Monolithic classes, lack of modularity, non-single-responsibility. 5) Singletons. X| 6) Convoluted concatenation -- a String.Format will be clearer. 6.1) Concatenated SQL statements, when a parameterized statement is better on so many levels. 7) Not leveraging interfaces. 8) Not allowing polymorphism for no apparent reason. 9) Swallowing Exceptions. 10) Posting snippets of code that use uncommon, custon, or third-party classes and expecting everyone to know what they are.
You'll never get very far if all you do is follow instructions.
-
I was thinking about the things that bug me and came up with a short list
- No comments. I know - let's have a religious war etc, but I find no comments dangerous.
- using o as a variable name. In fact using anything that's not sensible.
ctx
,dr_rfp_ptr
,i2
- Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
- Mystery side-effects in code.
- Magic numbers
I'm guilty of 2 of these on occasion. What's your list?
cheers Chris Maunder
ctx - it is assumed that it should point to some context structure, it is(should; may) not variable in usual sense but rather - the function parameter so it may be "pure functional".
-
I was thinking about the things that bug me and came up with a short list
- No comments. I know - let's have a religious war etc, but I find no comments dangerous.
- using o as a variable name. In fact using anything that's not sensible.
ctx
,dr_rfp_ptr
,i2
- Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
- Mystery side-effects in code.
- Magic numbers
I'm guilty of 2 of these on occasion. What's your list?
cheers Chris Maunder
I have nothing to say against use of comments. They may not be necessary for some, but usually do no harm to anyone. I believe programmers are free to choose any name for a variable so long as they communicate well to people you work with. Using "o" is fine. If it's a problem, change your font. Bad formatting used to a bad practice, but nowadays, we have apps and services to make them neat.
-
How about the SingleOrDefault on the same machine?
Wrong is evil and must be defeated. - Jeff Ello[^]
-
I'm not sure what you mean - the timings were all on the same machine.
PooperPig - Coming Soon
I was just curious on the performance of SingleOrDefault vs FirstOrDefault as per Petes suggestion.
Wrong is evil and must be defeated. - Jeff Ello[^]
-
I was just curious on the performance of SingleOrDefault vs FirstOrDefault as per Petes suggestion.
Wrong is evil and must be defeated. - Jeff Ello[^]
Oh - I see. I didn't do that - the figures were from a test I did some time ago when someone kept going through our code base changing all the .where(predicate).something() to .something(predicate) because they said it was more efficient - which I didn't think was the case.
PooperPig - Coming Soon
-
6. Leaving commented-out code hanging around too long I'm guilty of that one quite often.
The difficult we do right away... ...the impossible takes slightly longer.
-
I was thinking about the things that bug me and came up with a short list
- No comments. I know - let's have a religious war etc, but I find no comments dangerous.
- using o as a variable name. In fact using anything that's not sensible.
ctx
,dr_rfp_ptr
,i2
- Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
- Mystery side-effects in code.
- Magic numbers
I'm guilty of 2 of these on occasion. What's your list?
cheers Chris Maunder
Thanks for this week's survey - it's great! :thumbsup: /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
6. Leaving commented-out code hanging around too long I'm guilty of that one quite often.
The difficult we do right away... ...the impossible takes slightly longer.
Too long? I want to kill you if you don't delete old code. That's why we have (I have, but it's hard to convince people to use) version control. There should be 0 old code commented. One time I just deleted all comments that where not proper "human" language, except for code examples, because they're the only exception to having code in comments.
-
Too long? I want to kill you if you don't delete old code. That's why we have (I have, but it's hard to convince people to use) version control. There should be 0 old code commented. One time I just deleted all comments that where not proper "human" language, except for code examples, because they're the only exception to having code in comments.
Luiz Felipe Stangarlin wrote:
I want to kill you if you don't delete old code.
Maybe you should cut down on the caffeine? ;P
The difficult we do right away... ...the impossible takes slightly longer.