Bogdi

Writing code the fastest way

Published on

Photo by Shen Liu on Unsplash

You're happily driving your Toyota on the highway while a yellow light appears on the screen of the board computer. Now you have to pull over at the next service shop to get your car fixed. Fortunately, there is a Toyota service nearby.

Arriving at the service, a mechanic quickly checks the problem and tells you that a pipe is punctured, but he can fix your car immediately. He has a new exact same pipe in his inventory. This is a win-win for both the client and the service - you'll get your car back sooner, and the dealership will have a new happy customer while also not running the risk of you taking the car somewhere else for repair.

In traditional mass production, the way to avoid stockouts would be to keep a large inventory of spares just in case. The more inventory you keep, the greater the likelihood you will have the right product in stock for every customer. A large stock might create more happy customers, but it also has its drawbacks: high maintenance cost, the need for a large physical deposit, and managing the stock, which is time-consuming.

Just-in-time production

Toyota came with a solution for this issue. When a service shop would sell a spare part, a "hole" would be created in its inventory which would automatically cause a signal to be sent to a local restocking facility called "Toyota Parts Distribution Center" (PDC). The PDC sends a new pipe to the dealer, which in turn creates another hole. This sends a similar signal to a regional warehouse called the "Toyota Parts Redistribution Center" (PRC), where all part suppliers ship their products. That warehouse signals the factory where the pipes are made to produce one more pipe, manufactured and shipped to the PRC.

The goal is to achieve small batches all the way down to a single-piece flow along the entire supply chain. Each step in the line pulls the parts it needs from the previous step. This is the famous Toyota just-in-time production method.

When companies switch to this kind of production, their warehouses immediately shrink as the amount of just-in-case inventory (called work-in-progress, or WIP, inventory) is reduced dramatically.

Lean methodology in software craftsmanship

The same concept can be applied to the software manufacturing process. Each piece of code that is being written without being deployed into production is in the WIP area. The features in development should be pulled by client demand. In the case of startups, these client demands are initially modeled by a business plan which at the beginning is just a hypothesis that needs validation.

This is where Continuous Integration/Continuous Deployment (CI/CD) comes into play. CI/CD is a process and methodology designed to make sure that all the code you merge into main is deployable at any time. Testing and deploying are done automatically after each commit such that the WIP area is as small as possible. This is the fastest way to gain validation for your starting hypothesis.

It might be surprising, but CD is the easiest way to write, ship, and run code in production. This is the counterintuitive truth: making lots of little changes swiftly is infinitely easier than making a few bulking changes slowly.

PS: This neat pipeline designed by Toyota is part of a bigger concept known as Lean Manufacturing. "Lean" because its supply chain looks like it is on a diet. Find more about it in "Lean Startup" by Eric Ries