Mental Models for Software Engineers: Feedback Loops

All real-world systems have some form of a feedback loop. Feedback loop is so called because output of the system is fed back into the system as input, increasing or decreasing its effect. The most common example of a feedback loop is audio feedback. I am sure most of you have experienced it at least once in your lifetime. Audio feedback loop occurs when a sound loop exists between an audio input(ex. Microphone) and audio output. Watch the video in case you want to experience it again. I am waiting….

Now that you are back. Let’s try to understand feedback loop by going over a common situation in most software development organisations.

Management in most organisations care only about the feature velocity. They want more features delivered in less time. As team delivers more features, management want developers to further increase their productivity and deliver more features. This helps an organization acquire more customers and get more $$$. The more features a development team delivers, less time they will spend on clearing the technical debt. More technical debt a team incurs, it becomes more and more difficult to deliver features leading to decrease in feature velocity. This will force management to give time to developers to decrease the technical debt and improve quality of the product. This will eventually improve feature velocity. The cycle will repeat. This is an example of a feedback loop.

A feedback loop can be either positive or negative. Whether a feedback loop is positive or negative is determined by the connections in the loop. Connections are also of two types — positive and negative. Let’s take a look at positive and negative connections to better understand loop structure.

  • In a positive connection when you increase or decrease one variable of the system then another variable of the system will also increase or decrease in the same direction. In the above example, increase in feature velocity lead to increase in revenue.
  • In a negative connection when you increase or decrease one variable of the system then another variable of the system will change in the opposite direction i.e. decrease or increase. In the above example, increase in feature velocity lead to decrease in quality of the system.

The above is an example of a negative feedback loop. Negative feedbacks are self-correcting; they tends to hold a system to some equilibrium state making it more stable. Feature velocity will stabilise to a level that can be sustained.

Another example of a system that makes use of negative feedback loop is human body.

If the body temperature rises above 98.6 F then skin sensors send a signal to the brain. The brain relays the information to the effectors that increase blood flow to the skin. This induces perspiration which on evaporation lowers the body temperature. Similarly, when the body cools down below a certain threshold, blood flow is reduced causing shivering. This activity generates heat through physical activity thus raising body temperature.

Positive feedback loop amplify changes. They can move a system away from its equilibrium state and make they unstable. An example of positive feedback loop is social media notification anxiety. Good habits like saving and investing money, investing in horning can lead to snowball effect. Compounding is an example of positive effect that leads to more positive effect.

Another example of positive feedback loop is hiring. Hiring good developers will lead to more good developers in an organisations.

Another example of feedback loop is garbage collectors in most modern programming languages.

One important point to consider with feedback loop is that their might be time delay between cause and effect in a system.

Other examples of feedback loops in software development

I am a strong believer in the philosophy that fast feedback loops lead to better software. Following are the few practices that can create a feedback loop that helps build high quality software.

  1. Automated tests: The only way you can build a stable system is by investing in automated tests. Write tests -> Run tests -> Write code to make failing test pass -> run tests is a continuous feedback loop that keep software developers in the right mindset. The output of automated tests is either a green light or red light. Red light means you should take a step back and fix the failing test. Green light means move ahead with writing next lines of code. Successful output of tests give confidence to the developers that they have not broken anything.

  2. Code review: Along with automated tests another feedback loop that has tremendous impact on building high quality products is code review. Getting quick feedback on your work from your colleagues ensure you are on the right path.

  3. Continuous integration: It provides feedback that application is building on a centralised machine. This ensure applications builds for everyone.
  4. Application monitoring: When your application is running, monitoring provides feedback on how your application is behaving in production.

Video on Feedback loop

A good TED talk on feedback loop

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s