<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Eric Gunnerson's Compendium</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ericgu/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ericgu/feed.xml</link>
    <description />
    <lastBuildDate>Sun, 05 Nov 2017 03:45:56 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Last post…</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/last-post</link>
      <pubDate>Sun, 05 Nov 2017 03:45:53 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12467</guid>
      <description><![CDATA[&nbsp; Hey folks. &nbsp; After 23 years of fun, I'm leaving Microsoft to try some new things, and...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p><font size="3">Hey folks.</font></p> <p><font size="3"></font>&nbsp;</p> <p><font size="3">After 23 years of fun, I'm leaving Microsoft to try some new things, and therefore this blog will be going into readonly mode.</font></p> <p><font size="3"></font>&nbsp;</p> <p><font size="3">If you want to continue to read about agile development or design, you might be interested in my new blog:</font></p> <p><font size="3"></font>&nbsp;</p> <p><font size="3"><a href="https://ericscodeshack.com/">EricsCodeShack.com</a></font></p>]]></content:encoded>
    </item>
    <item>
      <title>#NoTDD</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/notdd</link>
      <pubDate>Thu, 22 Jun 2017 15:31:43 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12465</guid>
      <description><![CDATA[Did that title get your attention? Good. Like the other #no&lt;x&gt; assertions – NoEstimates,...]]></description>
      <content:encoded><![CDATA[<p><font size="3">Did that title get your attention? Good.</font></p> <p><font size="3">Like the other #no&lt;x&gt; assertions – NoEstimates, NoBugs – I'm really not saying that you shouldn't do TDD. Well, maybe I am…</font></p> <p><font size="3">I was an early TDD advocate, as I really liked the way it helped me organize my thoughts, and I respected some of the other people who were early advocates – people like <a href="https://ronjeffries.com/">Ron Jeffries</a>. </font></p> <p><font size="3">But looking back on the 15 years since I started with TDD, I have to say that it really did not live up to my expectations. </font></p> <p><font size="3">What I've seen is a consistent pattern of TDD working in a laboratory setting – developers are quick to pick up the workflow and can create working code and tests during classes/exercises/katas – and then failing in the real world.</font></p> <p><font size="3">My hypothesis for this is very simple. When you look at the TDD evangelists, all of them share something: they are all very good – probably even great – at design and refactoring. They see issues in existing code and they know how to transform the code so it doesn't have those issues, and specifically, they know how to separate concerns and reduce coupling.</font></p> <p><font size="3">If you have those skills, TDD works great; you see what the issues are as the arise and fix them incrementally, and your simple tests prove that your design has low coupling. And, you have the tests to lean on in the future. </font></p> <h1>A hypothetical</h1> <p><font size="3">Let's take the TDD workflow and remove the third step – the refactoring step. What would we expect to happen?</font></p> <p><font size="3">Well, we would expect to end up with classes that have multiple concerns in them – because we didn't split them apart – and they would be inconvenient to test. We would need to write a lot of test code, and would need a lot of help to write the code, either creating many hand-written mocks or using mock libraries. </font></p> <p><font size="3">Which I submit is precisely the result that most developers get using TDD; the resulting code looks exactly like what we would expect if developers are skipping the third step. Which isn't really very surprising, given that the tests in most non-TDD code look the same way, and we know that most developers do not have great design/refactoring skills. </font></p> <p><font size="3">At this point we should ask ourselves, "are these developers getting a net positive benefit from using TDD?" Let's list the pros/cons:</font></p> <h2></h2> <h2>Pros</h2> <li><font size="3">We end up with tests that verify the behavior of the code and help prevent regressions</font></li> <p><font size="3"></font>&nbsp;</p> <h2>Cons</h2> <p><font size="3"></font>&nbsp;</p> <li><font size="3">It takes us longer to write code using TDD</font> <li><font size="3">The tests get in the way. Because my design does not have low coupling, I end up with tests that also do not have low coupling. This means that if I change the behavior of how class &lt;x&gt; works, I often have to fix tests for other classes. </font> <li><font size="3">Because I don't have low coupling, I need to use mocks or other tests doubles often. Tests are good to the extent that the tests use the code in precisely the same way the real system uses the code. As soon as I introduce mocks, I now have a test that only works as long as that mock faithfully matches the behavior of the real system. If I have lots of mocks – and since I don't have low coupling, I need lots of mocks – then I'm going to have cases where the behavior does not match. This will either show up as a broken test, or a missed regression. </font> <li><font size="3">Design on the fly is a learned skill. If you don't have the refactoring skills to drive it, it is possible that the design you reach through TDD is going to be worse than if you spent 15 minutes doing up-front design. </font></li> <p><font size="3"></font>&nbsp;</p> <p><font size="3">I think that's a good summary of why many people have said, "TDD doesn't work"; if you don't have a design with low-coupling, you will end up with a bunch of tests that are expensive to maintain and may not guard against regression very well. </font></p> <p><font size="3">And to be fair, the level of design and refactoring skills required is relative to the state of the codebase you're working in. There are a lot of legacy codebases with truly monumental amounts of coupling in them and figuring out how to do anything safely is very difficult and complex. </font></p> <h1>TDD—, Refactoring++</h1> <p><font size="3">Instead of spending time teaching people TDD, we should instead be spending time teaching them more about design and especially more about refactoring, because that is the important core skill. The ability to write and refactor code to a state with low coupling, well-separated concerns,&nbsp; and great names will be applicable in all the codebases that we work in. </font></p> <p><font size="3">That is not to say that I don't dust off Ncrunch now and then to either create a new set of functionality with great tests or to create tests around a concern as I do a refactoring, because I still do that often. I just don't think it's the right place to start from a educational or evangelical perspective. </font></p>]]></content:encoded>
    </item>
    <item>
      <title>Agile and the Theory of Constraints: Part 4–The Inner Loop</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/agile-and-the-theory-of-constraints-part-4-the-inner-loop</link>
      <pubDate>Thu, 11 May 2017 15:32:49 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12456</guid>
      <description><![CDATA[In this post, I'm going to talk about what I'm calling the inner loop, what some people call "Ring...]]></description>
      <content:encoded><![CDATA[<p><font size="3">In this post, I'm going to talk about what I'm calling the inner loop, what some people call "Ring Zero"; it is basically the simple act of writing code and validating it, over and over. It is focused on a single developer. </font></p> <h1>Code/Test/Code/Test/Code/Test/Code/Test</h1> <p><font size="3">Before I dig into things, I have a bit of pre-work for you. I would like you to spend 5 minutes listing all the things that you (or your team) do/does as part of the inner loop, and then create a value stream map from that information. Put numbers on all of the steps, but don't worry if they aren't particularly accurate. You can also use a range like 5-10 minutes. </font></p> <p><font size="3">Do you have a diagram that describes your current process? Great. </font></p> <p><font size="3">Here's the first diagram I came up with:</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2016/04/code1.jpg"><font size="3"><img class="alignnone size-full wp-image-11875" alt="code1" src="https://msdnshared.blob.core.windows.net/media/2016/04/code1.jpg" width="568" height="244"></font></a><font size="3"> </font></p> <p><font size="3">The times are going to vary considerably for a given team and a given developer. Let's expand a little bit on the diagram to add our first handoff. This time, because we're only talking about a single developer, it's a different kind of handoff. </font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/image187.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/05/image_thumb171.png" width="862" height="246"></a></p> <p><font size="3">When we start a build, we are handing off the code to another process –the compiler – and we will need to wait until that process is done. And no, that 5-60 minutes is not a misprint; I've worked on a number of teams where a full build was at least an hour. </font></p> <p><font size="3">If you are thinking, "self, that looks like a queue/handoff and a context switch, and that is bad". If so, give yourself a gold star and a hearty "Well done!". Let's flesh this out a bit more….</font></p> <p><font size="3"></font>&nbsp;</p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/image188.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/05/image_thumb172.png" width="1026" height="296"></a></p> <p><font size="3">Before we can test or debug our code, we need to deploy it to a place where we can test or debug it. If we are running unit tests, we don't have a deploy step, which is why it sometimes takes 0 minutes.</font></p> <p><font size="3">Finally, sometimes we are successful, and sometimes we are not. That needs to be represented in the diagram as well…</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/image189.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/05/image_thumb173.png" width="1031" height="315"></a></p> <p><font size="3"></font>&nbsp;</p> <p><font size="3">If our build failed or our test/debug failed, we need to go back and tweak the code. If it worked, then we need to figure out the next thing to do.</font></p> <p><font size="3">Time to search for bottlenecks. Where do we look?</font></p> <p><font size="3">The usual places; we look for handoffs and we look for queues. Waiting for the build and waiting for the deployment are excellent candidates. Before we dig in there, I want to go on a bit of a tangent…</font></p> <p><font size="3">In earlier posts, I talked in depth about developers switching to do something else and the costs of that. I'd like to quantify that using</font><font size="3"> Eric's <strong><font size="5" face="Times New Roman">Theory of Developer Wait Times</font></strong>. </font></p> <p><font size="3">It sounds more grandiose than it really is…</font></p> <p><font size="3"></font>&nbsp;</p> <table cellspacing="0" cellpadding="2" width="648" border="1"> <tbody> <tr> <td valign="top" width="200"> <p align="center"><font size="3"><strong>Wait time</strong></font></p></td> <td valign="top" width="446"> <p align="center"><font size="3"><strong>Impact</strong></font></p></td></tr> <tr> <td valign="top" width="200"> <p align="center"><font size="3">None</font></p></td> <td valign="top" width="446"> <p align="center"><font size="3">No impact</font></p></td></tr> <tr> <td valign="top" width="200"> <p align="center"><font size="3">&lt;15 seconds</font></p></td> <td valign="top" width="446"> <p align="center"><font size="3">Slight impact on flow</font></p></td></tr> <tr> <td valign="top" width="200"> <p align="center"><font size="3">60 seconds </font></p></td> <td valign="top" width="446"> <p align="center"><font size="3">Some context lost. Annoying.</font></p></td></tr> <tr> <td valign="top" width="200"> <p align="center"><font size="3">2 minutes</font></p></td> <td valign="top" width="446"> <p align="center"><font size="3">Most context lost; hard to keep focus</font></p></td></tr> <tr> <td valign="top" width="200"> <p align="center"><font size="3">&gt; 2 minutes</font></p></td> <td valign="top" width="446"> <p align="center"><font size="3">I'm doing something else</font></p></td></tr></tbody></table> <p><font size="3"></font>&nbsp;</p> <p><font size="3">This is basically just a repurposing/reexpression of the research around how users react to delays in programs. </font></p> <p><font size="3">Once we get above 2 minutes, it's time to read email, take a nature break, get some water, read the Facebooks, etc. Because it's a hard interruption, it's really easy for 3 minutes to turn into 15 minutes. </font></p> <p><font size="3">Since developers spend a lot of time waiting for builds, the majority of the teams out there put a high priority on having fast builds; they give developers capable machines on which to do builds, they architect their projects so that components are small and builds can therefore be fast, and the focus on fast-executing unit tests rather than slower integration tests. </font></p> <p><font size="3">Ha Ha. I make joke. </font></p> <p><font size="3">Remember the discussion about how local optimization can de-optimize other parts of the system from the last post? Here's another example.</font></p> <p><font size="3">The amount of time I waste waiting for a build is determined by how long the build takes and how many times I need to wait for it. If my build takes 10 minutes, I will look to batch my work so that I minimize how much time I spend waiting for builds. That means bigger checkins, with all the downsides that come from them; mistakes are more common, design feedback is less likely to acted upon, etc. </font></p> <p><font size="3">Is this obvious, or even noticeable? I</font><font size="3">f you ask most dev leads about the impact of build speed on their team's productivity, they will say something like, "Our build is slower than we would like, but it's not a large drain on our productivity". They say this whether their average build takes 30 seconds or their average build takes 15 minutes. That is based on an estimate of the "time spent waiting for builds" / "total time" metric. Developers will rearrange how they do things (ie "optimize") so that the metric doesn't get too far out of whack in most cases. </font></p> <p><font size="3">What they are missing is the opportunity cost of having slow builds.</font></p> <ul> <li><font size="3">Slow builds means no TDD. I am fairly stubborn and I've tried to modify TDD to make it work when I have slow builds, but it isn't really effective, and there is no way I can convince anybody else to try it. </font></li> <li><font size="3">Slow builds mean I (probably) can't leverage any of the&nbsp; continuous testing tools such as NCrunch or dotCover in the C# world or Infinitest in the Java world. Ncrunch is why there is a "none" entry in the wait time table; you just write your product code and your test code and everything happens in the background, with no wait for compile or deploy. </font></li> <li><font size="3">Slow builds mean my team will write fewer tests.</font></li> <li><font size="3">Slow builds mean my team will do fewer refactorings. </font></li></ul> <p><font size="3">In lean terms, slow builds are a constraint, and the developer optimization is an attempt to subordinate the constraint. Which is fine as long as you exploit and elevate the constraint to try to remove it as a constraint.</font></p> <p><font size="3">If you can only do one thing, work on getting your developer builds faster. </font></p> <p><font size="3">Having a short deployment cycle is also important, but </font><font size="3">if your builds are quick and you write unit tests, you will be spending a lot more time in that cycle and less time in the deployment cycle. For deployment I think that simple and automated is more important than pure speed, because mistakes you make in deployment kill your overall cycle time; just forgetting to deploy one changed binary can cost you anywhere from 15 minutes to a couple of hours. On the other hand, if you can make deployment very fast as well, nobody will be tempted to build a faster version of it, which has a lot of other benefits.</font></p> <h1>Figure out what code to write</h1> <p><font size="3">We will now move the fill in the left side of the diagram, the part where we figure out what code to write.</font> </p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/image190.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/05/image_thumb174.png" width="1199" height="566"></a>&nbsp;</p> <p><font size="3">There are three ways we figure out what code to write:</font></p> <ol> <li><font size="3">Sometimes we just think about it, or we already know pretty much what we want to do.</font></li> <li><font size="3">Sometimes we have to do some research to figure out what we need to do and/or how to do it.</font></li> <li><font size="3">Sometimes we ask somebody.</font></li></ol> <p><font size="3">Where are the bottlenecks here? </font></p> <p><font size="3">One of them is obvious – it's the time that we spend finding somebody to ask and/or the time we spend waiting for an email response to the a question. Unless it's a person-to-person interaction, that part generally takes long enough that we "go do something else". </font></p> <p><font size="3">So, we should just try to limit that path, right? </font></p> <p><font size="3">Well, nobody likes to interrupt other people to find out something you could have found out yourself, and in many (most?) teams there are social pressures that keep you from choosing that branch first, so they choose the upper research branch first. </font></p> <p><font size="3">The flow in that branch typically looks something like:</font></p> <ol> <li><font size="3">Need to do &lt;x&gt;</font></li> <li><font size="3">Do a web search on &lt;x&gt;</font></li> <li><font size="3">Read a few articles</font></li> <li><font size="3">Go write some code</font></li> <li><font size="3">Can't figure out on of the samples. </font></li> <li><font size="3">Go back and read some more </font></li> <li><font size="3">Modify the code. </font></li> <li><font size="3">Build/deploy/test the code</font></li> <li><font size="3">Mostly works, but not sure</font></li> <li><font size="3">Go back and read some more</font></li> <li><font size="3">Try something else</font></li> <li><font size="3">Code works, go do something else. </font></li></ol> <p><font size="3">Is that the most efficient way to do things? Or, to put it another way, if we wanted to make this faster, what would we do?</font></p> <p><font size="3">Well, the obvious observation is that our build/test/deploy time has a big effect on the cycle time here; that was one of the reasons I talked about that first. If you can experiment quickly, you can be a bit less sure of what you are doing, spending less time researching and more time doing. </font></p> <p><font size="3">But there's a larger thing at play here. </font></p> <p><font size="3">Our goal is obviously to get to the exit arrow as quickly as possible (assuming good testing, good quality code, etc. ). To do that, we have to write the code that is correct. </font></p> <p><font size="3">So, to state it another way, our bottleneck is figuring out what the right code is. If we can do that quickly, then the coding and testing part is generally pretty straightforward. </font></p> <p><font size="3">How do we become more efficient at that? How do we get rid of the waste?</font></p> <p><font size="3">The answer is simple. The biggest waste is when we go down the wrong path; we don't understand the code correctly, we don't understand what we are trying to do, or we use a more cumbersome way of solving a problem. How do we solve that? Well, we need to apply more minds to the problem.</font></p> <p><font size="3">Some groups have an "ask for help" rule, which says if you have been stuck on a problem for more than 15/30/60 minutes, you are required to ask for help. Which is a good idea, but you've already wasted a lot of time, nobody likes to ask for help, and you have to interrupt somebody else to ask, slowing them down. </font></p> <p><font size="3">What we really need is a way to dedicate extra brainpower to a task from the start. By doing so, we will reduce false starts, research flailing, waiting too long to ask, etc. – and we will write the right code faster.</font></p> <p><font size="3">And, once again, we've invented pairing. </font></p> <p><font size="3">Pairing is more efficient because it directly targets the waste in the system:</font></p> <ul> <li><font size="3">Time spent researching how the system works</font></li> <li><font size="3">Time spent researching options</font></li> <li><font size="3">Time spent modifying code when it doesn't work</font></li> <li><font size="3">Time spent doing more research when we could have just asked somebody. </font></li></ul> <p><font size="3">Why don't teams try to become more efficient at writing good code? </font></p> <p><font size="3">Well, that ties back to one of the weird parts of the profession. </font></p> <p><font size="3">Writing software is a very complex task, especially if you are doing it in a codebase that has a lot of technical debt. Because of that, it is very hard to estimate how long a given task should take, which – transitively – means that it is often hard to determine whether a task is taking longer than it should. We don't want to ask developers why a task is taking so long because that encourages the wrong behavior and we know that sometimes things just take a long time to do.</font></p> <p><font size="3">Pairing gives us a way to hop inside that complex task and get rid of the waste without having to ask the wrong question or mess up the group dynamic. That is one of the reasons it is so powerful. </font></p> <p><font size="3">That is all for this post, and that takes me to the end of where I envisioned the series. I do think there might be a short summary post to wrap things up. </font></p> <p><font size="3"></font>&nbsp;</p> <p><font size="3"></font>&nbsp;</p> <p><font size="3"></font></p>]]></content:encoded>
    </item>
    <item>
      <title>Agile and the Theory of Constraints – Part 3: The Development Team (3)</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/agile-and-the-theory-of-constraints-part-3-the-development-team-3</link>
      <pubDate>Tue, 18 Apr 2017 15:08:17 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12385</guid>
      <description><![CDATA[Finally, we make our way to the heart of the development team and the design &amp; code...]]></description>
      <content:encoded><![CDATA[<span style="font-size: medium">Finally, we make our way to the heart of the development team and the design &amp; code phase.</span>

<img src="https://msdnshared.blob.core.windows.net/media/2017/02/3.2a.png" />

&nbsp;

<span style="font-size: medium">That is the top part of this diagram. </span>

<span style="font-size: medium">The design/review/finish and code/review/finish chunks are very similar. T</span><span style="font-size: medium">he developer does some work, submits it for review, perhaps does rework based on the review, and then finally finishes and moves onto the next step.</span>

<span style="font-size: medium">As is common with an overall map, we're some important details:</span><a href="https://msdnshared.blob.core.windows.net/media/2017/02/3e_2.png"><img alt="3e_2" src="https://msdnshared.blob.core.windows.net/media/2017/02/3e_2.png" width="1074" height="296" /></a>

<span style="font-size: medium">In this detailed view, we see that the "Submit Review" step leads to a queue in front of three other developers, which then leads back to a queue for the original developer.</span>

<span style="font-size: medium">Let's explore a different perspective, switching from a value stream view to a sequence diagram. This diagram shows what each person is doing during a typical code review cycle:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3f.png"><img alt="3f" src="https://msdnshared.blob.core.windows.net/media/2017/01/3f.png" width="1167" height="308" /></a>

<span style="font-size: medium">I tried to pick what feels like a reasonable example; of course there are some reviews that are simpler and some that are much more complicated.</span>

<span style="font-size: medium">What we see here looks very nice from a utilization perspective; everyone is busy all the time, and the time from submission to finish for Miss Blue looks pretty good.</span>

<span style="font-size: medium">This diagram is missing a bit of detail, so let's add that in:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3g.png"><img alt="3g" src="https://msdnshared.blob.core.windows.net/media/2017/01/3g.png" width="1310" height="348" /></a>

<span style="font-size: medium">What we were missing is what the manufacturing world calls "setup time", which is the time it takes to switch a machine from doing one task to doing another. Obviously, this time is time that the machine is not doing useful work, and therefore reducing the time spent on setup is a major factor in optimizing throughput (</span><a href="https://www.mmsonline.com/articles/setup-reduction-at-the-heart-of-lean-manufacturing"><span style="font-size: medium">article</span></a><span style="font-size: medium">). </span>

<span style="font-size: medium">In our world, we call this period a context switch. This isn't a strict downtime, but there is a time of reduced efficiency, where developers are both less productive and more likely to make mistakes. How long it is depends upon the complexity of the mental model required; it might be only a couple of of minutes for a simple task, or it might be thirty minutes for a complex debugging scenario. Every time we switch from working on one thing to another, there is a loss of productivity and quality.</span>

<span style="font-size: medium">Note that this is the diagram for one review; the actual sequence diagram for a developer can be much worse; there may be multiple reviews going on at the same time, and there are other interruptions as well; meetings, breaks, and the all important lunch.</span>

<span style="font-size: medium">Looking at the diagram, the queues show up as lag time between when Miss Blue submits her code/design for review, and when the other developers start to review it. If we we can reduce that lag time – reduce the time spent in the queue – then we will improve the throughput of the system. So we  set up a policy that doing code reviews is our highest priority.

</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/image492.png"><img title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb481.png" width="447" height="342" /></a><span style="font-size: medium"></span>

<span style="font-size: medium">If you've made the choice in the picture, you know what happens; the process that you set to high priority runs faster, and you slow down the rest of the system. If you are lucky, you might even hang the system. </span>

<span style="font-size: medium">The same thing happens in our process; when a code review shows up, it gets handled quickly, which would seem to be what we want. But it also shifts the required context switch from "when I have some free time" to "right now", and that change makes the interrupt more costly. The teams I've been on that tried this absolutely hated it. </span>

<span style="font-size: medium">Is there another solution? Well, we know from our earlier examples that getting rid of a queue is far better than just reducing its time – especially if there is a handoff, as we have here – so how can we get rid of a queue?</span>

<span style="font-size: medium">Well, perhaps we can limit the number of developers who are required for a given code review, so that there is only one review queue per task. It would look something like this:</span>

<span style="font-size: medium"></span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/image493.png"><img title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb482.png" width="1044" height="267" /></a>

<span style="font-size: medium"></span>

<span style="font-size: medium">That is better from an interruption perspective, but we probably lose some quality, Mr. Red has more time and feels more responsible to do a good code review, but he doesn't have any more context than he did before, and he's still going to feel that the time he spends on code review is taken away from his "real work".</span>

<span style="font-size: medium">How can we improve that? What if he worked with Mrs. Blue during the design and coding, so that he understands *deeply* what is being done and can give immediate context. That would change the review process to be something like this:</span>

<span style="font-size: medium"></span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3h.png"><img alt="3h" src="https://msdnshared.blob.core.windows.net/media/2017/01/3h.png" width="1168" height="299" /></a>

<span style="font-size: medium">And yes, we have invented pairing. One of the benefit of pairing is obvious if you look at the sequence diagram and the long periods of work devoted to a single task; that is clearly going to have less waste than the previous diagram.</span>

<span style="font-size: medium">The groups that I have been on that paired heavily ended up with a slightly different workflow; when the code is done, a code review is always sent out – so that others can see what is going on if they wish – and the pair has the option to ask for review from somebody else if they think they need it. </span>

<span style="font-size: medium">This has worked very well in the groups that I've worked in. </span>

<span style="font-size: medium"></span><strong> <span style="font-size: medium">&lt;aside – the hidden cost of context switches&gt;</span></strong>

<span style="font-size: medium">If you are currently in a world like the one I described – one with lots of context switches – you might be saying to yourself, "self, I can see how it would be nice to have fewer interruptions, but I'm pretty good at context switching and still being productive."</span>

<span style="font-size: medium">Such a feeling is nearly universal, and almost always, it is wrong. When we are in a world that requires context switching – especially one where those context switches are higher priority – it's hard not to be in a reactive, firefighting mode. What I sometimes call tactical mode. </span>

<span style="font-size: medium">If you are in tactical mode, it's very hard to engage your thoughts around bigger strategic questions, such as whether the approach that you are taking is an efficient one. Instead of "being productive" meaning "making good choices about how things are done so as to maximize output", it becomes "responding quickly to interrupts and doing a decent job of juggling all the things on my plate". </span>

<span style="font-size: medium">Or, to put it another way, in a results-driven, context-switching environment, the chance that you are spending any time at all thinking about your efficiency is pretty low. </span>

<span style="font-size: medium">To go back to my processor/operating system analogy, everybody knows what happens to background tasks when your CPU is at 100%, and strategic level thinking is a background task. </span>

<span style="font-size: medium">I honestly think that if you can get rid of code review interruptions, that alone saves enough time to make pairing equal to single-developer work, without going to any of the other advantages. </span>

<span style="font-size: medium"><strong>&lt;/aside&gt;</strong></span>
<h2>Checkin Queue</h2>
<span style="font-size: medium">Finally, we get to the checkin queue, where you submit code into a system that builds it runs all the tests, and then checks the code in if it was successful. This is often known as "gated checkin".</span>

<span style="font-size: medium">Let's add in some of the missing detail.</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/image494.png"><img title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb483.png" width="860" height="548" /></a>

<span style="font-size: medium">When we submit our code, we jump into a queue where a separate machine will get the changes, make sure that everything builds, run the tests, and then either check the code in if it works or send an email to us telling us what the problems are. </span>

<span style="font-size: medium">Let's analyze the situation here…</span>

<span style="font-size: medium">First, I see that there is a queue for the developer to wait for this process to happen. That will require them to figure out something else to do during this time period. The wait is going to depend on how big the queue before "build" is, and how long the build and test run is going to take.</span>

<span style="font-size: medium">What effects does this approach have on the organization?</span>
<ol>
 	<li><span style="font-size: medium">Developers have to figure out something else to do while they wait, which involves a context switch and/or "looking busy".</span></li>
 	<li><span style="font-size: medium">Because of the time lag, there is possibility that somebody on your team will have their checkin finish before yours, and if their changes are incompatible with yours, you will have to wait. </span></li>
 	<li><span style="font-size: medium">Because the wait feels like wasted time to the developers (it is…), they will try to optimize by making their submissions bigger, which makes their code reviews bigger and harder to understand. None of this is good.</span></li>
 	<li><span style="font-size: medium">If the infrastructure breaks, we are dead in the water until it is fixed.</span></li>
 	<li><span style="font-size: medium">The "run tests" step is a magnet for more tests; if bugs get through the box, it's very tempting to add tests. That is *great* if they are unit tests, and horrible if they are integration tests, as the time to run the tests will get much slower.</span></li>
 	<li><span style="font-size: medium">The attitude is "the system is supposed to find the errors", which makes it easy to be sloppy and just submit things. </span></li>
 	<li><span style="font-size: medium">Failures are generally private, and not considered to be that important.</span></li>
 	<li><span style="font-size: medium">If there is a big failure that makes it though even though it shouldn't have, you need to stop the whole system and block everybody until you get it fixed. </span></li>
</ol>
<span style="font-size: medium">The incentives typically push these systems into becoming bottlenecks, and they also lock the behavior of the team around the system; the team cannot experiment in this area because the system prevents it. My experience is that this can work okay with small codebases, but it rarely turns out good in larger codebases. </span>

<span style="font-size: medium">Is there an alternative that gets rid of the bottleneck? Consider the following:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/04/image495.png"><img title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb484.png" width="913" height="330" /></a>

<span style="font-size: medium"></span>

<span style="font-size: medium">When the developer is finished, they check in their changes. There is a separate build/test machine that notices the changes, does the build, and runs the tests. If things are okay, it doesn't do anything. If there is a failure, it emails the team (and in some teams, turns on a flashing red light in the team room).</span>

<span style="font-size: medium">What are the differences?</span>
<ol>
 	<li><span style="font-size: medium">We have gotten rid of the queue, which saves time</span></li>
 	<li><span style="font-size: medium">Developers can work in smaller chunks. There is great synergy with pairing and working in small increments. </span></li>
 	<li><span style="font-size: medium">Failures are obvious, which puts social pressure on developers to be more careful.</span></li>
 	<li><span style="font-size: medium">The system rewards the behavior you want to incentivize; it encourages developers to be a little more careful, it encourages them to run tests on their computers (and therefore encourages them to keep those tests simple and fast).</span></li>
 	<li><span style="font-size: medium">It treats developers like adults who can make rational choices around what needs to be done before a checkin is made. </span></li>
</ol>
<span style="font-size: medium">The one downside of this system is that the build is sometimes broken. The teams I've worked on have adopted a "5 minute rule"; if you can fix the breakage in 5 minutes – say you just forgot to include a new file when you checked in – then you are allowed to do it. If it's going to take longer than that, you revert your checkin so that nobody else is blocked.</span>

<span style="font-size: medium"></span>

<span style="font-size: medium">Which finally brings us to the end of the developer team section. Up next… the individual developer…</span>

<a href="https://blogs.msdn.microsoft.com/ericgu/2017/05/11/agile-and-the-theory-of-constraints-part-4-the-inner-loop/">Next: Part 4 - The Inner Loop</a>]]></content:encoded>
    </item>
    <item>
      <title>Agile and the Theory of Constraints - Part 3: The Development Team (2)</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/agile-and-the-theory-of-constraints-part-3-the-development-team-2</link>
      <pubDate>Thu, 30 Mar 2017 15:13:56 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12315</guid>
      <description><![CDATA[In the last post, I asked you to put some numbers on the red (aka "rework") arrows on the diagram....]]></description>
      <content:encoded><![CDATA[<span style="font-size: medium">In the last post, I asked you to put some numbers on the red (aka "rework") arrows on the diagram. There are two ways to express these numbers; either the percentage of the time a specific path is taken, or the number of times the path is taken on average. I've chosen the latter because it is easier to understand. As I noted in the last post, it doesn't help us a lot to put numbers on the blue boxes because their times vary so drastically. </span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/3.2a.png"><span style="font-size: medium"><img alt="3-2a" src="https://msdnshared.blob.core.windows.net/media/2017/02/3.2a.png" width="1392" height="570" /></span></a>

<span style="font-size: medium">In value stream maps, we want to measure the overall time through the system. We don't have good times for the task boxes themselves, but it's really worse than that; pretty much every system has ways to jump queues or even skip whole sections of the process, and the numbers are different if it's the first time through or a rework.</span>

<span style="font-size: medium">Does that mean this value stream map is useless?</span>

<span style="font-size: medium">After all the time I've spent writing this, I am fervently hoping the answer is "no". Let's see what we can do with what we have…</span>
<h1>Searching for the bottleneck</h1>
<span style="font-size: medium">We normally start optimization by searching for the bottleneck. Here are a few characteristics of bottlenecks:</span>
<ol>
 	<li><span style="font-size: medium">They are always busy. </span></li>
 	<li><span style="font-size: medium">Work piles up in front of them. </span></li>
 	<li><span style="font-size: medium">Downstream resources are regularly idle.</span></li>
</ol>
<span style="font-size: medium">Let's walk through these, and see how we might apply them.</span>
<ol>
 	<li><span style="font-size: medium">This one works well with machines, but people are another matter. Not only can we easily look busy, we might be busy with low-value work. </span></li>
 	<li><span style="font-size: medium">Work piling up in front of them is a pretty good indicator. This is another way of saying, "examine the queues and find the ones that are the longest". </span></li>
 	<li><span style="font-size: medium">A machine that is after a bottleneck will look idle. As I noted in #1, humans are great at looking busy.</span></li>
</ol>
<span style="font-size: medium">It looks like we will be looking at the queues.</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/3.2b.png"><span style="font-size: medium"><img alt="3-2b" src="https://msdnshared.blob.core.windows.net/media/2017/02/3.2b.png" width="455" height="269" /></span></a>

<span style="font-size: medium">Absent any real data on where our bottleneck is, I'm going to start with the "owner acceptance" part of the process. What has drawn me here are the rework numbers, which mean that we generally find one design issue and one bug when we hit owner acceptance, which will require us to rewind back into the process. </span><span style="font-size: medium">That means the owner acceptance process time for a given feature is really the sum of:</span>
<ol>
 	<li><span style="font-size: medium">The time spent in the incoming queue. </span></li>
 	<li><span style="font-size: medium">The time to perform the acceptance test. </span></li>
 	<li><span style="font-size: medium">The time spent in the "redesign" and "fix bugs" queues (queues that are absent in the current map). </span></li>
 	<li><span style="font-size: medium">The time for the redesigned and fixed feature to wind its way through the process again. </span></li>
 	<li><span style="font-size: medium">The time spent in the incoming queue for the second time </span></li>
 	<li><span style="font-size: medium">The time to perform the acceptance test. </span></li>
 	<li><span style="font-size: medium">The time to repeat steps 3-6 if the feature still isn't right.</span></li>
</ol>
<span style="font-size: medium"></span>

<span style="font-size: medium">Not only are the rework issues slowing this feature down significantly, they are slowing all the other features down because we are using the same set of resources. And, they are significantly increasing the amount of work required in the owner acceptance step - we have to do most items twice - which is certainly going to make the acceptance testing itself slower.</span>

<span style="font-size: medium">Another way of looking at this is that rework causes a multiplier effect based on how often it happens and how far back in the map it sends you. Acceptance is at the end and it can send you all the way back to the beginning, so it can have a very big impact.</span>

<span style="font-size: medium">The solution here isn't very surprising; we should work to a) reduce the size of the acceptance queue, so features don't stall there, and b) reduce the chance that we need to do rework to address design issues and bugs.</span>

<span style="font-size: medium">There are a few agile practices that we might use:</span>
<ul>
 	<li><span style="font-size: medium">Embedding a product owner in the team </span></li>
 	<li><span style="font-size: medium">Having defined and regular interaction between the product owner and the developers </span></li>
 	<li><span style="font-size: medium">Doing feature design with the product owner and the whole team to make sure everybody is on the same page </span></li>
 	<li><span style="font-size: medium">Writing explicit acceptance criteria for features ahead of time. </span></li>
 	<li><span style="font-size: medium">Using ATDD with tools like Cucumber/Gherkin/Specflow.</span></li>
 	<li><span style="font-size: medium"></span>

<span style="font-size: medium">The best solution is going to depend on your organization and how you structure development. I recommend focusing on a shared understanding of scenarios and acceptance criteria up front, as that will both prevent issues and streamline acceptance testing by the team.</span>

<span style="font-size: medium">One more thought on this area; the situation here is an example of an handoff between teams. Handoffs are a great place to look for waste, because:</span>
<ul>
 	<li><span style="font-size: medium">They aren't under one team's control, which means it would take cross-team effort – which most companies are poor at – to improve them</span></li>
 	<li><span style="font-size: medium">The incentives in place are usually on a per-team basis, and therefore they reinforce an "us vs. them" perspective.</span></li>
 	<li><span style="font-size: medium">Politics often show up. </span></li>
 	<li><span style="font-size: medium">There are often fixed contracts/SLAs </span></li>
</ul>
<span style="font-size: medium">In other words, it's a lot of effort to try to fix them from within a team and the success rate isn't great, so they persist. </span><span style="font-size: medium">In lean terms, the teams on both sides will consider the handoff to be a constraint, and will subordinate (ie de-optimize) the rest of their process to try to deal with it as best they can.</span>

<span style="font-size: medium">It is therefore very important to ask, "what would happen if this handoff did not exist?"</span>
<h4><span style="font-size: medium">Moving upstream</span></h4>
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/3.2c.png"><span style="font-size: medium"><img alt="3-2c" src="https://msdnshared.blob.core.windows.net/media/2017/02/3.2c.png" width="291" height="248" /></span></a>

<span style="font-size: medium">Moving upstream, we next come to the test box. It has a lot in common with the owner acceptance scenario, but in thinking about it I realized that I'm missing some important detail in the drawing. For sake of discussion, I've collapsed the whole upper part of the diagram into a simple "Design &amp; Code" box. </span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/3.2d.png"><span style="font-size: medium"><img alt="3-2d" src="https://msdnshared.blob.core.windows.net/media/2017/03/3.2d.png" width="994" height="463" /></span></a>

<span style="font-size: medium">Not only is there a queue before test, there are queues on the output of test. The first queue sits before the triage process, where we spend time talking about how bad each bug is and whether we want to expend time fixing it. This is typically done by managers and other senior (read as "expensive", both in monetary terms and opportunity cost terms) people. I put "1-30 days" in front of that as a guess, but in my experience triage happens every week or every few weeks.</span>

<span style="font-size: medium">After that, bugs move into another queue, which is typically called the "bug backlog". The reason that the label says "1-N" is that the bug backlog is where many bugs go to die; unless you are fixing bugs faster than you are creating them, this list is going to continue to grow and you therefore will not fix all of the bugs.</span>

<span style="font-size: medium">I missed another feature of the diagram:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/3.2e.png"><span style="font-size: medium"><img alt="3-2e" src="https://msdnshared.blob.core.windows.net/media/2017/03/3.2e.png" width="935" height="407" /></span></a>

<span style="font-size: medium">Because bugs come in faster than you fix them, the bug backlog will grow to be too big, so there is often a "retriage" step, where you look at the bugs you already triaged and get rid of the lower-priority bugs. This is an example of rework of the rework.</span>

<span style="font-size: medium">What can we say about the effect of this on the time it takes a feature to flow through the system? If you agree that a bug is an indication that a feature has not met acceptance, then if you have bugs against that feature you are not done, and therefore most of your features are never done; you may have shipped them, but you are still engaged in rework on them after you ship them.</span>

<span style="font-size: medium">How did we end up here? Well, this seems like a good time for a story that I call "FeatureLocks and the Three Groups"...</span>

<em><span style="font-size: medium">FeatureLocks desperately wanted to go out into the world, but he was held up because he had bugs. He went and talked to the developers, and they said, "FeatureLocks, it's not our fault, it's the test team's job to find bugs, and they are too slow at it". Then he went and talked to the testers, and they said, "FeatureLocks, we are sorry there are bugs, but we are always busy testing and the developers are just writing too many bugs". Then he went to the triage group, and they said, "FeatureLocks, we know that you want to go out into the world, but you have 10 priority 1 bugs logged against you and you'll just have to wait until they are fixed". </span></em>

<em><span style="font-size: medium">FeatureLocks was so sad. His goal in life was to deliver value, but he couldn't do that until he worked well and could visit customers. </span></em>

<em><span style="font-size: medium">They did not live happily ever after. </span></em>

<span style="font-size: medium"></span>

<span style="font-size: medium">At this point, I feel compelled to talk a bit about charter.</span>

<span style="font-size: medium">If we want to improve our development process, we need a set of goals. Something like:</span>
<ul>
 	<li><span style="font-size: medium">Decreasing the time it takes features to move through the system </span></li>
 	<li><span style="font-size: medium">Decreasing the time it takes to fix bugs </span></li>
 	<li><span style="font-size: medium">Decreasing the number of bugs </span></li>
 	<li><span style="font-size: medium">Identifying more bugs earlier in the process</span></li>
 	<li><span style="font-size: medium">Reducing the average bug age</span></li>
</ul>
<span style="font-size: medium"></span>

<span style="font-size: medium">Who owns the charter to make things better?</span>

<span style="font-size: medium">Upper management certainly owns the overall charter, but they aren't really close enough to the problem, so they delegate it to the individual team managers. That doesn't work because each of the group only owns a part of the problem, and the handoff/interactions between groups aren't really owned by anybody. </span>

<span style="font-size: medium">Which means we really have two high-level problems; the first is the one we identified in the diagram - we have queues and lots of rework - and the second is that nobody owns the overall problem.</span>

<span style="font-size: medium">You have probably figured out that this is a long discussion that will lead us towards what is sometime called "combined engineering". We take the dev and test teams and we combine them into a larger "engineering" team. What do we get out of this?</span>
<ul>
 	<li><span style="font-size: medium">Since we don't have a handoff between teams, our queue between coding and testing will be smaller. More importantly, the way that process works is owned by one team, which means they can improve it. </span></li>
 	<li><span style="font-size: medium">It is in the new team's best interest to make bugs easier to find and fix.</span></li>
</ul>
<span style="font-size: medium">My experience is that combined engineering is a significant improvement over individual teams. </span>

<span style="font-size: medium">There is a natural extension to combining dev and test; the "devops" movement includes operations functions such as deployment into the same team, and has the same sort of benefits.</span>

<span style="font-size: medium"></span>

<span style="font-size: medium">The meta point – which I stole directly from the Theory of Constraints – is to always look at the interfaces between teams, because those are places where inefficiencies naturally accumulate. </span>

<span style="font-size: medium"></span>

<span style="font-size: medium">That pretty much covers the bottom part of the diagram; in my next post I'll be tacking the design / code part. </span>

<span style="font-size: medium"></span>
<p class="entry-title"><a href="https://blogs.msdn.microsoft.com/ericgu/2017/04/18/agile-and-the-theory-of-constraints-part-3-the-development-team-3/">Part 3: The Development Team (3)</a></p>
</li>
</ul>
&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Agile and the Theory of Constraints - Part 3: The Development Team (1)</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/agile-and-the-theory-of-constraints-part-3-the-development-team-1</link>
      <pubDate>Thu, 23 Feb 2017 15:31:51 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12095</guid>
      <description><![CDATA[(Note: The first version of this was a very random draft rather than the first part that I wrote. I...]]></description>
      <content:encoded><![CDATA[(Note: The first version of this was a very random draft rather than the first part that I wrote. I blame computer elves. This should be a bit more coherant)

This episode of the series will focus on the development team - how a feature idea becomes a shippable feature.

A few notes before we start:
<ul>
 	<li>I'm using "feature" because it's more generic than terms like "story", "MVP", "MBI", or "EBCDIC"</li>
 	<li>I picked an organizational structure that is fairly common, but it won't be exactly like the one that you are using. I encourage you to draw your own value stream maps to understand how your world is different than the one that I show.</li>
</ul>
<span style="font-size: medium">In this episode, we will be looking at the overall development team. I'm going to start by looking at a typical development flow:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3A.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/01/3A.png" alt="3a" width="1122" height="216" class="alignnone size-full wp-image-12115" /></a>

Green lines are forward progress, red lines show that we have to loop back for rework.

That's the way it works for a single developer, and across a team it looks something like this:

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3B.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/01/3B.png" alt="3b" width="1364" height="668" class="alignnone size-full wp-image-12125" /></a>

I've chosen to draw the case where features are assigned out by managers, but there are obviously other common choices. Hmm... there are already a ton of boxes in the diagram, and this is just the starting point, so I'm going to switch back to the single-developer view for now.

What are we missing?
<h1>Adding the Queues</h1>
<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3C.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/01/3C.png" alt="3c" width="1401" height="571" class="alignnone size-full wp-image-12135" /></a>

There are several queues in the process:
<ol>
 	<li>The input queue, which I'm going to ignore for now.</li>
 	<li>Design Review: After I have finished a design, I send it out to the rest of the team for review.</li>
 	<li>Code Review: After I have finished the implementation, I send out the code to the team for review.</li>
 	<li>Code Submission: I submit my code to an automated system that will run all the tests and check in if they all pass.</li>
 	<li>Test: The feature moves to the test phase. This might be done by the development team, or there might be a separate test team.</li>
 	<li>Acceptance: Somebody - typically a product owner - looks at the feature and determines if it is acceptable</li>
</ol>
Now, let's put some times on the time spend in the queue. The numbers I'm listing are from my experience for a decent traditional team, and they are typical numbers.
<ol>
 	<li>Design Review: 3 hours to 1 day.</li>
 	<li>Code Review: 3 hours to 1 day.</li>
 	<li>Code Submission: 30 minutes to 1 day.</li>
 	<li>Test: 1 day to 10 days</li>
 	<li>Acceptance: 1 day to 10 days.</li>
</ol>
Here's an updated diagram with the numbers on it:

<a href="https://msdnshared.blob.core.windows.net/media/2017/01/3d.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/01/3d.png" alt="3d" width="1388" height="580" class="alignnone size-full wp-image-12145" /></a>

At this point, we would typically try to put numbers on all of the blue boxes, but because our features sizes vary so much, the numbers were all over the place and weren't very useful.

We can, however, try to put some numbers on the red rework lines. I'd like you to think about what the numbers are in your organization, and we'll pick it up from there.

<a href="https://blogs.msdn.microsoft.com/ericgu/2017/03/30/agile-and-the-theory-of-constraints-part-3-the-development-team-2/">Part 3: The Development Team (2)</a>]]></content:encoded>
    </item>
    <item>
      <title>Trip Report: Agile Open Northwest 2017</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/trip-report-agile-open-northwest-2017</link>
      <pubDate>Tue, 14 Feb 2017 16:46:26 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12195</guid>
      <description><![CDATA[Agile Open Northwest uses a different approach for running a conference. It is obviously around...]]></description>
      <content:encoded><![CDATA[<a href="https://www.agileopennorthwest.org/">Agile Open Northwest</a> uses a different approach for running a conference. It is obviously around agile, and there is a theme – this year’s was “Why?” – but there is no defined agenda and no speakers lined up ahead of time. The attendees – about 350 this year – all show up, propose talks, and then put them on a schedule. This is what most of Thursday's schedule looked like; there are 3 more meeting areas off to the right on another wall.

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/IMAG0068.jpg"><img src="https://msdnshared.blob.core.windows.net/media/2017/02/IMAG0068.jpg" alt="imag0068" width="923" height="522" class="alignnone wp-image-12205" /></a>

I absolutely love this approach; the sessions lean heavily towards discussion rather than lecture and those discussions are universally great. And if you don't like a session, you are encouraged/required to stand up and go find something better to do with your time.

There are too many sessions and side conversations that go on for me to summarize them all, but I've chosen to talk about four of them, two of mine, and two others. Any or all of these may become full blog posts in the future.

<strong>TDD and refactoring: Did we choose the wrong practice?</strong>

<span>Hosted by </span><a href="https://arlobelshee.com/">Arlo</a><span>.</span>

The title of this talk made me very happy, because something nearly identical lived on my topic sheet, and I thought that Arlo would probably do a better job than I would.

The basic premise is simple. TDD is about writing unit tests, and having unit tests is a great way to detect bugs after you have created them, but it makes more sense to focus on the factors that cause creation of bugs, because once bugs are created, it's too late. And - since you can't write good unit tests in code that is unreadable - you need to be able to do the refactoring before you can do the unit testing/TDD anyway.

Arlo's taxonomy of bug sources:
<ul>
 	<li>Unreadable code.</li>
 	<li>Context dependent code - code that does not have fixed behavior but depends on things elsewhere in the system</li>
 	<li>Communication issues between humans. A big one here is the lack of a ubiquitous single language between customers to code; he cited several examples where the name of a feature in the code and the customer visible name are different, along with a number of other issues.</li>
</ul>
I think that the basic problem with TDD is that you need advanced refactoring and design skills to deal with a lot of legacy code to make it testable - I like to call this code "aggressively untestable" - and unless you have those skills, TDD just doesn't work. I also think that you need these skills to make TDD work well even with new code - since most people doing TDD don't refactor much - but it's just not evident because you still get code that works out of the process.

Arlo and I talked about the overall topic a bit more offline, and I'm pleased to be in alignment with him on the importance of refactoring over TDD.

<strong>Continuous Improvement: Why should I care?</strong>

I hosted and facilitated this session.

I'm interested in how teams get from whatever their current state to their goal state - which I would loosely define as "very low bug rate, quick cycle time, few infrastructure problems". I've noticed that, in many teams, there are a few people who are working to get to a better state - working on things that aren't feature work - but it isn't a widespread thing for the group, and I wanted to have a discussion about what is going on from the people side of things.

The discussion started by talking about some of the factors behind why people didn't care:
<ul>
 	<li>We've always done it this way</li>
 	<li>I'm busy</li>
 	<li>That won't get me promoted</li>
 	<li>That's not my job</li>
</ul>
There was a long list that were in this vein, and it was a bit depressing. We talked for a while about techniques for getting around the issue, and there was some good stuff; doing experiments, making things safe for team members, that sort of thing.

Then, the group realized that the majority of the items in our list were about blaming the issue on the developers - it assumed that, if only there wasn't something wrong with them, they would be doing "the right thing".

Then somebody - and of course it was <a href="https://arlobelshee.com/">Arlo </a>- gave us a new perspective. His suggestion was to ask the developers, "When you have tried to make improvements in the past, how has the system failed you, and what makes you think it will fail you in the future?"

The reality is that the majority of developers see the inefficiencies in the system and the accumulated technical debt and they want to make things better, but they don't. So, instead of blaming the developers and trying to fix them, we should figure out what the systemic issues are and deal with those.

<strong>Demo your improvement</strong>

Hosted by <a href="https://arlobelshee.com/">Arlo</a>.

Arlo's sessions are always well attended because he always comes up with something interesting. This session was a great follow-on to the continuous improvement session that I hosted.

Arlo's basic thesis for this talk is that improvements don't get done because they are not part of the same process as features and are not visibly valued as features.

For many groups, the improvements that come out of retros are either stuck in retro notes or they show up on the side of a kanban board. They don't play in the "what do I pick up next" discussion, and therefore nothing gets done, and then people stop coming up with ideas it seems pointless. His recommendation is to establish second section (aka "rail") on your kanban board, and budget a specific amount to that rail. Based on discussions with many managers, he suggested 30% as a reasonable budget, with up to 50% if there is lots of technical and/or process debt on the team.

But having a separate section on the kanban is not sufficient to get people doing the improvements, because they are still viewed as second-class citizens when compared to features. The fix for that is to demo the improvements the same way that features are demo'd; this puts them on an equal footing from a organizational visibility perspective, and makes their value evident to the team and to the stakeholders.

This is really a great idea.

Meta-Refactoring (aka "Code Movements")

Hosted by me.

In watching a lot of developers, use refactoring tools, I see a lot of usage of rename and extract method, and the much less usage of the others. I've have been spending some time challenging myself to do as much refactoring automatically with Resharper - and by that, I mean that I don't type any code into the editing window - and I've developed a few of what I'm thinking of as "meta-refactorings" - a series of individual refactorings that are chained together to achieve a specific purpose.

After I described my session, to friend and ex-MSFT Jay Bazuzi, he said that they were calling those "Code Movements", presumably by analogy to <a href="https://en.wikipedia.org/wiki/Movement_(music)">musical movements</a>, so I'm using both terms.

I showed a few of the movements that I had been using. I can state quite firmly that flipchart is really the worst way to do this sort of talk; if I do it again I'll do it in code, but we managed to make it work, though I'm quite sure the notes were not intelligible.

We worked through moving code into and out of a method (done with extract method and inlining, with a little renaming thrown in for flavor). And then we did a longer example, which was about pulling a bit of system code out of a class and putting it in an abstraction to make a class testable. That takes about 8 different refactorings, which go something like this:
<ol>
 	<li>Extract system code into a separate method</li>
 	<li>Make that method static</li>
 	<li>Move that method to a new class</li>
 	<li>Change the signature of the method to take a parameter of it's own type.</li>
 	<li>Make the method non-static</li>
 	<li>Select the constructor for the new class in the caller, and make it a parameter</li>
 	<li>Introduce an interface in the new class</li>
 	<li>Modify the new class parameter to use the base type (interface in this case).</li>
</ol>
Resharper is consistently correct in doing all of these, which means that they are refactorings in the true sense of the word - they preserve the behavior of the system - and are therefore safe to do even if you don't have unit tests.

They are also *way* faster than trying to do that by hand; if you are used to this movement, you can do the whole thing in a couple of minutes.

I asked around and didn't find anybody who knew of a catalog for these, so my plan is to start one and do a few videos that show the movements in action. I'm sure there are others who have these, and I would very much like to leverage what they have done.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Stop writing bad tests. Write only the tests that you can do great.</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/stop-writing-bad-tests-write-only-the-tests-that-you-can-do-great</link>
      <pubDate>Sun, 09 Oct 2016 20:25:15 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=12085</guid>
      <description><![CDATA[I've been working on a talk on ways to make unit testing easier. I has not been going well; I'd come...]]></description>
      <content:encoded><![CDATA[<span style="font-size: medium">I've been working on a talk on ways to make unit testing easier. I has not been going well; I'd come up with an approach I liked, do most of the slides for it, come back to it, and be unhappy with what I had written.</span>

<span style="font-size: medium">This happened – and I am not exaggerating – 4 times in a row. </span>

<span style="font-size: medium">In the 5th try, as I was working through the techniques I was going to talk about, I realized something. But let me back up a bit first…</span>

<span style="font-size: medium">Pretty much every introduction for unit testing starts with a very simple scenario using a very simple class; the flow is something like:</span>
<ol>
 	<li><span style="font-size: medium">Figure out what a method does</span></li>
 	<li><span style="font-size: medium">Write a test for it</span></li>
 	<li>Repeat</li>
</ol>
<span style="font-size: medium">Or, if you are doing TDD, you swap the order and write the test before the method.</span>

<span style="font-size: medium">With a small class and small problem space, this works well; it's simple for developers to understand, and you can therefore present it to a group and they walk out thinking that they understand unit testing.</span>

<span style="font-size: medium">There is one *tiny* problem, however. </span>

<span style="font-size: medium">It doesn't work on real classes – and by that, I mean the classes that are in most real system. We all know that the testability of existing codebases is low, and we also know that most developers do not have the design skills or experience to take that sort of code and write good unit tests for it. </span>

<span style="font-size: medium">But that is what developers try to do, because <strong>THAT IS WHAT OUR INTRODUCTION TOLD THEM UNIT TESTING IS ABOUT</strong>.</span>

<span style="font-size: medium">So, they take their existing code, add in a bunch of interfaces so they can inject dependencies, pull in their favorite mocking library, shake it around a bit, and end up with a unit test.</span>

<span style="font-size: medium">Hmm…</span>
<ul>
 	<li><span style="font-size: medium">There is a lot of test code that takes time to write</span></li>
 	<li><span style="font-size: medium">Because of the high coupling, changes in many areas of the system will require changes in the test</span></li>
 	<li><span style="font-size: medium">The test is very hard to understand, and it's often not clear whether the test is actually testing what it says it is testing</span></li>
 	<li><span style="font-size: medium">Developers do not feel like they are being successful in writing unit tests. </span></li>
</ul>
<span style="font-size: medium">And – <strong>AND – </strong>there is very little chance of the test driving improvements, which is one of the main reasons we are advocating for a unit-testing approach. </span>

<span style="font-size: medium">We have been going about this in the wrong way.</span>

<span style="font-size: medium">We should focus on teaching developers how to look at code and figure out what different units are lurking in a single class, and also teaching them how to extract those units out so that simple tests can be written for them. </span>

<span style="font-size: medium">And… we should lighten up on the "you should write tests for everything", because these expensive complex tests aren't doing anybody any good. </span><span style="font-size: medium">
</span>]]></content:encoded>
    </item>
    <item>
      <title>You Suck at TDD #8 – Doing fewer things</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/you-suck-at-tdd-8-doing-fewer-things</link>
      <pubDate>Tue, 05 Jul 2016 15:05:33 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=11773</guid>
      <description><![CDATA[Welcome back to You Suck at TDD. Today's code will show up in the Improvements-Phase-3 branch if you...]]></description>
      <content:encoded><![CDATA[Welcome back to You Suck at TDD. Today's code will show up in the <a href="https://github.com/ericgu/DesignForTestability/tree/Improvements-Phase-3">Improvements-Phase-3 branch</a> if you would like to follow along.

In our last episode, we concentrated mostly on the Employee fetching and filtering. Things are better, but we still have a problem...

Well, actually, we have a number of problems, but we'll start with the first one that I see, which is that Yucky.GetEmployees() is trying to do too many things - it both fetches data and filters it.

This is one of the most common things I see when I look at code - methods that try to do too much, and they are generally quite challenging to test because they do too much.
<h2>EmployeeSource class</h2>
So, we'll start by working on that. I pulled the fetching code out into a new EmployeeSource class and then I pulled the creation of the EmployeeSource instance out of GetEmployees().

At this point, GetEmployees() only has a couple of lines in it:

<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> EmployeeCollection GetEmployees(EmployeeFilter employeeFilter, EmployeeSource employeeSource)
{
    <span class="kwrd">var</span> employeeCollection = employeeSource.FetchEmployees();

    <span class="kwrd">return</span> employeeCollection.Filter(employeeFilter.Matches);
}
</pre>
We can easily simplify it with an inline of employeeCollection:

<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode"><span class="kwrd">return</span> employeeSource.FetchEmployees().Filter(employeeFilter.Matches);</pre>
At this point, there is no reason to have a separate method, so I inlined FetchEmployees() and did some cleanup in Main(), and deleted class Yucky.

This does make Main() more complex than I would like it, but I did the inline with a purpose; I find that my thoughts are often constrained by the abstractions that are present, and the act of getting rid of a bad abstraction sometimes makes it easier to find the right abstraction.

Spending a little time with Main(), it isn't testable code, and I'd like to get some tests in there...

If we abstract out writing the output to the console, we get something like this:

<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode"><span class="kwrd">var</span> collection = employeeSource.FetchEmployees().Filter(employeeFilter.Matches);

WriteToConsole(collection);
</pre>
That's decent code; since it doesn't have any conditionals, it's likely code that either works all the time or never works at all. Not my first target when I'm looking to make things more testable, but if we wanted to cover it, how can we do it?

Well, the most obvious thing to do is to extract the IEmployeeSource interface, create a method that calls that, create a mock (or a simulator using P/A/S), and then write a test or two. That adds some complexity; you have another interface hanging around, and you need to create and maintain the mock and simulator. It will definitely work, but it is a fairly heavyweight approach.

I'm instead going to go with a different option. One of the things I've noticed with developers is that while they may pick up on the opportunity to create a data abstraction - or not, given the title of this series - they rarely pick up on the opportunity to create an <strong>algorithmic</strong> abstraction.

So, I'm going to go in that direction.

From an abstract perspective, this code does the following:
<ul>
	<li>Creates a chunk of data</li>
	<li>Performs an operation on that chunk of data to create a second chunk of data</li>
	<li>Consumes that chunk of data</li>
</ul>
Our current implementation implements this through procedural statements, but we could consider doing this differently. Consider the following code:

<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Pipeline
{
    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Process&lt;T1, T2&gt;(Func&lt;T1&gt; source, Func&lt;T1, T2&gt; processor, Action&lt;T2&gt; sink )
    {
        sink(processor(source()));
    }
}
</pre>
This is an abstraction of the pattern that we were using; it's general-purpose code that takes a source, processor, and sink, and knows how to wire them up to pass data between them. The version of Process() that I wrote handles this specific case, but you can obviously write versions that have more than one processor.

Doing that with our code results in the following:
<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode">Pipeline.Process(
    employeeSource.FetchEmployees,
    (employees) =&gt; employees.Filter(employeeFilter.Matches),
    WriteToConsole);
</pre>
I like the first and third arguments, as they are just method names. I would like the second line also to be a method name.

We can recast this by adding a Filter() method to EmployeeFilter, which then yields:
<!-- code formatted by https://manoli.net/csharpformat/ -->
<pre class="csharpcode">Pipeline.Process(
    employeeSource.FetchEmployees,
    employeeFilter.Filter,
    WriteToConsole);
</pre>
That makes me fairly happy; Pipeline.Process() is tested, and the code to use pipeline is almost declarative.

Take a few minutes and look through the current implementation, and write down what you like and what you don't like.

Looking at the code, it is improved, but there are still a number of things that I don't really like:
<ul>
	<li>I don't have a way to test my EmployeeSource class, so there is probably a trip to P/A/S coming up.</li>
	<li>I'm not really in love with Pipeline; I have an alternate approach in mind that I think will be better.</li>
	<li>The implementation of EmployeeSource has that ugly retry logic in it; that is something algorithmic that I hope can be teased out of the fetching.</li>
</ul>
Those will come up next time.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Agile and the Theory of Constraints - Part 2: The development cycle</title>
      <link>https://docs.microsoft.com/archive/blogs/ericgu/agile-and-the-theory-of-constraints-part-2-the-development-cycle</link>
      <pubDate>Tue, 17 May 2016 15:18:44 GMT</pubDate>
      <dc:creator><![CDATA[Eric Gunnerson]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericgu/?p=11985</guid>
      <description><![CDATA[In the last post, I talked about some of the analysis used in lean. Now, let’s see how we can apply...]]></description>
      <content:encoded><![CDATA[In the last post, I talked about some of the analysis used in lean. Now, let’s see how we can apply the same principles to the software world.

I will start by trying to create a value-stream map. But where to start? There are three levels at which we can do the mapping:
<ol>
 	<li>The entire organization, starting at the idea stage and going through the stage where we ship bits to customers.</li>
 	<li>The overall implementation of a feature/MBI/whatever by the development team.</li>
 	<li>The inner developer loop for a single story/feature/whatever by a single developer or pair.</li>
</ol>
I decided to start at #3, spent a lot of time writing, and then realized that the inner loop discussion depends a lot on the other ones, so I put that aside, and decided to start at the outside, with level #1. First issue solved...

I also need to decide what process I am going to map. I've worked in a number of different teams with very different processes, many of which I don't remember perfectly. So, instead of choosing a real team, I've decided to invent a composite team that is a bit more on the old-school side of things. Perhaps "old-school interested in building a new school" is a decent description.

The actual process of creating one of the is done through an interactive discussion with a number of people and is very customized to the way a particular organization works. Some of what I create here will not apply to you, so I've come up with two ways that might make it more useful for you.

First, I encourage you to draw your own diagram as you read through what I am saying - or perhaps as you read through it a second time. And second, I've added a few <strong>Question</strong> sections where you might want to think a bit about what your answer is before you read mine.

That said, let's dive in. Our organization builds software, and follows the following steps:
<ol>
 	<li>Enter Idea</li>
 	<li>Triage by priority</li>
 	<li>Feature estimation</li>
 	<li>Release planning</li>
 	<li>Create</li>
 	<li>Ship</li>
</ol>
Let’s put those into our first diagram:

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/dev1.jpg"><img class="alignnone wp-image-12036" src="https://msdnshared.blob.core.windows.net/media/2016/05/dev1.jpg" alt="dev1" width="1191" height="176" /></a>

Here's a little bit more information about the steps:
<h2>Enter idea</h2>
Somebody comes up with an idea, and we need to track it, so it gets entered into a system. This takes about 15 minutes per item.
<h2>Traige by priority</h2>
Once we have the ideas, we need to order them by priority so we know what the most important ones are. This is typically done by a small group of people who meet for a couple of hours every month.
<h2>Feature estimation</h2>
To be able to determine which features fit into the release, we need to know how big they are. We will ask the engineering team to do the estimation for us. Since we ask them to give us good estimates, it takes anywhere from 1 to 8 hours of work for them to do each estimate.
<h2>Release planning</h2>
Before we can start working on a new release, we need to figure out what features we are going to put into it. This is a very important function as it determines what we will invest in for the next release and there are lots of competing priorities, so we set up a release planning group and they spend a lot of time figuring out a draft plan, getting it reviewed, modifying it, rolling it out, etc. It takes about 100 hours for the group to do this, spread over a period of a couple of months.
<h2>Create</h2>
The engineering team takes the list of features, works through them, and creates the new version of the software. We are using a 2 year ship cycle, so this phase is that two years minus the overhead of planning and shipping, or about 20 months.
<h2>Ship</h2>
There are things that we need to finish at the end of the cycle; we do acceptance testing and fix the leftover important bugs and go through all the mechanics of putting together the full release. This takes about 2 months.

Let's add those times to the chart:

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/dev2.jpg"><img class="alignnone wp-image-12038" src="https://msdnshared.blob.core.windows.net/media/2016/05/dev2.jpg" alt="dev2" width="1194" height="240" /></a>

Something you may have noticed is that there are different kinds of times here; "Enter idea" and "Feature estimation" are per-item times, "Triage by priority" is a periodic short meeting, and the rest are just time boxes.

What's next? Well, those steps just don't feed directly from one to the next; we have inventory. And wow, we have a lot of it; so much that we give each set of inventory a name so we can tell them apart. We'll add the inventory with names and counts to the diagram:

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/dev3.jpg"><img class="alignnone wp-image-12046" src="https://msdnshared.blob.core.windows.net/media/2016/05/dev3.jpg" alt="dev3" width="1162" height="215" /></a>

These are numbers that I've seen for a small product group; one with 20 or so developers on it. They are conservative; I've seen examples where the number of prioritized features is well about 500.

There may be a way to express the timeboxed sections properly using the value-stream mapping nomenclature, but I don't know of one, so I'll stick to this approach.

Since we will be trying to determine how long it takes a item to move through our system, periodic processing poses a bit of a challenge; one item might get lucky and arrive on the day of the meeting, and another might get unlucky and arrive right after a meeting and have to wait for the next one. We'll therefore choose an average that is half of the cycle time.

Here's a little table of our average end-to-end time:
<table border="1">
<tbody>
<tr>
<th>Step</th>
<th>Inventory count</th>
<th>Elapsed time</th>
</tr>
<tr>
<td>Enter Idea</td>
<td>0</td>
<td>15 minutes</td>
</tr>
<tr>
<td>Triage by Priority</td>
<td>200</td>
<td>2 weeks</td>
</tr>
<tr>
<td>Feature Estimation</td>
<td>200</td>
<td>5 weeks</td>
</tr>
<tr>
<td>Release Planning</td>
<td>100</td>
<td>2 months</td>
</tr>
<tr>
<td>Create</td>
<td>50</td>
<td>20 months</td>
</tr>
<tr>
<td>Ship</td>
<td>50</td>
<td>2 months</td>
</tr>
<tr>
<th>Total</th>
<td></td>
<td>26 months</td>
</tr>
</tbody>
</table>
A little over two years for an idea to come in and make it through our system, which is about what we would expect for a 2 year cycle.
<h2>Where's the bottleneck?</h2>
<strong>Question:</strong> In our current system, where do you think the bottleneck lies?

<strong>Answer:</strong> Our analysis is a little complicated by the fact that many of our operations aren't full time, so let's focus on the Create and Ship steps. Let's express them as rates:

Create: 2.5 features/month

Ship: 25 features/month

So, creation is our bottleneck, which means I've spent a lot of words coming to the result everybody was expecting. Let's continue building the rest of our model to see if we get some more insight into what is going on.

Because of the long lead time - 26 months - this approach cannot be very responsive to changes in business climate or to needs that are discovered as part of the development process. There are different ways to address this; for this part of the discussion, we are going to choose one traditional way of getting there.

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/dev4.jpg"><img class="alignnone wp-image-12056" src="https://msdnshared.blob.core.windows.net/media/2016/05/dev4.jpg" alt="dev4" width="1188" height="348" /></a>

We've added a change request process, whereby we identify a small number of very-high-priority features and feed them into the middle of the create process, thereby getting better responsiveness. This feels like an agile and responsive thing to do, but in reality, it really doesn't help us a ton, for a couple of reasons:
<ul>
 	<li>The later a change request is injected in the cycle, the closer it is to shipping and therefore the shorter the time period is before it will show up as value to our customer, so we want to get the change requests in late.</li>
 	<li>The later a change request is injected in the cycle, the more disruptive it is to the development process, and the higher the priority that the ship date will slip, the change request will not be well-implemented, and the overall product will suffer more quality issues, so we want to get them early.</li>
</ul>
Or, to put it in ToC terms, adding additional destabilizing work to the bottleneck does not yield great results, for obvious reasons.

Pretty much everybody hates change requests, but they are viewed as a necessary evil under this model.
<h2>Quality</h2>
Our group creates a lot of bugs. Let's add them into our design:

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/dev5.jpg"><img class="alignnone wp-image-12065" src="https://msdnshared.blob.core.windows.net/media/2016/05/dev5.jpg" alt="dev5" width="1194" height="544" /></a>

This world of bugs is a complex one. There are weekly triages, bug bars, ship rooms, customer support interactions, service-level agreements, quick fix engineering, hotfixes, service packs, etc. <strong>Lots</strong> of process.

I spent a while diagramming the process with all of the detail, and quickly realized that if I wanted to include it in this diagram, I had to simplify it considerably, so this is a bare-bones representation. I am not including verification time for bugs, and I'm also not including loop-back for retriaging existing bugs or bugs that were marked as fixed but aren't, nor am I including regressions. All of which increase the time significantly.

&lt;aside&gt;

If you have a lot of bugs, I highly suggest trying to diagram what happens with bugs including the customer and all the teams that deal with bugs and all the steps you go through. I think it will be enlightening on how much those bugs are costing you.

&lt;/aside&gt;

So, anyway, we have two sources of bugs: bugs from the customer that come in from the left and bugs out of the current create step that come in from above. We triage them, and then they are fixed by our development team - the same group that is trying to do the create work. Then we either ship them as fixes to our previous product, or we feed the fixes back into the product under development. Or both.

The time the development team spends fixing bugs is time that they aren't spending on product work, or - in ToC terms - we have added another stream of work to our bottleneck. How does it affect the total time for an item to go through the system?

Well, if our team fixes 1000 bugs during this long cycle - and that's not an outlandish number - and they each take 4 hours to fix - also not an outlandish number, then we are spending 500 days of time on bug-fixing. A 20 month project for 10 developers is on the order of 4000 days, so it looks like we are spending around 12% of our time on bugs. Which really doesn't seem that bad, so we can probably ignore it.

However, if we have a lot of bugs external to the create step, there are also a lot of bugs internal to that step, which are costly. I'll defer that to the next post.

That completes the creation of our initial diagram. It's a simplification of the real world, but should server our purposes.
<h2>Talkin' 'bout Optimization</h2>
Now that we have identified the constraint, the first thing that we need to do is to exploit it. Which is one of the topics for the next post.

The problem that we have at this level is that we have a significant and very obvious problem - the problem of bugs - but we *have not* attempted to deal with it in the proper way, from within the development team.

<strong>Question for the class</strong>: Viewed through the lens of ToC, how would you describe the bug triage and fix system? What step does it belong to?

<strong>Answer: </strong>The whole bug flow is about both subordinating and elevating the constraint.

We have de-optized the process for our non-developers by introducing a new stream of work, which is handled by bug-fix orchestration technicians. They are in charge of looking at bugs, deciding which ones are important enough to fix, deciding when we should fix them, deciding who should fix them, tracking our progress on fixing them, predicting when all of them will be fixed. etc. etc. etc.

And, as this process is obviously costly, we introduce bug-fix orchestration *optimization* technicians, who are responsible for making the process faster. And bug-fix customer advocates, who liaison with the orchestration technicians to make sure that the customer impact of bugs is properly considered. And, in the ship step, we have bug fix coordination meetings, where we get together to make sure we are fixing the right bugs.

And much of this process is handled by our management, which means we are using our high-value assets towards this goal, instead of deploying them towards more strategic concerns.

And I'm still not done...

In my diagram, there's the section of bugfixing where we are fixing bugs in products that have already been shipped. This takes time away from the developers working on the current product, so we can elevate our constraint by setting up a separate process to handle bugfixing for shipped products.

We create a separate group that is only responsible for bugfixes in our current shipping product, staff it up, and that makes our main process faster. We call this group "sustained engineering". They are responsible for creating and managing service pack releases to fix the worst of our bugs.

<strong>Question: </strong>How effective are these approaches at reducing the effect of our constraint?

<b>Answer:</b> Not very. In fact, it can be argued that they make the problem worse.

To draw a manufacturing analogy...

We are building cars, and we have been noticing that when they come out of the paint shop, the doors consistently have some glops of paint on them. We also know that our customers are complaining about the door paint flaking off.

The paint shop is busy creating new doors and also has a lot of doors that need to be redone piled up outside, so we set up a group that looks at all the doors that failed our QC check, takes the ones that we think aren't bad enough to really bother the customer, and puts them back on the assembly line. Only the very bad doors go back to the paint shop. We look through this whole pile every few months, or at least most of it.

We have customers complaining about gloppy and flaking paint. We tell them that we don't normally fix those sorts of issues, but if they buy the special extended warranty package, they can get special access to our door fix technicians. We have a separate group who is in charge of doing that - once again, so we don't slow down the paint shop.

<strong> Question: </strong>Taking the ToC perspective, what are we missing?

<strong>Answer:</strong> We missed exploiting the constraint.

It is pretty clear that we have a <strong>massive</strong> rework problem; we are spending vast amounts of effort fixing issues that are come out of the create process, and it's so bad that we are ignoring a number of issues that our customers care about. But instead of exploiting the constraint, we are trying to mitigate it from the outside.

I will expand on the bug discussion in a future post, but I think there is an interesting parallel in the manufacturing world.

In the 1950s and 1960s, the US auto industry was quite successful at building products that didn't have great quality. Then, a bunch of imported cars showed up - cars built by companies that had adopted a very different view on quality, a view that, ironically, came mostly from a number of people from the US.

You probably know how that turned out; the US auto industry learned a painful lesson about trying to compete with companies that are using a better system.

The parallel to software is pretty obvious.

Enough about bugs for now, time to switch topics...
<h2>Risk</h2>
Risk is something that those of us in development teams really don't think too much about; that is mostly a topic for the business people. But I'd like to spend a little time on it here.

The two big risks that we need to worry about are:
<ul>
 	<li>Schedule risk - the risk that we will not be able to finish the project on the estimated schedule</li>
 	<li>Market risk - the risk that the features that we developed are not longer relevant to our market.</li>
</ul>
We have a problem with our 2-year cycle; that is quite a long period of time and it is well known that software estimates aren't very good, so we run a pretty good chance of either being late or having to cut features. Or both. And we have the list of bugs we need to fix, and regressions to fix, and we know that the time to fix bugs isn't terribly predictable.

There is also a large market risk; we know from our diagram that it takes 26 months for most features to make it through the pipeline, and though we can use change requests to be faster, it will generally only cut our cycle in half, and that's still fairly long.

This long cycle also requires a fairly large investment of money; a development team of 10 can easily cost $200,000 per month, so over the two years, we've put 24 * $200,000, or $4.8 million into the release.

In the theory of constraints, the bottleneck in the system isn't always something physical; sometimes it's a policy or choice made by the business. The 24-month cycle is an arbitrary one, and it is something that we could change.

If we pick a shorter approach, we can cut our schedule risk, cut our time to market, and cut our investment. Which seems like a total win to do.

How can we make this change the easiest and safest way? Well, we know how to plan in 2 months, and we know how to ship in 2 months. How about if we shrink the "create" part of the process down to two months, which will give us a 6-month overall cycle (2 months planning, 2 months create, 2 months shipping). Once we do a couple of those and get used to them, we will naturally find ways to cut down the planning part, and we can probably make the shipping part a bit faster as well.

This is a great idea, but it turns out that pretty much nobody does this, and here's the reason.

In our old system, we were devoting 20 months out of 24 to creating features (well, and bug fixes, but I'm ignoring that for now). If we go to a 6 month cycle, we only get two months worth of "create" in each cycle, for a total of 8 months every two years.

8 months of feature creation is much less than 20, so there is no chance we are going to adopt that approach, despite the fact that it gives us far faster time to market, much less risk, and is something that our team can <strong>demonstrably</strong> do successfully.

What teams generally do is go for a linear reduction; our 6 month cycle becomes 2 weeks planning, 20 weeks coding, and 2 weeks shipping. Planning works fine - it's easier, in fact - and development starts the way it always done, and then - as the ship portion approaches - the team realizes the following:
<ul>
 	<li>They aren't quite done with their features.</li>
 	<li>They have a lot of bugs to fix</li>
 	<li>All their processes were designed to work in a two-month-long ship step.</li>
 	<li>They have absolutely no idea how to ship in two weeks.</li>
</ul>
Their options are:
<ol>
 	<li>Delay shipping.</li>
 	<li>Cut corners</li>
</ol>
The team generally picks a combination of these. And then, they turn right around and start the next cycle.

There's another bit of organizational psychology going on here. In a lot of US companies, being bold, aggressive, and making big bets is encouraged and rewarded. That is why we see re-org after re-org; we are <strong>doing something significant</strong>.

This makes little sense to me. From the agile and lean perspective, we want continuous improvement, because that is the path where the risk is minimized. There is very likely a path that takes the team from a 2-year cycle to a great 6-month, 3-month, or even 1-month cycle, but it's very clear that you cannot get there just by decree.

That's all for this post. In the next one, we are going to crack open the create process and see what's inside.

<a href="https://blogs.msdn.microsoft.com/ericgu/2017/02/23/agile-and-the-theory-of-constraints-part-3-the-development-team-1/">Part 3 - The Development Team (1)</a>]]></content:encoded>
    </item>
  </channel>
</rss>