<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Emmanuel Genard</title>
    <description>The latest articles on DEV Community by Emmanuel Genard (@edgenard).</description>
    <link>https://dev.to/edgenard</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F361488%2F4c7d058b-12bb-44dc-aae9-0fbbb105a7dc.jpeg</url>
      <title>DEV Community: Emmanuel Genard</title>
      <link>https://dev.to/edgenard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/edgenard"/>
    <language>en</language>
    <item>
      <title>Chapter 5: Franc-ly Speaking</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Sun, 28 Jun 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/edgenard/chapter-5-franc-ly-speaking-331j</link>
      <guid>https://dev.to/edgenard/chapter-5-franc-ly-speaking-331j</guid>
      <description>&lt;h1&gt;
  
  
  Chapter 5: Franc-ly Speaking
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Beck wants to implement multi-currency multiplication but can't because we only have one currency implemented, &lt;code&gt;Dollar&lt;/code&gt;. So in this chapter he does a quick and dirty implementation of &lt;code&gt;Franc&lt;/code&gt;. He copies the code in &lt;code&gt;Dollar&lt;/code&gt; and renames the class &lt;code&gt;Franc&lt;/code&gt;. Beck acknowledges that most programmers would consider this bad code but makes the case the the first goal is to get a green test. Once you have a green test, you can then improve the design with a refactoring.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Good design at good times. Make it run, make it right.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This quote by Beck reminds me something I've heard about writing: "The only kind of writing is rewriting". It's supposedly from Ernest Hemingway. Writing is about getting something, anything, down and then working it until it's good. I think Beck is advocating the same thing for writing programs. You could say that he thinks clean code is &lt;em&gt;cleaned&lt;/em&gt; code.&lt;/p&gt;

&lt;p&gt;However, I almost never see this attitude. In my experience there is an expectation of a good design immediately. I feel this pressure almost every time. Every time I try to make it run then make it right, I feel like I'm doing something wrong. There seems to be an unstated norm that a good programmer is able to do a good design right away. This maybe some imposter syndrome on my part or some other projection of my fears and insecurities. Nonetheless it feels risky not not make it right, right away.&lt;/p&gt;

&lt;p&gt;I think another reason is that I don't always know when I have a good or bad design. When is the code clean? When is it OK to leave it a little dirty? How do I know when to insist on squeaky clean and when not to? I tend to just do what feels right. I settle for "good enough" but I have many different versions of "good enough".&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Good design at good times. Make it run, make it right.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What is a good design? When is it a good time? What makes it right?&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>kentbeck</category>
      <category>book</category>
    </item>
    <item>
      <title>Chapter 4: Privacy</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Sun, 07 Jun 2020 23:29:01 +0000</pubDate>
      <link>https://dev.to/edgenard/chapter-4-privacy-2b6o</link>
      <guid>https://dev.to/edgenard/chapter-4-privacy-2b6o</guid>
      <description>&lt;h1&gt;
  
  
  Chapter 4: Privacy
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is a short chapter that cleans up after the refactoring in the previous chapter. Beck refactors the multiplication test to make it clear that the &lt;code&gt;times&lt;/code&gt; method returns a new instance of the &lt;code&gt;Dollar&lt;/code&gt; object. &lt;/p&gt;

&lt;p&gt;He goes from this test &lt;/p&gt;

