Build-time Biased Python

A design philosophy for rapid iteration with fewer errors.

Brian Yarbrough
The Pythoneers

--

Photo by Tyler B on Unsplash

This post presents a simple design philosophy for rapid Python development of code that’s more maintainable and has fewer bugs, as well as a case-study of how to implement a few open-source tools (black, pre-commit, flake8, mypy) to enforce that philosophy.

The Acorn of Design Philosophy

Our “acorn” of design philosophy that can grown into a larger set of standards is this: Prefer build-time errors to run-time errors.

That’s it.

A run-time error occurs during program execution: after software has been released. A run-time error can cause a catastrophic crash. Or it may cause an insidious error that’s excruciating to pin down and fix.

Run-time errors are devastating because they occur exactly when the customer most needs success. Examples include:

  • Divide by zero
  • Incorrect type
  • Index out of bounds
  • Undefined variables

In contrast, a build-time error occurs before software is released. In fact, the presence of a build-time error should prevent software from being released until the error has been resolved. The customer never encounters…

--

--

No responses yet