For much of the world, 2020 was a year unlike any other. We were forced to stay at home for months and work remotely. We wore face masks in stores and other venues where we’d have contact with others. Restaurants were forced to have limited capacity or just do carry-out orders. It felt out of our control and we had to make sure we could handle the changes.
In an interesting coincidence, my youngest son’s school district began handing out Chromebooks to nearly every student a couple years ago. That effort was simply to use technology to enhance the students’ learning experience. But a couple years later it proved to be a proactive step that would show benefits no one expected.
What’s more, some of the precautions we’re taking to prevent the spread of COVID-19 in our communities remind me of the techniques programmers employ to prevent the spread of bugs in our code.
Expect the unexpected
As programmers, it’s far too easy to focus on getting the positive cases of a requirement working. Let’s face it, much of the time it can be brand new code or making changes to code you may not be familiar with. It’s easy to say “it works” based on the happy path and call it a day.
Just as COVID-19 turned us upside down virtually overnight, it’s important to focus on the negative test cases when we do unit testing and to expect the unexpected by thinking about things like:
- What happens if you get a drastically different response from an API call than you’re expecting on a happy path call?
- What if you’re expecting a deep JSON object with many attributes with their own properties and get only a couple, or none at all?
- What happens if you get absolutely no response and it’s up to your own code’s timeout settings to prevent unnecessarily long delays to the user?
These are all situations to take into account in your testing and make sure that even under bad conditions, your code works well and handles whatever is thrown at it.
Follow the rules
COVID-19 has forced just about all of us to wear face masks when we go out into the world. Despite the fact that it’s easy, and a good precautionary measure, there are still people who don’t think it’s necessary. Maybe they think masks don’t make sense, or that the virus is a hoax, or that they’re not effective—so why wear them?
Coding standards are kind of the same thing. They’re an effective technique to improve code quality and make it easier for other developers to be comfortable with code they’ve never seen before. Standards also help junior developers in terms of what kind of loops can be more effective than others (along with other “best practices”). Even if you’re not exactly sure why it’s better to do so, programmers follow the standards because they assume they exist for a reason.
Sometimes even good developers may feel rushed to get something done in a tight deadline and following standards might suffer as a result. This can lead to code that doesn’t run as efficiently as it should and can make it harder for other developers to understand what it’s doing.
Even though (as with wearing face masks) we might feel like we don’t have time for it, or that it’s not going to help, we should follow the rules and coding standards.
Don’t believe the hype
COVID-19 put us all in a situation nobody wanted. We all want to get back to our normal way of life, interacting with others the way we used to, and getting back to our routine. The pandemic made us more desperate to find a solution, so in our mild panic we may be more susceptible to believe things that don’t actually make a lot of sense.
Things like drinking this or that to kill the virus, going out to develop “herd immunity,” wondering if we should all get vaccinated—or would that just make things worse? With answers coming inexplicably from both sides, it was hard to know who or what to believe.
As developers, we’re always looking for frameworks or tools to make our lives easier and our code better and more efficient. That’s a good thing. But most times when we’re searching for those things, we’re under project timelines or just need something to get us past whatever coding issue we have.
The same precautions apply. Nobody is going to admit their framework is bad, or hard to use, but sometimes that’s the case. Worse yet, without the proper due diligence up front, we only find out about the repercussions after we’ve implemented them, and then there’s no time to start over. We just have to live with the ill effects.
As architects and developers, we always need to vet out tools and frameworks before we commit to them. Using open-source code from “some guy,” and other things we aren’t very familiar with, can have serious consequences that we simply can’t un-do.
Even when we go out (wearing our masks), we are still asked to “socially distance” from each other. Proper separation reduces transmission of the virus and helps prevent the spread of COVID-19.
Nicely formatted code isn’t just “icing on the cake.” It has real impact on a developer’s productivity. Whether it’s tabs vs. spaces (classic Silicon Valley episode), formatting standards for function syntax, or the ordering of CSS properties, it all helps. Having to work on code that is very poorly formatted can actually have a big impact on how long it takes to make changes to that code.
Following the same “code distancing” rules enables developers to jump into unfamiliar code and understand the logic more quickly. This accelerates bug fixes or enhancements and reduces the odds of introducing new bugs due to making changes without fully understanding the code base.
Clean and disinfect
To reduce the spread of COVID-19, sanitizing is a big part of prevention. One store I shop at often would disinfect the checkout lanes, including the conveyor belts, between each customer. This helps prevent the buildup of germs and decreases the likelihood of transmitting germs to another customer down the line.
Keeping your code clean and reducing technical debt at all times is the same idea. Every time you work on a unit of code, you should try to keep it as clean as possible to prevent the spread of bugs. This helps keep the overall project in a better state and reduces bugs due to taking shortcuts or introducing other types of technical debt.
So, before you open up PR’s on changes, be sure you’ve looked for bugs and have “cleaned and disinfected” the code of any exiting technical debt to prevent its spread in the future.
We’re all happy to see the end of 2020 and the promise of a vaccine in 2021. COVID-19 will still be with us, but better days are on the horizon. When you’re ready to start your next software project, or want to “disinfect” a previous project, be sure to give Anexinet a call. We’ll help ensure the success of your project, and the cleanliness of your code.