Trusted by leading businesses worldwide
Jul 31, 2020
Imagine yourself as a chess player instead of a Software Developer.
How would the development of your pieces adjust to the competitor’s challenges? Are you going to become extremely defensive, or will you allow yourself calculated risks and planned sacrifices by having the end game all the time in your mind.
I would like to talk about my own evolution on the intention behind opening variations and how I managed to gain confidence in my codebase through some techniques.
First I started incorporating the Defensive programming technique, this style is dating from the early days of C and its aspiration is to:
However, my issue with defensive programming is that in practice is taken past what is described to a very sad and ugly place. I found that important things about my codebase suffer because of this:
When looking at defensive code, it’s hard to grasp the intention: was it added for safety or is there a valid reason x can be null? Is it expected behavior, or is it an unhandled error?
My opinion is that this technique is designed to deal with User input or External interfaces, and it should not progress beyond that scope.
Not being careful and not having the discipline of using the technique can be the cause of Paranoid Programming. This approach can be contagious, spreading like a wildfire in the codebase. And I don’t want to have any part of that again.
So how do we keep our sanity and can we take control of the board and strip our code of paranoia? I found that the answer to these questions was:
Recognize and use tools from your preferred language to help you. It should be the main carrier when adopting this technique.
Quick shout-out to Kotlin, this language provides some gems that can be used to enforce offensiveness. Their intentions behind Null safety at compile-time, Capturing assumptions with require, check and assert, Aggressive or smart TODOs and many other concepts let you crash your program in the most fantastic ways.
Offensive programming goes hand in hand with the Agile methodology on a higher level. At our company, we like to follow these words.
Recognized as one of our core strengths to deliver good code fast and to iterate fast on our changes. The more frequent deploys, the more information is being gathered, don’t be afraid to crash and detect failures at an early stage.
Are you tired of being paranoid and overprotective about your codebase? Do you want to be in a company where crashes are encouraged and met with understanding? Check out our current job openings.
Tanja Zlatanovska
Trusted by leading businesses worldwide
Velimir Graorkoski
Velimir Graorkoski
Tanja Zlatanovska