&lt;p&gt;public void testMultiplication() {&lt;br&gt;
    Dollar five = new Dollar(5);&lt;br&gt;
    Dollar product = five.times(2);&lt;br&gt;
    assertEquals(10, product.amount);&lt;br&gt;
    product = five.times(3);&lt;br&gt;
    assertEquals(15, product.amount);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;which checks against the primitive numbers 10 and 15. &lt;/p&gt;

&lt;p&gt;To this test&lt;/p&gt;

&lt;p&gt;public void testMultiplication() {&lt;br&gt;
    Dollar five = new Dollar(5);&lt;br&gt;
    assertEquals(new Dollar(10), five.times(2));&lt;br&gt;
    assertEquals(new Dollar(15), five.times(3));&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;which compares the result of the multiplication with new instances of &lt;code&gt;Dollar&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This change is made possible because of the implementation of &lt;code&gt;equals&lt;/code&gt; in &lt;code&gt;Dollar&lt;/code&gt;. It also allows the instance variable &lt;code&gt;amount&lt;/code&gt; to be made private since it is no longer referenced outside of &lt;code&gt;Dollar&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Beck notes that this refactoring does a better job of expressing intent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This test speaks to us more clearly, as if it were an assertion of truth, not a sequence of operations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The rest of the chapter is about the tradeoff of TDD. He argues that TDD is not about perfect code but about having enough confidence with the code you've written to move forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;I think this chapter has two important ideas that are not talked about enough when discussing TDD. The refactoring of a test. The tradeoff of TDD.&lt;/p&gt;

&lt;p&gt;The refactoring of tests is not emphasized in most of the writing about TDD. I've seen its importance in practice but there isn't much guidance on how to do it and when to do it. Beck does it here because the tests no longer express the intent of the code. This is a good heuristic but understanding when the tests no longer express the intent of the code is not always obvious. Other reasons I've refactored tests are, they don't provide any value, they are coupled to an implementation, or they are unreliable. &lt;/p&gt;

&lt;p&gt;When tests are coupled to an implementation it is usually easy to spot. You write code that does the same thing in a different way but the tests fail. It can even be explicit duplication between the tests and the code. When tests are unreliable every test run is exciting. You don't know whether they will pass or fail even though you haven't changed any code. Value can be harder to determine. Sometimes the test tests something covered elsewhere. Sometimes it's the wrong test. Sometimes it's not important in the context of the domain. Sometimes the effort of maintaining the test is not worth it. These are a few of the things form my experience, I think there is a big opportunity in helping programmers evaluate and improve the quality of their tests.&lt;/p&gt;

&lt;p&gt;The tradeoff of TDD is summarized beautifully by Beck.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By saying everything two ways—both as code and as tests—we hope to reduce our defects enough to move forward with confidence. From time to time our reasoning will fail us and a defect will slip through. When that happens, we learn our lesson about the test we should have written and move on. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's not about preventing all mistakes. It's about lessening the chance mistakes. Like refactoring tests I think this is something that is under-emphasized in the discussions about TDD. It is not a silver bullet. I think "we hope to reduce our defects enough to move forward with confidence" should be mentioned anytime someone mentions TDD. The point is not to be good at TDD, the point is to write good software. TDD is a tool that can help you write good software. &lt;/p&gt;

&lt;p&gt;An interesting question is what counts as "good" software?&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>testing</category>
      <category>kentbeck</category>
      <category>books</category>
    </item>
    <item>
      <title>Chapter 3: Equality For All</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Sun, 24 May 2020 14:42:29 +0000</pubDate>
      <link>https://dev.to/edgenard/chapter-3-equality-for-all-ogm</link>
      <guid>https://dev.to/edgenard/chapter-3-equality-for-all-ogm</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Beck starts the chapter by introducing the concept of a value object. A value object cannot be mutated and so any message that changes the "value" in a value object should produce a new object.  &lt;code&gt;Dollar&lt;/code&gt; is on its way to becoming a value object. The refactoring in the previous chapter made the &lt;code&gt;times&lt;/code&gt; method return a new &lt;code&gt;Dollar&lt;/code&gt; object instead of mutating the &lt;code&gt;amount&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Another property of a value object is responding to &lt;code&gt;equals&lt;/code&gt;. This makes it comparable to other value objects of the same class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testEquality&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;He first implements equals by hardcoding the return value of &lt;code&gt;equals&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;object&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;He uses this as an opportunity to introduce &lt;em&gt;triangulation&lt;/em&gt;.&lt;br&gt;
Triangulation is adding a test to drive you towards a refactoring. A refactoring to a more generalized implementation. It's another tactic you can use when following the strategy of first making things work and then making things right. Beck says triangulation is useful when the refactoring is not obvious.&lt;/p&gt;

&lt;p&gt;The second test is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testEquality&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;
    &lt;span class="n"&gt;assertFalse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;)));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;He finishes by implementing a more generalized &lt;code&gt;equals&lt;/code&gt;. He postpones implementing other properties of value objects because they are not immediately necessary, but he adds those things to his test list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;This chapter seems to be a way for Beck to introduce triangulation. However, he makes a few casual remarks that stood out to me. &lt;/p&gt;

&lt;p&gt;In trying to explain the value of using triangulation he asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What axes of variability are you trying to support in your design?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think this is a question that has many levels. There is the level of comparing instances of &lt;code&gt;Dollar&lt;/code&gt;. There is the level of trying to add support for multiple currencies. There is another level of the whole WyCash bond portfolio management system. But I can only say "I think" because Beck does not offer any more explanation. Maybe it's just about comparing instances of &lt;code&gt;Dollar&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Another remark is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;That will let us make “amount” private, as all good instance variables should be&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why should instance variables be private? What makes that a better design? He continually drops lines like this as if the reader shares his context. It's one of the most frustrating parts of the book.&lt;/p&gt;

