<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Productivity on The Cloud Optimist</title>
        <link>https://antoinedelia.github.io/cloud-optimist/pr-144/en/categories/productivity/</link>
        <description>Recent content in Productivity on The Cloud Optimist</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-US</language>
        <lastBuildDate>Wed, 26 Jun 2019 22:49:13 +0200</lastBuildDate><atom:link href="https://antoinedelia.github.io/cloud-optimist/pr-144/en/categories/productivity/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>The Rubber Duck Debugging - why does it work?</title>
        <link>https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/the-rubber-duck-debugging/</link>
        <pubDate>Wed, 26 Jun 2019 22:49:13 +0200</pubDate>
        
        <guid>https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/the-rubber-duck-debugging/</guid>
        <description>&lt;img src="https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/the-rubber-duck-debugging/duck.jpg" alt="Featured image of post The Rubber Duck Debugging - why does it work?" /&gt;&lt;p&gt;&lt;strong&gt;Programming is a painful art.&lt;/strong&gt; You are a real architect and you mission is to design, build, decorate and maintain an application, much like how you would do for a house.&lt;/p&gt;
&lt;p&gt;One difficulty emerges though: &lt;strong&gt;you have to communicate information with a machine through programming languages to make everything work.&lt;/strong&gt; Surely you don&amp;rsquo;t talk to your furniture to place them into your house, right? &lt;em&gt;Right?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This little difference is crucial, as you sometimes will encounter an issue that you have no idea why it is there. Truly you developed this thing so perfectly that it should not fail. But here we are, a bug is there and you don&amp;rsquo;t know why.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The first thing to do is of course to blame it on the computer.&lt;/strong&gt; I mean, you know what you&amp;rsquo;re doing, there is no way you wrote something the wrong way. It&amp;rsquo;s probably this damn laptop which is making you look like a fool again. But the truth is hard to swallow.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The machine does exactly what you tell it to do.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;cite&gt;Bill Gates, probably&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Like it or not, your computer is dumb. It will mindlessly retrieve the information you provided and execute them. &lt;strong&gt;And if it fails, it is, without a doubt, your fault.&lt;/strong&gt; I know the pain, trust me. But don&amp;rsquo;t worry too much, it happened to every one of us, and at the end of the day, everything will be fine.&lt;/p&gt;
&lt;p&gt;Now, it is all up to you. You know that you did something wrong, yet are unable to find what.So what&amp;rsquo;s next? Should look up answers on StackOverflow? Resign of your position as you clearly are not good enough for this job? The answer is simple.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The first step when you are stuck, is to ask the wisdom of the duck.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I know what you&amp;rsquo;re thinking right now: &lt;em&gt;What are you smoking and where can I get some?&lt;/em&gt; But trust me, this whole duck thing is not an hallucination, it is THE best way to help you.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t worry though, you won&amp;rsquo;t need to drive to the nearest farm and steal a duck to apply this advice. In our case, a rubber duck is what we need.&lt;/p&gt;
&lt;p&gt;Once you get your hands on one and place it on your desk, the only thing left is to talk to him. Go ahead, don&amp;rsquo;t be shy and explain to him what&amp;rsquo;s happening with your code.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;d rather tell about it right now so you don&amp;rsquo;t end up shocked when confronted with the truth, but the duck will not respond to you. Hearth-breaking, I know. However, &lt;strong&gt;he is the perfect listener and his patience is way above any other human being&lt;/strong&gt; unlike your co-workers. Moreover, the duck will never judge your mistakes. He is kind and comprehensive.&lt;/p&gt;
&lt;p&gt;And the more you will explain to him your troubles, the more you&amp;rsquo;ll realize what was wrong all along in your code. Indeed, trying to explain properly to the duck what you are trying to do will expose a tiny inconsistency between what you did and what you are trying to achieve. Slowly but surely, you will soon enough be able to pinpoint the exact line of code that was causing all your troubles and fix it like the pro you are.&lt;/p&gt;
&lt;p&gt;And that&amp;rsquo;s why the duck is so useful. Not only did you let your coworkers work in peace, this exercise forces you to take a step back at your code so that you can explain it to someone who has no clue of what&amp;rsquo;s going on.&lt;/p&gt;
&lt;p&gt;This effort to put words on the expected behavior and what you were able to achieve for now will highlight any potential mistakes you might have made during the development, things that can&amp;rsquo;t be seen when you spent eight hours looking at your code non-stop.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In describing what the code is supposed to do and observing what it actually does, any incongruity between these two becomes apparent.&lt;/p&gt;
&lt;p&gt;&amp;ndash; &lt;cite&gt; &lt;a class=&#34;link&#34; href=&#34;https://www.sjbaker.org/humor/cardboard_dog.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Stephen J. Baker&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So next time you&amp;rsquo;re stuck on something, don&amp;rsquo;t bother your co-workers, save your internet data and simply ask the duck!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you wish to learn more on this method, I strongly suggest having a look at the website behind this post&amp;rsquo;s inspiration. &lt;cite&gt; &lt;a class=&#34;link&#34; href=&#34;https://rubberduckdebugging.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://rubberduckdebugging.com/&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        </item>
        <item>
        <title>FizzBuzz, the simplest, more efficient way to test a developer</title>
        <link>https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/fizzbuzz/</link>
        <pubDate>Mon, 27 May 2019 13:35:55 +0200</pubDate>
        
        <guid>https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/fizzbuzz/</guid>
        <description>&lt;img src="https://antoinedelia.github.io/cloud-optimist/pr-144/en/posts/2019/fizzbuzz/fizzbuzz.jpeg" alt="Featured image of post FizzBuzz, the simplest, more efficient way to test a developer" /&gt;&lt;p&gt;When I got out of my engineering school, I passed a lot of interviews in the hope of getting a developer job. My experiences being limited to having done a few internships, I was fearing the part of the interview where I would have had to get up and resolve some complex algorithm exercise on a white board, or even just answer a few technical questions. I was wrong.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Not a single interview tested me on my development skills.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I could&amp;rsquo;ve lied my way through the whole interview that I would still have gotten the job.&lt;/p&gt;
