When accomplishing tasks, especially tasks that are tedious and boring; we tend to do whatever we can to get it done. While that sounds great from a management point of view, one must also realize we are merely rushing the job and the results may be sloppy. We should always aim to produce effort that will not have to be reproduced again. In other words, do the job in a way that you won’t have to do it again.
Examples pop up all the time in software development. One must recognize when and where they can innovate and simplify their code to produce the best result. See the code below:
Both blocks of code achieve the same purpose — to strip out the HTML tags from an email to store a small preview of the content sent in the database. Which solution is more futureproof? Recursive calls have limitations in SQL databases in respect to the number of times it can call itself (a security measure to prevent infinite loops). Loops have no limitations, and thus is the better solution. The result from using the second block of code is that the developer can now freely define how many characters they wish to save to database for the content preview, without being restricted by recursive function limitation.
Additionally, a great developer analyzes the use cases of the user and brainstorms additional ways the software could potentially be used so that all the bases are covered. Of course, one can never account for all the scenarios an end user may use their software, but one must stay proactive and constantly question: Is this the best I can do? How can this be improved?
One must strive for constant improvement. It is the only way we learn. I have summarized 6 key points to follow to build great systems. Consider these best practices.
1. Don’t be complacent on one solution; be relentless;
2. Usually the better idea pops up during implementation and testing;
3. Think out of the box; there are many ways to solve a problem; the best solution usually is not the most obvious;
4. Write defensive and unbreakable code all the time; Build systems that can stand an elbow test;
5. Do not fight limitation, embrace it;
6. Do whatever to gain peace of mind; low maintenance is a function of worry-free programs;
A good analogy here would be: You go outside during a snowstorm. A few days later, you come down with a horrible cold. How can you make yourself feel better? What is the best way to get over a cold? Sure, you can take cold medicine and drink warm soup to recover, but wouldn’t the best solution be to bundle up and dress warmer before heading out, so you don’t get a cold in the first place?
A similar analogy can be made for keeping your house clean and clear of clutter. The easiest way to keep things tidy is not have a massive cleanup every month or so — it’s to make habits that cause the least mess and to clean regularly.
Be preventive, not reactive. Don’t wait for a bug to pop up to fix the code, build code that can handle all use cases!
Originally published on February 14, 2017 on blog.rintagi.com