Quality is the most important aspect of each & every product & business. Everyone tries to achieve it to the maximum possible level by various approaches. If we consider software industry then software testing, training & code reviews are some of the most important approaches for quality management.
Code review plays an important role & is a key approach to get a quality result. Initially when I was a beginner I was thinking why code review is this much important & why we are wasting this much time for reviewing our team members’ code. But immediately after the 1st code review of my professional life I realized that it is the most important part of SDLC & we are not wasting the time for code reviews rather we are investing the time for the same. I have reviewed code dozens of time & every time I review the code of a beginner I come up with a list of common mistakes that I would like to share here.
Most basic principle to complete any task successfully within minimum possible time period is to do sufficient homework & draw an efficient plan for execution. It has been observed that most of the beginners when assigned a new task start execution without completing sufficient paper work. As a result either task fails or deadline for the task is missed. In the worst case, they don’t even know what they are doing. Sometimes they have arrived at a solution but still they consider the correct solution as wrong one and keep working on to find the right one which they never find and at last they realize that they were unnecessarily wasting their time. When we are assigned a new task, we should first understand it carefully & then we should prepare & verify an algorithm. Implementation should be started only after cross verification.
Solution of each problem can mostly be divided into two parts. 1st is desired output & 2nd is its cost effectiveness. Consider an example of travel sales man problem, straight forward method to solve this problem will take hundreds of thousands of year for few cities to find the shortest possible path to travel. So here if we think that we have found a procedure to solve the problem & we do not go further to check its cost effectiveness then we will never arrive at a solution. I have observed in most of the cases once the beginners get the desired output then they mark that task as completed. They do not go further to check its cost effectiveness.
Clearly defined architecture & proper formatting always lead to an efficient, easy to manage & easy to understand solution. At the starting point of any project, if architecture is not clearly defined then it leads to complex solution. Whenever we need to modify the project, we always need more time to find the problem & complete the solution. Sometimes probability of missing the task deadline is higher because of unnecessary complexity which has been introduced due to undefined architecture. The same way proper formatting makes the code more readable & easy to understand. Improper formatting creates unnecessary confusions & compels user to have more time than required to solve a problem in most of the cases.
When beginners are assigned a task & if they have completed the similar task earlier then they just copy previous functionality & make necessary changes. At first look we may think that they have saved time to speed up the development but at the same time they have introduced another problem called code duplication. Writing same code again & again is code duplication. Now if we reconsider the above example then consider here a case in which user copies a code which has some bug. So by copying that code they have also copied a bug. So at each such place software user will face a bug. When that bug is identified, user has to correct the same bug at each place which again requires unnecessary efforts. In general case, instead of copying the whole code they should re-use that code by converting that code into the re-usable element such as function.
X, y, z, a, b, c, I, j, k, etc… are the best examples of the worst names in the programming history. They are worst because they mean nothing. Naming conventions are the most important aspect of the entire software project & play an important role in the project success. For example if a user is reporting an error & informs that he/she is facing some error while adding new record in city page. So if we have proper naming conventions then with the help of just this statement we can immediately assume the name of an object (i.e. CityMaster_Insert) where something is wrong. Here proper naming convention helped us to find the exact location of error with 90% accuracy. Name of programming elements should be meaningful & specify the maximum possible information. It is completely fine to have descriptive names. We should avoid improper use of upper & lower case combination. We should avoid short forms & random names as well.
Solution of an error is the top priority for all the programmers. I would mention one point here. Just a solution of an error is not important. Proper solution of an error is the most important point. Sometimes there are situations where beginners focus only on the error & take actions accordingly which create new errors or bugs at the same time or in near future. Let’s see an example. We are maintaining a customer database in which city is important to us. But now while using the application user faces an error “cannot insert value null into the column CityID in CustomerMaster”. To solve this error assume that programmer simply opened that database table & make the CityID column nullable to allow it to save null values. So here he has corrected the error but this correction now allows user to input customer data without inputting city and customer’s city is important to us. Hence this error correction introduced other bug. It is advisable to focus on the entire situation while correcting the error.
When we buy a new phone, we never forget to check its each & every feature to use it fully. The same way when we start studying new technology, programming language or development tool, we should first study each & every feature to use it fully. That way we can save time to write programs & to find solutions of errors or bugs.
To debug means to identify & to remove errors from a program. Debugging tools are always there like our best friends to help us to find the error in minimum possible time. Generally most of the beginners make little use of debugging tools to solve the errors & bugs. One should use to a maximum level whenever it is useful.
Backup of our work is again an important part of our day to day operation. There is no need to mention if we do not backup & we lose our actual work accidentally then we have to rework it again which can be very costly in every aspect. Now a days, many automatic backup tools & version control systems are available at free of cost. We can make effective use of them & can have a backup of each & every bit of our work at any specific time.