This article is a response to 7 Warning Signs that you’re a Bad Programmer. It provided time tested solutions to the warning that were discussed in the above article. Success is not a product of chance. It is the sum result of all the choices that you will make. The eye-opening tips will transform you into a happy programmer : )
Tip # 1: Make you plan before you start coding.
You can never be too prepared. In this stage, you want to make sure that you understand all the requirements of the users. You also need to ensure that you understand or anticipate future requirements. Come up with a plan that solves the present and can accommodate future requirements with ease. Read this article How to Plan a Coding Project for more details
Tip # 2: Use Version Control Software
“The Only Thing That Is Constant Is Change -”. ― Heraclitus. Bugs are always fixed in software, new features are added and old ones removed. New versions are developed and old code needs to be maintained too. Never say the cat ate my code 1 year down the line after you shipped version one of the killer ERP software and the client wants new features. Read these free tutorial series on Software Version Control with Git for more details
Tip # 3: Use descriptive names for variables and functions
Avoid using abbreviates especially weird ones such as x or y as a variable name that holds data used for computations in a tax program. Make your variables and method names part of the documentation. A descriptive name will tell you what the variable is and what the method is supposed to do.
Tip # 4: Don’t repeat yourself. Write once use many times
Oh yes, the DRY principle. Don’t repeat yourself. Let’s say you have a project that display data to the user in different windows. The displayed data needs to be formatted in a certain way. Instead of copying and pasting the code formatting the data in all the windows, you can create a function that you can call from all those windows that need to format data. This way, you write the function once and use it many times.
Tip # 5: Comment your code
The best kind of comments are the ones you don’t need. Comments should tell you why and not how. There is little value in commenting //this method connects to the database when the method name already says connectToDB. For more details, read this article Code tells you how, comments tell you why?
Tip # 6: Share your knowledge with others
Almost always, there is someone who knows more than you do. Sharing your solution does not only help others. It gives you an opportunity for a review and if someone sees a weakness in your implementation, they will highlight that. If this doesn’t make you better than I don’t know what does.
Tip # 7: Work on a single project at a time
Focusing on a single project at a time has been proven to be more productive than working on multiple projects. Let’s assume you take 10 seconds to finish tasks A and B. let’s say you spend a second on each project then switch to the other. The time it takes you to complete both projects when multi-tasking will be roughly 30 seconds. The other 9 is for switching between projects. If you concentrate on a single project and finish it before you move to the next one then you spent 21 seconds. Read this article by Joel Spolsky Human Task Switches Considered Harmful for more details