Head over to this post to remind yourself what is error free software and why we need it. With that taken care of let us get straight to the five tips that can help us produce error free code.
Tips for error free software
Simple logic is the best logic
Creating simple solutions starts before you even pick up the laptop. Be concise in your mind about what the problem is. Then proceed to think clearly about what you want to do to solve the problem.
- How are you going to solve this problem?
- This there another way to do what you are trying to do.
Think through the available options. It is best to pick the first simple, and the one that is easiest to implement.
Does that logic present risks in the future? If no, then that is a great solution. Simple logic is the best logic. It is harder to think of easy solution as compared to the more complex ones.
Yes, I know you want everyone to know that you are a shata in your field. Sometimes you want to demonstrate this by the complexity of the solutions you present. However you can still do this and not have your logic all over the place. You will confuse others and more importantly yourself.
The best solutions are the ones both you and your team understand. And of course, make sure it solves the problem at hand.
In God we trust, the rest we test
It is true the software was always needed yesterday, however if you start the habit of placing tests inside your code then you would be starting a good habit.
Starting with testing follows the principles of Test-Driven Development (TDD). Tests can help you check if the software has not been broken since your last changes (or commits).
I would recommend testing with selenium as well as writing unit tests. It is true that it may take time, however that would be time well spent.
Do CI and CD
No CI and CD are not Confidential Information and Compact Disk respectively
CI and CD refers to Continuous Integration and Continuous Delivery, respectively.
As the word integration implies Continuous Integration is all about bringing the work of developers together into a single piece. On the other hand, Continuous Delivery makes it possible to deliver software consistently over shorter time spans.
There are a lot of tools that can assist you. You can start with Jenkins, (after you have already started version control of course ). I would also recommend Gitlab which helps with the CI and CD process and comprehension.
Monitor app performance
It is embarassing to be told by someone else that your website is returning error 500 and 400
Keep a log of how your apps are performing.
It looks bad for someone to send you an email saying your app is not working. It is better you know first-hand about it before the customer experiences that frustration. However, do you know what is even better? It is if the error does not happen at all.
If such errors do not happen then let us keep a tab on how the app performs as well as other metrics throughout the day. Get to know what the peak periods and vice-versa.
Once you start collecting all this information you will be able to improve the overall performance of your software.
Have a coding convention
It is better to have some rules rather than having no rules at all
Different languages, and frameworks push for coding in a certain manner. Teams advocate for this in order to move the team forward and have them speaking the same language ( figuratively ) whatever the contexts.
For example, classes should be written in camel case, whilst variable are written as snake case. It is helpful for team to have the same or at least similar conventions in order to make their work as well as the work of the next developer that much smoother.
Another good reason to have conventions is when you work in a team. It makes the code handoff between different developers easier especially when one of the team members leaves the team.
Wash your hands
Thats it folks!
As you can see these tips are easily to implement. You do not need to do all of them at once. Rather, approach them one at a time. I have full confidence that you will make consistent progress in your developer journey.
Finally, a reminder that we are still not in normal times, hence please remember to wash your hands.
Cheers and bye!