<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Xavier Balloy</title>
    <subtitle>A software engineer sharing thoughts on code quality, conferences, and continuous learning.</subtitle>
    <link href="https://xballoy.github.io/tags/tdd/feed.xml" rel="self" type="application/atom+xml"/>
    <link href="2019-11-15T00:00:00+00:00"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2019-11-15T00:00:00+00:00</updated>
    <id>https://xballoy.github.io/tags/tdd/feed.xml</id>
    <author>
        <name>Xavier Balloy</name>
    </author>
    <entry xml:lang="en">
        <title>Back from SoCraTes France 2019</title>
        <published>2019-11-15T00:00:00+00:00</published>
        <updated>2019-11-15T00:00:00+00:00</updated>
        <author>
            <name>Xavier Balloy</name>
        </author>
        <link rel="alternate" type="text/html" href="https://xballoy.github.io/blog/socrates-france-2019/"/>
        <id>https://xballoy.github.io/blog/socrates-france-2019/</id>
        <summary type="html">&lt;p&gt;From October 17 to 20, one of the key events in the &lt;em&gt;software craftsmanship&lt;&#x2F;em&gt;
movement took place in France. SoCraTes-FR describes itself as an unconference
— it&#x27;s more of a retreat than a traditional conference.&lt;&#x2F;p&gt;</summary>
        <content type="html" xml:base="https://xballoy.github.io/blog/socrates-france-2019/">&lt;p&gt;From October 17 to 20, one of the key events in the &lt;em&gt;software craftsmanship&lt;&#x2F;em&gt;
movement took place in France. SoCraTes-FR describes itself as an unconference
— it&#x27;s more of a retreat than a traditional conference.&lt;&#x2F;p&gt;
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;




&lt;img src=&quot;https:&amp;#x2F;&amp;#x2F;xballoy.github.io&amp;#x2F;processed_images&amp;#x2F;2019-11-15-socrates-france-2019-1.e39d17fc1737d75d.webp&quot; alt=&quot;Château de Massillan, where SoCraTes-FR 2019 was held&quot; width=&quot;800&quot; height=&quot;526&quot; loading=&quot;lazy&quot; &#x2F;&gt;
&lt;p&gt;The agenda isn&#x27;t known in advance. Instead, it takes shape each morning from the
many workshop proposals that everyone is encouraged to submit. The October 18
agenda — so hard to choose with this many options!&lt;&#x2F;p&gt;





