Our training paths
Grow your skills
You’ll get our FREE Video Series & special offers on upcoming training events along with notifications on our latest blog posts.
Valid email required.
Submit failed. Try again or message us directly at email@example.com.
Check your email for confirmation.
Updated on February 10th, 2017
This post is part of a series of posts designed to make you think about your own design philosophy on different topics. If you haven’t read this post yet, please do so first:
Develop Your Design Philosophy
I want to share with you my design philosophy around the word Integrity and what it means to me from a Go perspective. Integrity is much more than just a buzzword, it is a driving principle in everything I do, both in code and in life.
This is my definition of the word integrity:
The accuracy and consistency of the code performing every read, write and the execution of every instruction. Just as important, writing less code and knowing the error handling code is the main code.
If you step back for a second and think about what the code you write actually does, it can be broken down into micro and macro level operations. Think about it, each line of code you write is either allocating, reading or writing memory (micro). Variables and statements are a driving force behind these operations. The larger amount of code you write performs data transformations (macro). We have an input and we produce an output. Our functions are a driving force behind these operations.
With this in mind there are two driving forces behind integrity.
Integrity is about every allocation, read and write of memory being accurate, consistent and efficient. The type system is critical to making sure we have this micro level of integrity.
Integrity is about every data transformation being accurate, consistent and efficient. Writing less code and error handling is critical to making sure we have this macro level of integrity.
Integrity is critical for writing software that is both resilient and reliable.
If we are to become serious about reliability , we must become serious about integrity and therefore error handling. There was a case study that looked at a couple hundred bugs in Cassandra, HBase, HDFS, MapReduce, and Redis . In the study 48 critical failures were found and this was the breakdown:
The results may be surprising to you. 92% of the critical failures that occurred could have been avoided if the developers made integrity their first priority. Error handling was mishandled in several different ways. In some cases because of how exceptions were handled and in others because of developer carelessness.
Exception handling lends itself to making mistakes. It doesn’t force you to think about error handling as part of the main code but as it is titled, an exception. Something to be dealt with later, somewhere else in the code. This disconnect creates lots of issues as the postmortem discovered.
I hear all the time that error handling in Go is tedious and inconvenient but that’s the point. This is Go pushing you towards the one thing you must never ignore, integrity. We all know that for security to be effective it requires this same tedious and inconvenient nature. I don’t see error handling in Go to be any different. Integrity and security go hand in hand.
The study also revealed an interesting trait among developers, carelessness. I believe developers operate in a matrix of carelessness vs ignorance vs intent. Anytime we discover an integrity issue we must ask ourselves how and why it happened.
I like using this matrix when trying to understand developer behavior around integrity. It is a different twist on Martin Fowler’s matrix on technical debt . When an integrity issue is discovered it either comes from a place of ignorance or carelessness.
| | |
| | |
Ignorance | Learning / Prototyping | Hacking / Guessing |
| | |
| | |
| | |
| | |
Carelessness | Education | Dangerous Situation |
| | |
| | |
Integrity issues that come from a place of ignorance either occur when we are prototyping/learning (non-deliberate) or when we are hacking our way through a solution without considering the consequences (deliberate). I am usually ok when ignorance is at play but I want to eliminate as much of the hacking and guessing as possible.
Integrity issues that come from a place of carelessness create dangerous situations. The idea that a developer would knowingly introduce and deploy code with integrity issues is beyond me. That being said, there may be critical situations where it is acceptable for very short periods of time. Non-Deliberate carelessness requires an immediate action towards education. We must eliminate carelessness from everything we do.
There have been studies that have researched the number of bugs you can expect to have in your software. The industry average is around 15 to 50 bugs per 1000 lines of code . One simple way to reduce the number of bugs, and increase the integrity of your software, is to write less code.
Bjarne Stroustrup stated that writing more code than you need results in Ugly, Large and Slow code :
I want to conclude with my definition of integrity again:
I feel strongly that integrity must be your highest priority for everything you do and every decision you make. This means writing less code and making error handling part of your main code and not something to be dealt with as an exception. The way errors are handled in Go is proof that the language has an uncompromising attitude towards integrity and that error handling is inseparable to that cause.
If you are new to Go, it might help to read these posts about error handling mechanics.
Error Handling In Go Part IError Handling In Go Part IIError Training Material
 Software for infrastructure - Bjarne Stroustrup Lessons learned from reading postmortems - danluu.com Technical Debt Quadrant - Martin Fowler Ratio of bugs per line of code - Dan Mayer Masterminds of Programming - Federico Biancuzzi and Shane Warden
We have taught Go to thousands of developers all around the world since 2014. There is no other company that has been doing it longer and our material has proven to help jump start developers 6 to 12 months ahead of their knowledge of Go. We know what knowledge developers need in order to be productive and efficient when writing software in Go.
Our classes are perfect for both experienced and beginning engineers. We start every class from the beginning and get very detailed about the internals, mechanics, specification, guidelines, best practices and design philosophies. We cover a lot about "if performance matters" with a focus on mechanical sympathy, data oriented design, decoupling and writing production software.
Interested in Ultimate Go Corporate Training and special pricing?
Our courses have been designed from training over 30,000 engineers since 2013, and they go beyond just being a language course. Our goal is to challenge every student to think about what they are doing and why.
Please fill out the form below, and we'll get back to you soon.
Check your email for confirmation of your sent message. We'll get back to you shortly.
Ardan Labs Copyrights © 2022