&lt;p&gt;To be honest, I&amp;rsquo;m not part of the people who praise technical questions like it is some kind of magic spell to detect good programmers. I&amp;rsquo;d rather think than someone with a good temperament, passionate and humanely pleasant is much more appreciated than a know-it-all who always brings his science to the table without wanting to hear anyone else opinions. &lt;strong&gt;You can improve a technical gap, but you can&amp;rsquo;t improve a shitty character.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I do believe however that it is mandatory to at least check the way of thinking of someone when being confronted to a problem. Because in the end, that&amp;rsquo;s what he is gonna do most of his job: resolve problems. As such, it is crucial to see how someone will behave when being presented a problem. Will he run away? Will he immediately ask for help?&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s when the &lt;strong&gt;FizzBuzz&lt;/strong&gt; test comes into play.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This post was inspired by &lt;a class=&#34;link&#34; href=&#34;https://www.youtube.com/watch?v=QPZ0pIK_wsc&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Tom Scott&amp;rsquo;s video&lt;/a&gt; that I strongly suggest you to have a look at if this topic interests you.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The idea behind FizzBuzz is straight-forward. You need to count out loud numbers starting at 1 until you reach 100. But, if the number is a multiple of 3, you have to say the word &amp;ldquo;Fizz&amp;rdquo; instead. In the same way, if the number is a multiple of 5, you have to say the word &amp;ldquo;Buzz&amp;rdquo;. Now you might be thinking: &amp;ldquo;Then what am I supposed to do when it is a multiple of both 3 and 5?&amp;rdquo;. Well, you would simply have to say &amp;ldquo;FizzBuzz&amp;rdquo;. &lt;em&gt;Roll credits&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;By reading this simple test, you might wonder why this should be used, as it appears that even an intern could solve it quite easily. Well, that&amp;rsquo;s what I thought too, until I ran across &lt;a class=&#34;link&#34; href=&#34;https://blog.codinghorror.com/why-cant-programmers-program/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Jeff Atwood&amp;rsquo;s post on this subject&lt;/a&gt;, stating that he was surprised how this problem actually gave a lot of troubles to candidates, even senior ones.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So let&amp;rsquo;s try to solve it together!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In most technical interviews and as such for this exercise, you are free to use any programming language you feel most comfortable with, or even write using &lt;a class=&#34;link&#34; href=&#34;https://en.wikipedia.org/wiki/Pseudocode&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;pseudocode&lt;/a&gt;. For this post, I&amp;rsquo;m gonna use Python.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;First things first, let&amp;rsquo;s create a simple loop that prints all numbers from 1 to 100.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;101&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Off to a great start! Now let&amp;rsquo;s review the original statement: if the number is a multiple of 3, show &amp;ldquo;Fizz&amp;rdquo;, if the number is a multiple of 5, show &amp;ldquo;Buzz&amp;rdquo;. No Let&amp;rsquo;s add these conditions.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;101&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Fizz&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Buzz&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;and&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s take a minute to see what we did here. &lt;strong&gt;In order to check whether a number is a multiple of 3, we are using the modulo with the symbol %.&lt;/strong&gt;We are doing the same thing for multiples of 5. Finally, if the number is neither a multiple of 3 nor 5, we simply display it.&lt;/p&gt;
&lt;p&gt;This way we get exactly what we want !&amp;hellip; Except when a number is a multiple of both 3 and 5. When that happens, &lt;strong&gt;the words Fizz and Buzz are not displayed on the same line !&lt;/strong&gt; We shall then take into account this case by adding a new condition, and prevent the first two &lt;code&gt;if&lt;/code&gt; to trigger.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;9
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;101&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;and&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Fizz&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;and&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;Buzz&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;and&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;FizzBuzz&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;and&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This finally works! But at what cost? &lt;strong&gt;This whole code is a mess.&lt;/strong&gt; And it is by no means a piece of code that can easily be maintained. Take this issue as an example: what would happen if we now want to display the word Fizz for multiples of 2 instead of 3? &lt;strong&gt;We will have to change this value at 4 different places through the code&lt;/strong&gt; to make it work.&lt;/p&gt;
&lt;p&gt;This might look trivial with such a minimalistic code, but imagine what would happen if this happened on a much bigger project. &lt;strong&gt;This code is prone to errors, complicates its maintainability and makes it almost impossible to add new features easily.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s try another approach to make this code more elegant! We&amp;rsquo;ll first declare a variable which will be the value we want to print at the end. We&amp;rsquo;ll make it an empty string for now. Each time we successfully match a condition, we&amp;rsquo;ll simply append the corresponding word to the result. At the end, checking if the variable is empty will let us know if we should print it or rather print the number.&lt;/p&gt;
&lt;p&gt;This is what we get.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;101&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Fizz&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;5&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Buzz&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;or&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s already much clearer! Not only did we shrink the number of lines by half, our &lt;code&gt;if&lt;/code&gt; checks are now crystal clear and don&amp;rsquo;t let any rooms for misinterpretation. Plus, we can easily change the value of any of the numbers if we need to without having to look for all its occurrences. Last but not least, if we ever need to add yet another condition for multiples of 7, we&amp;rsquo;ll simply have to add two new lines without changing the rest of the code!&lt;/p&gt;
&lt;p&gt;We can finally see how this simple FizzBuzz test is so interesting. We were able to test one&amp;rsquo;s ability to use simple algorithmic principles, but also to check his way of thinking when being confronted to a problem, and if he is able to produce a code that takes care of its future.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;To make it short, FizzBuzz is a good way to differentiate a developer from a good developer.&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