&lt;img src=&quot;https:&amp;#x2F;&amp;#x2F;xballoy.github.io&amp;#x2F;processed_images&amp;#x2F;2019-11-15-socrates-france-2019-2.3a4991409151e456.webp&quot; alt=&quot;The October 18 agenda — so hard to choose with this many options!&quot; width=&quot;800&quot; height=&quot;600&quot; loading=&quot;lazy&quot; &#x2F;&gt;
&lt;p&gt;Software quality is part of AXA&#x27;s DNA, so it was natural for us to sponsor the
event and send our developers. I was lucky enough to attend and discuss a wide
range of topics — from DDD to code reviews, green IT, and many katas.&lt;&#x2F;p&gt;
&lt;p&gt;Here are some highlights from the discussions I had over those four days.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;code-reviews&quot;&gt;Code Reviews&lt;&#x2F;h2&gt;
&lt;p&gt;I didn&#x27;t expect code reviews to spark such intense discussions. To me, it&#x27;s
something everyone does as part of best practices when striving to improve
software quality.&lt;&#x2F;p&gt;
&lt;p&gt;But no! Even code reviews have their detractors.&lt;&#x2F;p&gt;
&lt;p&gt;Their main argument is that reviews are usually done poorly. For example,
reviewers don&#x27;t pull the code locally — they just skim through it during a
&lt;em&gt;pull request&lt;&#x2F;em&gt; or when someone presents code to them. In the end, reviews only
catch naming issues, typos, formatting problems, or obvious bugs.&lt;&#x2F;p&gt;
&lt;p&gt;Meanwhile, reviewers rarely question the business logic being implemented,
partly because &lt;strong&gt;the whole team&lt;&#x2F;strong&gt; doesn&#x27;t know every feature in detail. Worse,
the level of scrutiny varies based on trust in the author! We tend to trust
someone who&#x27;s been on the team longer and makes fewer mistakes.&lt;&#x2F;p&gt;
&lt;p&gt;Given this reality, some companies have stopped doing code reviews altogether,
opting instead for much more &lt;em&gt;pair programming&lt;&#x2F;em&gt; and &lt;em&gt;mob programming&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;pair-programming&quot;&gt;Pair Programming&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;em&gt;Pair programming&lt;&#x2F;em&gt; is a working method where two developers work together at the
same workstation.&lt;&#x2F;p&gt;
&lt;p&gt;This technique proves useful for newcomers (whether experienced or junior) to
learn the team&#x27;s working methods and established best practices. It also avoids
the potential back-and-forth of early &lt;em&gt;pull requests&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Those back-and-forths are counterproductive: the same code gets reviewed
multiple times, development stalls, and the developer may feel frustrated or
take comments personally. Once this &lt;em&gt;pair programming&lt;&#x2F;em&gt; phase ends — which can be
seen as mentoring and typically lasts several weeks — you can trust these people
and stop reviewing their code entirely (or at least not every line).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;mob-programming&quot;&gt;Mob Programming&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;em&gt;Mob programming&lt;&#x2F;em&gt; is similar to &lt;em&gt;pair programming&lt;&#x2F;em&gt;, except the entire team works
on the same feature! One key advantage is that the whole team shares both
business knowledge and code ownership. You&#x27;ll never hear &quot;That&#x27;s not my
code&#x2F;bug, it&#x27;s Paul&#x27;s&quot; or &quot;Who worked on this feature?&quot; anymore. Since the code
is written collaboratively, it&#x27;s higher quality and doesn&#x27;t need review
afterward.&lt;&#x2F;p&gt;
&lt;p&gt;




&lt;img src=&quot;https:&amp;#x2F;&amp;#x2F;xballoy.github.io&amp;#x2F;processed_images&amp;#x2F;2019-11-15-socrates-france-2019-3.477ea529840b06ac.webp&quot; alt=&quot;mob programming&quot; width=&quot;800&quot; height=&quot;608&quot; loading=&quot;lazy&quot; &#x2F;&gt;

