Bad Coding Practices

Here are some bad coding practices that are generally followed and needs to be checked and controlled to ensure a quality deliverable.

1) Ctrl+C / Ctrl+V of code without even understanding what the code does. This often results in problems as some more modifications might be needed post Ctrl+V.

2) Failing to do unit testing of the code. Delivering a code without testing. Sometimes, the defects just go unnoticed till production and come up as critical ones later. "If only I have tested it atleast once"..

3) Writing series of SQLs when the value(s) can be fetched in a single SQL. This is however language specific. For example

a) select F1 from T1
b) select F2 from T1
....................
..................
c) Select F3 from T1

Better to code like Select F1,F2,F3 from T1 -> right?...Minimises the number of database calls.

4) Writing a for loop and assiging a static value to a variable inside the loop. Boss, can't you declare that static variable outside the loop?

5) Pass NULL or BLANK values to bind variables in a SQL. Can't you filter it before running the SQL? This will prevent your DBA from screaming..

6) Failing to handle exceptions in code..It is always good to have an exception block..It helps..

7) Failing to write comments..Do you think you will be working in the same code forever...? Write clear comments. That is the best sign for a developer.

8) Writing obfuscated code. Do that in any code obfuscation contest..Not here.

9) Doing comparision of Boolean variable to '=TRUE' or '=FALSE'. Again this is language specific; If looks better right..

10) Writing SQLs without using Bind Variables. Use Bind Variables. It really helps in improving the performance.

No comments:

Post a Comment