Saturday, July 9, 2011

Lean 101

Lean is a philosophy derived from manufacturing (see for more details) that has made inroads into many things, including software development. When people try to adopt it they tend to focus on the techniques and often miss the big picture. When faced with a task, how you think about it will determine how you attempt to perform it.

Take laundry for example. The most common method is to first sort all the dirty laundry into piles of like colors. Then wash them one at a time and as they wash throw them in the drier. As the dry hang and fold and/or make piles for each person to take care of their own. This divide and conquer approach is usually tool #1 in our tool-belt.

A lean approach would start at a different place. Lean would start on value. Why do we do laundry? What's the end goal? For me it is clean clothes in my closet. If I could have elves do it for me while I slept I would be satisfied. Since I can't seem to find any nocturnal elves willing to work for free I am stuck doing it. I start with four laundry baskets (and some floors) filled with dirty clothes and I need a process for getting these clothes cleaned and put in the appropriate drawers and/or closets. The clothes need to be cleaned in the washing machine, dried (or laid out for those pesky clothes) and folded/hung in the correct location.

Lean tells us to pull value, instead of pushing it. What does that mean? Pushing can be thought of as focusing on the sub task. Let's take the first sub task when doing laundry - sorting. Pushing is doing all the sorting before starting a single load. You make sorting the goal before you move to the next task. This can lead to suboptimization. In lean we are trying to maximize value. One tool lean has is to minimize work in process (WIP). WIP isn't value and utilizes resources without providing value. In my domestic example WIP is piles of laundry on the floor. So how do I get laundry done when I don't have pre-made piles to throw in to the washing machine?

  1. Take clothes that can be washed together from the dirty clothes hamper containing the most import clothes (mine) and toss them in the washer. 
  2. When they are done toss them in the dryer.
  3. Go to #1 until all clothes are done

A problem this approach can run into is when I focus on maximizing the amount of clothes I can stuff in the washer. Doing this is similar to maximizing the output of a machine on a factory floor. When I do this the clean, wet clothes have to wait for the dryer. As I am maximizing the amount of clothes I put in the washer my WIP is bigger than it should be. Kanban (a practice from lean manufacturing) uses WIP limits to prevent this from happening. I simply need to learn the amount I can place in the washer so that the washing (a fixed time on my machine) matches the drying time (a variable time on my fancy dryer). This is the Lean principle of Perfection.

In software development lean tells us to pull the value. Value is software that is being used by those that paid (at least indirectly) for the software. One common mistake when adopting a lean based software development approach is to force the business customer into breaking cohesive features into bite size ones that are of NO value to the business by themselves. Instead the development team needs to own the break down of features into bite size one and deliver the cohesive feature in a way that the business can use. Sometimes the feature can be delivered piecemeal, but often the feature is not useful until all parts (think CRUD) are done.

The other mistake is trying to to the entire feature at once. This is comparable to shoving all the clothes in the washer. You need to find the smallest unit that works for your group. In a small group (one-two developers) in can be tackled in extremely small increments (one test at a time in TDD). In larger groups more coordination will be needed. It will be up to each group to find the sweet spot (like how many pants can my drier dry in one wash cycle).

One thing to keep in mind when adopting a lean approach is there is NO ONE RIGHT WAY. Every situation is different and requires different practices and rules to be optimal. The key is the Perfection principle. Never be satisfied. Always look for ways to make the software better, faster and more valuable to the business. Sometimes you will try ides that cause a step backwards in productivity, but these are a step forward in knowledge. Remember perfection is not achievable, but with lean you should always be seeking it.