What are Overused or abused programming techniques?
1.Comments in Code:
I just wish the University Professors would understand they don’t need to teach their students to write 10 lines of comments saying the following code is a for loop, iterating from 1 to a number of x. I can see that in the code!
Teach them to write self-documenting code first then appropriate commenting on what cannot be adequately self-documenting second. The software world would be a better place.
Teaching them to replace comments with the code would be a good start.
I shudder when I see a try catch that does nothing and is designed to handle dumb logic. In general try catches are overused, however in some cases are very useful.
2. The singleton design pattern:
Sure, it’s a useful pattern but every time a new programmer learns about this pattern he starts trying to apply it to every single class he creates.
3. try catch Block:
The evilest thing to protect dumb programming. putting everything in a try catch and doing nothing with the catch
try { int total = 1; int avg = 0; var answer = total/avg; } catch (Exception) { }
4.
- Using the compiler as a debugger.
- Ignoring compiler warnings or turning them off completely.
- Global variables.
5. Factory pattern
The Factory pattern is the most overused and abused design pattern.
I have come across numerous cases where a Factory class is coded when a simple constructor would be adequate.