Couple of months back, I took a session on Being A Pragmatic Programmer. To prepare the content I read through a book by Andrew Hunt and David Thomas called “The Pragmatic Programmer”, but there was this particular section that took my attention – The Pragmatic Paranoia, this section focused on the depressing reality that perfect software does not exists.
The section begins with how we spend a lot of time looking at others code – possibly through code reviews maybe on GitHub or Stack Overflow; we critique about the shortcomings and how code is not living up to the high standards. The term used is defensive to define the approach we programmers use; if we have doubts on the requirements we would go back and validate, we use assertion to detect data and add constraints in the database and validations to the forms, all we are trying to do is improve our software and our source code, generally improving the quality of the overall system – that makes us feel good.
But Pragmatic Programmers take a step further(knowing that no one writes perfect code including themselves), they code against their own mistakes. So one of the defensive measures discussed in this book is Design by Contract(DBC). At the heart of DBC is to document to what is agreed upon and verifying the same. Another one is Dead Programs Tell No Lies; at times we spend a lot of time on a piece of code that we tend to miss what is going wrong, we might also look at wrong places while convincing ourselves that errors cannot happen, whereas pragmatic programmers tell themselves that if there is an error something is seriously wrong.
“Crashing your program is the best thing you can do and do it as early as possible.”
Crash, Don’t Trash
Assertive Programming – another simple way to clarify all our assumptions, and check along the way while we develop.
So yes we will get unsurmountable problems to solve in limited time and we will be critiqued all through the way, but the author says – “lets play safe”.
I believe that’s a good idea.
When everybody actually is out to get you, paranoia is just good thinking.