&lt;p&gt;Beck could not have known that the book would be read by people who don't share his background or sensibilities. Programming wasn't as a big an industry as it was when he wrote the book and there weren't so many different people trying to become better programmers. This makes the book difficult for people without some background in the design ideas that he uses to navigate towards an implementation.&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>books</category>
      <category>testing</category>
    </item>
    <item>
      <title>Chapter 2: Degenerate Objects</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Sun, 17 May 2020 22:21:38 +0000</pubDate>
      <link>https://dev.to/edgenard/chapter-2-degenerate-objects-1mgj</link>
      <guid>https://dev.to/edgenard/chapter-2-degenerate-objects-1mgj</guid>
      <description>&lt;h1&gt;
  
  
  TDD by Example: Chapter 2 Degenerate Objects
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The chapter starts off with a summary of the "general TDD cycle". My summary of that summary is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write a test so your code has the API you want it to have.&lt;/li&gt;
&lt;li&gt;Get the test to green as fast as possible. Don't worry about "clean code" or "design".&lt;/li&gt;
&lt;li&gt;Improve the design of the code while keeping the tests green. Otherwise known as refactoring.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;He explains that the idea behind these three steps is to reduce the cognitive load on the programmer. First get the code to work, then worry about how it's designed.  This approach is in contrast to what he calls "architecture-driven development" which focuses on the design of the code first and then tries to get it to work.&lt;/p&gt;

&lt;p&gt;He puts the ideas into practice using them to remove the side effects from the &lt;code&gt;Dollar&lt;/code&gt; object that mutates the value of the &lt;code&gt;amount&lt;/code&gt; property. He writes a test that passes if multiplying a &lt;code&gt;Dollar&lt;/code&gt; object returned a new instance of &lt;code&gt;Dollar&lt;/code&gt; whose &lt;code&gt;amount&lt;/code&gt; is the result of the multiplication.&lt;/p&gt;

&lt;p&gt;He changes the test from this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testMultiplication&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Dollar&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;times&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;times&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testMultiplication&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Dollar&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dollar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;Dollar&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;times&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;times&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;He then introduces two tactics for quickly getting the tests to pass, hardcoding and implementation and doing the obvious thing. Hardcoding an implementation means that you write something to just get the tests to green. You then refactor the code into a real implementation while keeping the tests green. Doing the obvious thing is used when the real implementation is obvious to you. These are the two main tactics used by Beck. He mentions a third tactic, Triangulation, that will be explained in the following chapter.&lt;/p&gt;

&lt;p&gt;The chapter ends with a paragraph talking about using your feelings to guide you. Beck used the feeling of something being wrong with the code to write a test that exposes the underlying reason for the feeling. Getting the test to pass made him feel better and improved the design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;There is one great thing about this chapter and two problematic things.&lt;/p&gt;

&lt;p&gt;I think the restatement of the TDD cycle and the example that followed is great. Repetition of the steps of TDD in a different way helped my understanding. I hope he does this many more times throughout the book.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The goal is clean code that works (thanks to Ron Jeffries for this pithy summary). Clean code that works is out of the reach of even the best programmers some of the time, and out of the reach of most programmers (like me) most of the time. Divide and conquer, baby. First we'll solve the “that works” part of the problem. Then we'll solve the “clean code” part.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think this quote captures the power of TDD as a design tool. By writing the test, getting it to past and then worrying about the design of the code, you can be sure that your design works as longs the tests still pass.&lt;/p&gt;

&lt;p&gt;The problems start right after:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is the opposite of architecture-driven development, where you solve “clean code” first, then scramble around trying to integrate into the design the things you learn as you solve the “that works” problem.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes you need to think about the problem before writing any code. And one of the best tools for thinking is drawing. It externalizes your thoughts and helps you see the problem at a different level of abstraction. It is also faster feedback than writing code. I don't know if drawing a UML diagram or any other type of diagram is what Beck means by "architecture-driven development". He doesn't explain it. He just takes a passing shot.&lt;/p&gt;

&lt;p&gt;In my experience, if I can represent the problem or different solutions to the problem at a different level of abstraction this can lead to insights that are difficult to see when down in the code. A diagram can help answer the question, "What tests should I write?" or "Where should I start?".  It's also much cheaper to explore different approaches with drawings than with code. You can just erase a whiteboard or throw out a piece of paper.&lt;/p&gt;

