The art of coding disasters and failures: May the force of FAILURE be with you!
Accidents happen. Sometimes we make mistakes, and that’s perfectly okay. We spoke with IBM Developer Advocate Fernando Cejas about the power of failing, how to pick yourself back up again, and the transformation from failing to learning.
JAXenter: All (or most) software developers have their “battle scars” and “war stories”. What coding disasters have you encountered?
Fernando Cejas: That is a good one and I give myself a lot of credit for the disasters/mistakes I have made as a professional after almost 20 years working in this industry. The first one which comes to my mind, was one about 10 years ago when writing an application for a bank. I added a comment to the code:
“Please first call me before modifying this function”.
The reason? Not even I was able to understand the piece of code that I had written! Especially when we have complexity, we need to be very careful and try to come up with readable code that is easy to understand because most of us (as software engineers) spend more time reading/understanding source code than writing it.
Code is communication between people.
JAXenter: How did you solve them? What lessons did you learn?
Fernando Cejas: As professionals, the first thing we need to do it to recognize what we are doing wrong. In this specific case, no one would be able to maintain that part of the system, which put us in a situation where if something critical happens, we would not be able to solve it right away. The solution to this kind of problems is easy in theory (in practice many people do not do it, that is why it is something that I try to empower professionals to do): collect feedback, communicate, and do not isolate yourself. Learn from experienced people, have a mentor or as I like to call it: a Hero. And always keep in mind that code is communication between people.
JAXenter: Is failure always bad or is it helpful in the long-term? Has failure become more acceptable to discuss within the software industry?
Fernando Cejas: I say that a person who has never made a mistake (which by the way, might not exist) is someone who never tried anything new.
Learning from your mistakes is key to improving. Of course we have to minimize mistakes as much as we can in order to avoid disasters but unfortunately they happen: we are human beings and we make mistakes. Failures should always be looked at in a positive way: a lesson learned that should not happen anymore.
In a previous job, I made my company lose a few thousand Euros. Of course, we learned from the situation, and the best part? There was no finger-pointing, no one blamed me, we acted as a team, as a unit, solved the problem and made sure that it would not happen again.
JAXenter: How important is it to conduct actionable postmortems? Can they foster learning and improve future outcomes?
Fernando Cejas: Postmortems and retrospectives must be a very important part of any software development cycle, for the simple fact you can share the experienced situation and discuss the whys of the failure in order to improve in future similar situations.
JAXenter: What happens when the plan fails? How can you deal with the unknown in software delivery?
Fernando Cejas: Happy cases exist, but we cannot assume everything is going to always run smoothly. Betting on newer technologies, improving our code and delivery processes have risks: the risk of failure, this unknown you mentioned in the question.
How can we deal with it? We must always follow the best practices and principles of software engineering. Just to mention a few: Follow SOLID Principles if you are doing Object Oriented Programming (there are equivalents if you come from a more Functional Programming approach), detect anti-patterns, use patterns, communicate and work as a team, etc.
There are other things in the process of software development which can help when writing and delivering high-quality applications: Continuous Integration (automate as much as you can), Pair Programming, TDD (Test Drive Development). But two of the most important ones: Write tests and refactor your code. Continuous improvement (check the Boy Scout Rule) is so important to keep your codebase clean and healthy.
JAXenter: How can software developers learn to write/develop better software?
Fernando Cejas: This was pretty much answered in the previous question but I can add: share your experiences, good and bad ones. We, as professionals, deal with the same problems and having different opinions gives us the ability to be more flexible, have more tools in our toolbox for problem-solving.
Also, let me finish up with a phrase I like to repeat: May the force of FAILURE be with you!