Tuesday, 5 July 2011

Optimization has no Business Value

Or: The future – who cares?

By Sid B. Dane, July 1st, 2011

What is best to do: optimize your IT project to be prepared for the future or don’t care, we’ll see what happens then? In a SCRUM environment you have a strong preference for focusing on Business Value, i.e. effectiveness and not efficiency. The way to reason if you should be prepared for the future is first put it in the two extreme opposites:

  • Only solve the problem at hand; use the simplest possible solution ("Effective Java (2nd Edition)" / Joshua Bloch, 2008);
  • Always implement the principles of scalability, maintainability, reliability, availability, extensibility, performance, manageability, and security
The thing is: we cannot predict the future. Well, we can expect things, but it is not a prediction. This is like a weather forecast: it’s reasonably accurate for the next day, but after 3 days it’s more like a guess. So does it take more effort to be prepared for the future than just act on it like it comes? In an Agile environment, the rule is: choose respond to change over following a plan ("Manifesto for Agile Software Development" / Kent Beck, Mike Beedle, Arie van Bennekum, and others, 2001).

Also, taking care of things that might happen or might be handy in the future can introduce concessions to speed and performance and other things ("Premature optimization is the root of all evil - not only in the Agile world" / Przemysław Bielicki, 2008). Should you be willing to do those concessions just for the sake of being prepared for the future?

A mental model

Let’s take a look at these two scenarios:


In scenario 1 and 2 the same functionality is developed, which takes 100 units of work. In scenario 1 though, also 20 units of work are spent extra to do optimization. In scenario 2 just the simplest solution is applied and no extra optimization is done.

In this example, we assume that an extra of 10 work units need to be done to change that particular part needed for the new requirement. We can see that if the extra requirement needs 15 units of work, the total sum of work units spent is 135 in scenario 1 and 125 in scenario 2. If another extra requirement comes along, and we add those numbers again, we result in 150 units in scenario 1 and also 150 units in scenario 2.

We can assume this is quite a retentive model, and even then the early optimization pays back only when the 3rd extra requirement is added. So the question is: how likely is it that there will be at least 3 added requirements?

Well, in my opinion this is as likely as forecasting the weather for the next 7 days. I could even argue about the number of work units chosen for the early optimization in scenario 1. How likely is it if you spend 1/5th of the development time extra to optimize the system, that this will cover all possible or all likely future changes?
“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” ("The C++ Programming Language, 11.3.7: Efficiency" / Donald E. Knuth, 1988)
It would be nice to measure the following for all stories:

  •  How much time is spent on early optimization?
  • How much time is spent on developing the new requirement?
  • How much time is spent because early optimization was not done?
  • How much time is spent because early optimization was not done?
If you measure these parameters on 500 stories on your backlog, it would be interesting to see what scenario works best. Using the law of large numbers, you should consequently use the same scenario to make it work.
Project Managers will complain if negative signals reach them from the project. Spending time because early optimization is not done would be a negative signal. If it exists multiple times in 1 project, it appears to be a bad thing. Depending on how well the Project Manager is heard, views on early optimization will change. The overall gain usually is not visible because the early optimization that is done is often interwoven in the regular development work.
In non-agile environments, there usually is not much time to spend on early optimization. It is focused on meeting the deadline. In an agile environment, the team can decide for themselves. They will be eager to do early optimization because they never had the chance and it always was a developer’s utopia. And it’s the best thing to do… theoretically.
On the other hand, we are working in a SCRUM environment, so the actual questions that should be asked is:

  • How much Business Value is generated by early optimization?
“More computing sins are committed in the name of efficiency (not necessarily achieving it) than for any other single reason - including blind stupidity.” ("A Case Against the GOTO, Proceedings of the 25th National ACM Conference" / William A. Wulf, 1972)
How to handle this theory?

To avoid discussion on semantics, we should clearly identify premature or early optimization. The word premature indicates by itself that it’s not a good thing. Early sounds a bit better. But it’s not the words here that matter.

I won’t say that one should never optimize or early optimize. Thing is, in what level are we committed to creating Business Value? If no early optimization is done, the time-to-market will be optimal. The first few changes we can do quickly and it will not cost too much. Changes will take a little more time because we will have to make adjustments to the system to make it fit, but the overall time spent is less, at least for those few first changes.

To make things even a bit better, you could create a rule of thumb about optimization. Some specific aspects of … made us learn that it would be good to invest in those on a certain level. But those optimizations should always be minor and one should always be aware of the motivations and if those motivations are valid and not just because you should optimize or something could maybe happen.
“We follow two rules in the matter of optimization: Rule 1. Don't do it. Rule 2 (for experts only). Don't do it yet - that is, not until you have a perfecly clear and un-optimized solution.” ("Two rules in the matter of optimization" / M.A. Jackson, 1975)
If an optimization is of a larger size, it could be considered a new requirement to the story and the Product Owner and/or Business should be asked if there is any Business Value in it. If not, first make the un-optimized solution and after that reevaluate the necessity of the optimization.

=== END ===

special thanks to Korjan van Wieringen, friend and sparring partner

Bibliography

  • "A Case Against the GOTO, Proceedings of the 25th National ACM Conference" / William A. Wulf. (1972, August).
  • "Effective Java (2nd Edition)" / Joshua Bloch. (2008, May 28).
  • "Manifesto for Agile Software Development" / Kent Beck, Mike Beedle, Arie van Bennekum, and others. (2001).
  • "Premature optimization is the root of all evil - not only in the Agile world" / Przemysław Bielicki. (2008, oktober 9).
  • "The C++ Programming Language, 11.3.7: Efficiency" / Donald E. Knuth. (1988).
  • "Two rules in the matter of optimization" / M.A. Jackson. (1975).