&lt;p&gt;The other thing I have a problem is this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The translation of a feeling (for example, disgust at side effects) into a test (for example, multiply the same Dollar twice) is a common theme of TDD.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When he was writing this book Beck was already an expert at programming and at TDD. He had been doing both long enough to have built up an intuition. He could feel when something was wrong. A person just learning will not have that intuition. I think it would have been a more useful for a wider range of people if he took the time to point out exactly what was wrong with the design. Implying that anyone reading this book can go off a feeling, especially the same feelings he has, is something that can alienate the readers.&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>kentbeck</category>
    </item>
    <item>
      <title>TDD By Example: Chapter 1 Multi-Currency Money</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Thu, 16 Apr 2020 01:51:17 +0000</pubDate>
      <link>https://dev.to/edgenard/tdd-by-example-chapter-1-multi-currency-money-gpo</link>
      <guid>https://dev.to/edgenard/tdd-by-example-chapter-1-multi-currency-money-gpo</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The first part of this chapter Beck gathers requirements and starts to define the acceptance criteria. He doesn't call what he does by those names but when he writes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What behavior will we need to produce the revised report? Put another way, what set of tests, when passed, will demonstrate the presence of code we are confident will compute the report correctly?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think he is talking about putting the requirements for the code into the tests.&lt;/p&gt;

&lt;p&gt;He describes that he is going to put everything he needs to do on a list. He is going to focus on one thing at a time. He will add things to the list as they come up. &lt;/p&gt;

&lt;p&gt;We start to understand one of the main tactics of TDD.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When we write a test, we imagine the perfect interface for our operation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He writes the test so that code has the API he wants it to have. He then gets the test to green as fast as he can. One of the most important things in TDD is to get to a passing test as fast as possible.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You probably aren't going to like the solution, but the goal right now is not to get the perfect answer but to pass the test. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The TDD cycle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Add a little test.

&lt;ol&gt;
&lt;li&gt;Run all tests and fail.&lt;/li&gt;
&lt;li&gt;Make a little change.&lt;/li&gt;
&lt;li&gt;Run the tests and succeed.&lt;/li&gt;
&lt;li&gt;Refactor to remove duplication.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is a sidebar on "Dependency and Duplication". He mentions that dependencies are the key problem in software at all scales and that the key to removing dependencies is remove duplication. &lt;/p&gt;

&lt;p&gt;There is now a refactoring where duplication is removed in very small steps.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Do these steps seem too small to you? Remember, TDD is not about taking teeny-tiny steps, it's about being able to take teeny-tiny steps. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;I think the sidebar on dependency and duplication is the most interesting thing in the chapter. When he writes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dependency is the key problem in software development at all scales.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;my eyes stop.&lt;/p&gt;

&lt;p&gt;I wonder if that's true. I think about on my own experience and I feel like there is some truth to it. But could it really be the "key" problem? And can the answer to the "key" problem be as simple finding duplication and removing it?&lt;/p&gt;

&lt;p&gt;I have these questions in my mind as I read on. Some part of me feels like there is a lot truth to that statement. Some part of me feels that there are much more pressing problems, like building trust on a team.&lt;/p&gt;

&lt;p&gt;The rest of the chapter is a good introduction to the technique of TDD. Beck emphasizes small focused steps. I appreciate that approach more and more in my day to day work. I'm starting to feel that I actually move faster taking as small a step as possible. &lt;/p&gt;

</description>
      <category>tdd</category>
      <category>kentbeck</category>
    </item>
    <item>
      <title>TDD by Example: Part 1: The Money Example</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Tue, 14 Apr 2020 17:32:11 +0000</pubDate>
      <link>https://dev.to/edgenard/tdd-by-example-part-1-the-money-example-397i</link>
      <guid>https://dev.to/edgenard/tdd-by-example-part-1-the-money-example-397i</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Beck opens this part of the book giving a summary of what to expect. He lays out the rhythm of TDD and what the reader will find surprising. There isn't much to summarize here so I'll just quote him.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Quickly add a test.&lt;/li&gt;
&lt;li&gt;Run all tests and see the new one fail.&lt;/li&gt;
&lt;li&gt;Make a little change.&lt;/li&gt;
&lt;li&gt;Run all tests and see them all succeed.&lt;/li&gt;
&lt;li&gt;Refactor to remove duplication.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The surprises are likely to include&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How each test can cover a small increment of functionality&lt;/li&gt;
&lt;li&gt;How small and ugly the changes can be to make the new tests run

