The Coding Flow

Code Clean Or Die Tryin'

Details Matter!

Details

Change Log

Commit: 448fc310
improve reporting
31 changed files

versus

Commit: 1ef7a40c
extract median calculation into a separate function
1 changed file

Commit: 8125e973
provide total downtime as deparate data point
2 changed file

...

Downtime

func (d *DataCollector) addDowntime(
	downtime time.Duration) {

	d.totalDowntime += downtime
}

versus

func (d *DataCollector) addDowntime(dt time.Duration) {
	d.totalDowntime += dt	
}

versus

func (d *DataCollector) addDowntime(downTime time.Duration) {
	d.totalDowntime += downTime
}

versus

func (d *DataCollector) addDowntime(downtime time.Duration) {
	d.totalDowntime += downtime
	
}

versus

func (d *DataCollector) addDowntime(downtime time.Duration) {
	d.totalDowntime += downtime
}

Do Details Matter?

Do you see it? In both examples, all the alternatives do exactly the same, but their form has subtile differences. Do those details matter?

Decisions

There is this phenomenon called “decision fatigue”, which refers to the mental exhaustion caused by making numerous choices, leading to a decline in decision quality and willpower. As choices accumulate throughout the day, the ability to make sound judgments diminishes. This phenomenon affects various aspects of life, from selecting mundane tasks to complex decisions, impacting productivity and clarity of thought. Decision fatigue often results in opting for easier or default choices, avoidance, or procrastination. Strategies like simplifying choices, prioritizing, and taking breaks help mitigate its effects, allowing for better decision-making and preserving mental energy for more critical matters.

Writing code is all about making decisions. Spending a lot of valuable decisions on small details means there are less high quality decisions left for the important questions. The big picture is suffering from the striving for an sustainably understandable code base.

So should you really afford so many detailed decisions? Shouldn’t you concentrate your budget on the real important big decisions instead?

Symmetry and Consistency

Details are the essence of symmetry and consistency. Every deviation from symmetry or consistency raises questions with the viewer: What is the reason behind this deviation? Is it on purpose or by accident?

To present a piece of code in an easy-to-understand manner, the reader’s focus must be drawn to the important things. The special must stand out, the ordinary step back. This only works if the reader can trust in symmetry and consistency, and can rely on every deviation being on purpose, to point out an important fact.

With every accidental deviation, the reader looses trust, the understanding becomes harder and costs more energy. Hence, each and every detail counts. Details make code understandable. Details do matter.

Conclusion

Now what? Either we have a feature-packed product that no one can understand and maintain, or we never get anything to the customer because we die in the beauty of all your ingenious details? Is this our fate?

Well, not all is lost. There is a solution to this dilemma: rules, coding guidelines, best practices -however you want to call it.

Reduce the number of detail decisions to improve the quality of the big picture. Make detail decisions once, sound, and based on experience, and reuse them in the future. With increasing experience, grow an assorted set of rules over time and adhere to it. Build trust to the rule set. This frees more and more of the high quality decisions for the important questions.

Resources