Doing &lt;em&gt;mob programming&lt;&#x2F;em&gt; is like &lt;em&gt;pair programming&lt;&#x2F;em&gt; to the power of n — meaning
you get sustainable code. — Someone during a discussion at SoCraTes&lt;&#x2F;p&gt;
&lt;h2 id=&quot;katas&quot;&gt;Katas&lt;&#x2F;h2&gt;
&lt;p&gt;During this event, I practiced several katas that helped me discover a new
language (Haskell) and new ways of coding. A code kata is a development exercise that
helps you hone your skills through practice and repetition.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re interested, here are the katas I practiced:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;codingdojo.org&#x2F;kata&#x2F;FizzBuzz&#x2F;&quot;&gt;FizzBuzz&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;codingdojo.org&#x2F;kata&#x2F;RPN&#x2F;&quot;&gt;RPN Calculator&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;codingdojo.org&#x2F;kata&#x2F;RomanNumerals&#x2F;&quot;&gt;Roman Numerals&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;tcr-instead-of-tdd&quot;&gt;TCR Instead of TDD&lt;&#x2F;h3&gt;
&lt;p&gt;I had the chance to try TCR, an acronym for test &amp;amp;&amp;amp; &lt;em&gt;commit&lt;&#x2F;em&gt; || &lt;em&gt;revert&lt;&#x2F;em&gt;. It&#x27;s a
programming method proposed by
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;medium.com&#x2F;@kentbeck_7670&#x2F;test-commit-revert-870bbd756864&quot;&gt;Kent Beck&lt;&#x2F;a&gt;
(the inventor of TDD). The principle: when you run tests, if they fail, you
&lt;em&gt;revert&lt;&#x2F;em&gt; your code!&lt;&#x2F;p&gt;
&lt;p&gt;We applied a slightly less extreme version during the kata. Before running
tests, we&#x27;d bet on whether they&#x27;d pass or not. If we won the bet, we&#x27;d &lt;em&gt;commit&lt;&#x2F;em&gt;;
otherwise, we&#x27;d &lt;em&gt;revert&lt;&#x2F;em&gt;. This approach still lets you go through the &quot;red bar&quot;
phase where you see failing tests.&lt;&#x2F;p&gt;
&lt;p&gt;I preferred this approach. You spend less time &quot;running tests in your head&quot; to
avoid seeing all your code (including the latest test) disappear. Most
importantly, you keep the benefit of seeing your tests fail before they pass —
which I consider a crucial part of the TDD I practice daily.&lt;&#x2F;p&gt;
&lt;p&gt;However, TCR does force you to go through the obvious implementation phase of
the test (bet it&#x27;ll be green, commit) before refactoring (if it doesn&#x27;t work,
&lt;em&gt;revert&lt;&#x2F;em&gt; and return to a working state).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;fish-bowl-mob-programming&quot;&gt;Fish Bowl Mob Programming&lt;&#x2F;h3&gt;
&lt;p&gt;Before SoCraTes, I&#x27;d heard of &lt;em&gt;mob programming&lt;&#x2F;em&gt; but had never tried it. During
one kata, we experimented with a specific facilitation technique for &lt;em&gt;mob
programming&lt;&#x2F;em&gt;: the fish bowl.&lt;&#x2F;p&gt;
&lt;p&gt;The rules are fairly simple:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;A driver has the keyboard. They &lt;strong&gt;only&lt;&#x2F;strong&gt; code and don&#x27;t make decisions.&lt;&#x2F;li&gt;
&lt;li&gt;A navigator tells the driver what to do. They&#x27;re the &lt;strong&gt;only&lt;&#x2F;strong&gt; one speaking.&lt;&#x2F;li&gt;
&lt;li&gt;One chair is open for &lt;strong&gt;questions&lt;&#x2F;strong&gt;. But beware — only questions to better
understand the code (e.g., an unfamiliar syntax) or the business logic. You
can&#x27;t ask questions like &quot;Why are we doing it this way?&quot; — in that case, you
take the navigator&#x27;s seat!&lt;&#x2F;li&gt;
&lt;li&gt;Everyone else stays &lt;strong&gt;silent&lt;&#x2F;strong&gt; and can take the driver&#x27;s or navigator&#x27;s place
at any moment.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I really liked this technique for &lt;em&gt;mob programming&lt;&#x2F;em&gt; because it prevents the
chaos that can arise when everyone tries to code at once. In those situations,
the driver doesn&#x27;t know what to do, and it&#x27;s hard to make progress.&lt;&#x2F;p&gt;
&lt;p&gt;Since the event, I&#x27;ve tested this technique during a kata and the format was
well received. However, like other techniques, I think you need to practice it
first before using it daily on production code.&lt;&#x2F;p&gt;
</content>
    </entry>
    <entry xml:lang="en">
        <title>My Global Day of Code Retreat 2017</title>
        <published>2017-11-19T00:00:00+00:00</published>
        <updated>2017-11-19T00:00:00+00:00</updated>
        <author>
            <name>Xavier Balloy</name>
        </author>
        <link rel="alternate" type="text/html" href="https://xballoy.github.io/blog/my-global-day-of-code-retreat-2017/"/>
        <id>https://xballoy.github.io/blog/my-global-day-of-code-retreat-2017/</id>
        <summary type="html">&lt;p&gt;My takeaway from the Global Day of Code Retreat 2017.&lt;&#x2F;p&gt;</summary>
        <content type="html" xml:base="https://xballoy.github.io/blog/my-global-day-of-code-retreat-2017/">&lt;p&gt;My takeaway from the Global Day of Code Retreat 2017.&lt;&#x2F;p&gt;
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;




&lt;img src=&quot;https:&amp;#x2F;&amp;#x2F;xballoy.github.io&amp;#x2F;processed_images&amp;#x2F;2017-11-19-my-global-day-of-code-retreat-2017-1.8642469879a066a3.webp&quot; alt=&quot;Picture of the Global Day of Code Retreat at AXA&quot; width=&quot;800&quot; height=&quot;600&quot; loading=&quot;lazy&quot; &#x2F;&gt;
&lt;p&gt;Last Saturday, I attended
the &lt;a rel=&quot;external&quot; href=&quot;http:&#x2F;&#x2F;coderetreat.org&#x2F;&quot;&gt;Global Day of Code Retreat&lt;&#x2F;a&gt; hosted at AXA
WebCenter (Lille, France). A code retreat is an event where you can perfect the
way you write code, design your application, learn new ways of coding... Unlike
in your everyday job, the final goal is not to finish the exercise but to
improve your skills! During this
event &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ToF_&quot;&gt;Christophe Thibaut&lt;&#x2F;a&gt; was our facilitator. It was
his first time as a facilitator but he was so good no one realized it!&lt;&#x2F;p&gt;
&lt;p&gt;We did six iterations
of &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Conway%27s_Game_of_Life&quot;&gt;Conway&#x27;s Game of Life&lt;&#x2F;a&gt;
kata (45 minutes of coding and 15 minutes of debriefing). During every
iteration, we had different constraints. After an iteration, you have to destroy
your code. I did every iteration in Java using IntelliJ (my everyday language
and IDE) in ping-pong programming (using TDD of course) with a different person.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conway-s-game-of-life&quot;&gt;Conway&#x27;s Game of Life&lt;&#x2F;h2&gt;
&lt;p&gt;The rules of Conway&#x27;s Game of Life are simple. In an infinite orthogonal 2-dimensional world, the following rules apply:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;When an alive cell has fewer than 2 neighbors it dies.&lt;&#x2F;li&gt;
&lt;li&gt;When an alive cell has 2 or 3 neighbors it stays alive.&lt;&#x2F;li&gt;
&lt;li&gt;When an alive cell has more than 3 neighbors it dies.&lt;&#x2F;li&gt;
&lt;li&gt;When a dead cell has 3 neighbors it becomes alive.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;1st-iteration&quot;&gt;1st iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraint: none. This iteration is mostly to discover the problem and the
rules.&lt;&#x2F;p&gt;
&lt;p&gt;We both already knew this kata but always had the same approach so we decided to
do it another way: we started by implementing the rules. We went quite far: we
had all the elements and were assembling them. The design of the grid emerged by
itself so we didn&#x27;t have to think about which structure to use. It&#x27;s the best
approach I used so far and used it during the other iterations.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2nd-iteration&quot;&gt;2nd iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraint: no primitive in the public API of our methods.&lt;&#x2F;p&gt;
&lt;p&gt;We had the same approach as in the previous iteration. The hardest thing was to
define the coordinates of the cells without using &lt;code&gt;int&lt;&#x2F;code&gt;. We cheated and
used &lt;code&gt;Integer&lt;&#x2F;code&gt;, that&#x27;s Java after all.&lt;&#x2F;p&gt;
&lt;p&gt;During the debriefing, we shared our difficulties and someone suggested defining
the neighbors relative to each other. Using top, right, bottom, and left. I
think it&#x27;s a great idea because you can chain them and it is infinite (by
using an &lt;code&gt;int&lt;&#x2F;code&gt; I have a limit, a huge one, but still a limit).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;3rd-iteration&quot;&gt;3rd iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraint: no conditionals.&lt;&#x2F;p&gt;
&lt;p&gt;One of the most difficult constraints for me… How to remove the if in the method
that checks if a cell is dead or alive?! Finally, we
used &lt;code&gt;Map&amp;lt;Integer, Function&amp;gt;&lt;&#x2F;code&gt; to get the rule corresponding to the number of
neighbors. I don&#x27;t usually use this pattern but it improves the readability of
the code and every Function has only one role (the S in SOLID)!&lt;&#x2F;p&gt;
&lt;p&gt;However, it was quite hard to come to this idea and we should have written the
code with conditionals then refactored it. I have no idea why we didn&#x27;t use the
refactoring phase of TDD to do it.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;4th-iteration&quot;&gt;4th iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraint: not only object-oriented development (Functions &amp;amp; Types over
classes. Purity over mutability. Composition over inheritance. Higher-order
functions over method dispatch. Options over nulls).&lt;&#x2F;p&gt;
&lt;p&gt;This was the hardest constraint. I&#x27;m not used to functional programming so I
needed to change the way I think, which is hard in 45 minutes… Even
writing the first test wasn&#x27;t easy.&lt;&#x2F;p&gt;
&lt;p&gt;Finally, we wrote specific functions for every functionality (one for each rule,
one to count the number of neighbors…) then composed them.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;5th-iteration&quot;&gt;5th iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraint: mute programming.&lt;&#x2F;p&gt;
&lt;p&gt;I thought it would be an easy one because we both knew the problem and already
solved it a few times. However, it wasn&#x27;t so easy because it&#x27;s hard to tell the
intention of a method or a variable. We had to rename them a couple of times to
know what it meant for both of us. This time writing the rules first wasn&#x27;t the
best idea because once written it was hard to continue and to explain (without
speaking or writing) what we wanted to do! Communication is really important in
a team!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;6th-iteration&quot;&gt;6th iteration&lt;&#x2F;h3&gt;
&lt;p&gt;Constraints: TDD as if you meant it &amp;amp; mob programming.&lt;&#x2F;p&gt;
&lt;p&gt;The most fun! We were disciplined enough to listen to each other so it didn&#x27;t
end up in a big mess. But it was hard for some people to talk and give their
point of view. When the group is working well sometimes you don&#x27;t want to slow
it down. However, it could be interesting to have a higher vision of what we are
doing and it could be the opportunity for refactoring some code.&lt;&#x2F;p&gt;
&lt;p&gt;In this last iteration, we wrote the simplest code in the test to make it pass.
At first, it looked absurd because it was very far from the code we all produced
during the day. But it&#x27;s a good way to experiment with things and finally design
our application in a new way.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-did-i-learn&quot;&gt;What did I learn?&lt;&#x2F;h2&gt;
&lt;p&gt;This day was very interesting and I&#x27;m glad I spent my Saturday there. I met
passionate people, I had fun and I learned new things that I&#x27;ll try to apply in my
everyday job.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Communicating through the code is hard and sometimes a meaningful name for me
might not make sense to someone else. Next time I do a code review I will
challenge even more the name of the methods&#x2F;variables.&lt;&#x2F;li&gt;
&lt;li&gt;I will try to write more functional code: it&#x27;s harder to write when you&#x27;re not
used to but it&#x27;s really simple to test.&lt;&#x2F;li&gt;
&lt;li&gt;I will write more code in my test to experiment: you don&#x27;t have to switch to a
different class to see what you are doing and you can easily refactor
everything once it&#x27;s working.&lt;&#x2F;li&gt;
&lt;li&gt;Next time I will write an &lt;code&gt;if&lt;&#x2F;code&gt; (probably tomorrow) I&#x27;ll ask myself if I can do
without it.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
    </entry>
</feed>