&lt;ul&gt;
&lt;li&gt;How often the tests are run&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;How many teensy-weensy steps make up the refactorings&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;These seem simple enough and self explanatory. I didn't think I would have any thoughts other than, "Let's start!". But then I remembered how often I've tried to add a test and had no idea what to do. &lt;/p&gt;

&lt;p&gt;I don't see:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to know what test to write&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I think step 0 could be the most important. It would help answer not just what the next test is but how many there are and what they cover. It might help answer what kind of test to write. Which would probably be lead to: &lt;/p&gt;

&lt;p&gt;-1. The many kinds of tests and what they cover.&lt;/p&gt;

&lt;p&gt;But it's likely that those two steps would require a different book.&lt;/p&gt;

</description>
      <category>tdd</category>
      <category>kentbeck</category>
    </item>
    <item>
      <title>TDD by Example: Introduction</title>
      <dc:creator>Emmanuel Genard</dc:creator>
      <pubDate>Sun, 12 Apr 2020 23:52:37 +0000</pubDate>
      <link>https://dev.to/edgenard/tdd-by-example-introduction-29d1</link>
      <guid>https://dev.to/edgenard/tdd-by-example-introduction-29d1</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Beck tells a story. It starts with an unexpected new requirement. The CEO of the company they work for asks if the bond portfolio management system the company is selling could be changed to support multiple currencies. Ward Cunningham gets a couple of days to think about it. &lt;br&gt;
The &lt;code&gt;Dollar&lt;/code&gt; object originally had calculation and formatting responsibilities but those have been refactored away. The built-in classes of Smalltalk could handle the calculations. The formatting was done in the user interface classes. The &lt;code&gt;Dollar&lt;/code&gt; object is just used as a counter in calculating something in the user interface that deals with averages. He tries to substitute &lt;code&gt;Currency&lt;/code&gt; for &lt;code&gt;Dollar&lt;/code&gt; and finds that it can support it. He then tries to see what happens if the currencies being calculated are different and finds that can also be supported. He runs the tests and after fixing a few failing tests he checks in the code.&lt;/p&gt;

&lt;p&gt;Beck analyses the story. When the system was proved to be able to support multiple currencies, it multiplied the value of the system and thus the company that was selling it. This was because Ward Cunningham and his team were experienced making changes to the design of the system, they understood how valuable it would be to the business if they were able to make the system multi-currency, and automatic tests and good separation of concerns allowed them to make changes and have the confidence that their whole system still worked.&lt;/p&gt;

&lt;p&gt;Beck then says that this kind of progress is possible for most programmers, except for geniuses(they do not need any method) and idiots(no method will help them). If they follow these two simple rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write a failing test before you write any code

&lt;ol&gt;
&lt;li&gt;Remove duplication&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The rest of the book is about how complicated it can be to follow those two simple rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commentary
&lt;/h2&gt;

&lt;p&gt;It's a neat story. The good programmer because of his good programming has made a system that can respond to unexpected requirements from the business and deliver features that multiply business value. &lt;/p&gt;

&lt;p&gt;The thing that sticks out to me is that are lines like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;After six months of careful paring, the resulting Dollar didn't have much responsibility left.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ward and the WyCash team needed to have constant experience growing the design of the system, little by little, so the mechanics of the transformation were well practiced.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These quotes tell me of an almost ideal work environment for programming. One where you can spend six months carefully refactoring essential parts. One where your whole team believes this kind of thing is worth improving. One where the business stakeholders see the value in this. &lt;/p&gt;

&lt;p&gt;Beck acknowledges my skepticism when he says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does this mean that if you are not one of the ten best software engineers on the planet and don't have a wad of cash in the bank so you can tell your boss to take a hike, then you're going to take the time to do this right, that such moments are forever beyond your reach?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think about what is within my reach. If I'm pairing with somebody I may not be able always convince them to write a failing test first but I can always suggest it. And when I'm programming solo I can always do it. I may not always have the time to work on removing duplication, especially if it's not obvious duplication. I may not know enough of the domain to understand that the same concept is being encoded in two different places.&lt;/p&gt;

&lt;p&gt;If I do these things maybe one day I can tell a neat story too. I was a good programmer and because of my good programming I made a system that can respond to unexpected requirements from the business and deliver features that multiply business value. &lt;/p&gt;

</description>
      <category>tdd</category>
      <category>kentbeck</category>
    </item>
  </channel>
</rss>
