<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Blogs - Andrea Radaelli</title>
    <link>https://aradaelli.com/blog/</link>
    <lastBuildDate>Tue, 24 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://aradaelli.com/blog/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Keychron K3 Battery Mod</title>
      <link>https://aradaelli.com/blog/keychron-battery-mod/</link>
      <pubDate>Tue, 24 Dec 2024 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/keychron-battery-mod/</guid>
      <description>&lt;p&gt;In the last year or so I became interested in 75% sized keyboards. I love this design because it strikes a good balance between compactness and functionality — as a programmer, I need my function keys!&lt;/p&gt;
&lt;p&gt;For Christmas I finally decided to scratch my itch and bought a beautiful optical Keychron K3 off eBay. It&amp;rsquo;s been a joy to type on, but with a big downside: the battery life is very bad.&lt;/p&gt;
&lt;p&gt;With the backlight off, I struggled to get three days between charges. I didn&amp;rsquo;t want to keep the keyboard to be constantly wired, so I thought I could replace the battery. I checked a few online reviews and found out new units are rated for about week of use, which isn&amp;rsquo;t much of an improvement. I should have read about this &lt;em&gt;before&lt;/em&gt; impulse-buying the keyboard, but it was too late.&lt;/p&gt;
&lt;p&gt;I had a few used phone batteries collected over the years, so I thought I might be able to increase the total battery capacity by putting them to good use.&lt;/p&gt;
&lt;h2 id=&#34;the-battery&#34;&gt;The battery&lt;/h2&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image1.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image1_hu_214c4091f7bad977.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image1_hu_99affa380c9bd252.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image1_hu_d451686762ec0907.jpg&#34; alt=&#34;The keyboard original battery&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;The keyboard original battery&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The K3 is powered by a 3.7 V 1600 mAh lithium battery, and I was surprised to find out that it was almost twice as large and had less capacity than my old phone batteries, which are rated 3.85 V 3300 mAh. I did a deep-dive into lithium batteries and discovered that those batteries are dubbed &amp;ldquo;high-voltage&amp;rdquo;. By using a slightly different chemistry than regular lithium polymer batteries, they tolerate a higher charging voltage (4.4 V vs 4.2 V) and can therefore squeeze a bit more capacity for our ever more power-hungry phones.&lt;/p&gt;
&lt;h2 id=&#34;the-mod&#34;&gt;The mod&lt;/h2&gt;
&lt;p&gt;Luckily, replacing a normal lithium battery with a high-voltage one is totally safe: it will be undercharged, but given the larger overall capacity the result is still a win. Assuming a 30% loss of the rated capacity because of the lower charging voltage, plus wear from previous use, I would still get about ~ 2300mA/h — not bad!&lt;/p&gt;
&lt;p&gt;I figured I could fit two phone batteries in the frame by cutting a bit of plastic. Connecting two batteries in parallel effectively doubles the capacity. Before doing so, I carefully discharged the one that had the highest voltage until both were roughly the same within ±0.1 V — this to avoid any funny business when connecting them.&lt;/p&gt;
&lt;p&gt;Soldering battery leads is almost impossible because the tabs are made of aluminum. I found  that a product called &amp;ldquo;aluminum flux&amp;rdquo; makes it very easy! It dissolves and prevents aluminum from forming its natural oxide layer.&lt;/p&gt;
&lt;h2 id=&#34;the-final-result&#34;&gt;The Final Result&lt;/h2&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image2.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image2_hu_d08154a4622bcf12.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image2_hu_e09f9269eb69ca4e.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/keychron-battery-mod/images/image2_hu_14b60feb90043d22.jpg&#34; alt=&#34;Two batteries in the frame&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Two batteries in the frame&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;After this mod, I now get a good month of daily use from my Keychron, and I feel so satisfied that I&amp;rsquo;ve saved it from the bin and gave it a second life.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Sports Stats</title>
      <link>https://aradaelli.com/blog/sports-stats/</link>
      <pubDate>Fri, 22 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/sports-stats/</guid>
      <description>&lt;p&gt;I recently took a &amp;ldquo;homework project&amp;rdquo; for a job interview. What began as a daunting task turned into a pleasurable learning experience of &lt;a href=&#34;https://react.dev/&#34;&gt;React&lt;/a&gt; and &lt;a href=&#34;https://nextjs.org/&#34;&gt;Next.js&lt;/a&gt; and I got a new tiny project to showcase here.&lt;/p&gt;
&lt;h2 id=&#34;homework-projects&#34;&gt;Homework Projects&lt;/h2&gt;
&lt;p&gt;For those who don&amp;rsquo;t know, job interviews usually begin with a coding interview which consists of about an hour of solving coding problems under a time constraint. Some people criticize these evaluation methods  as not being very representative of what the day-to-day work of a software engineering looks like.&lt;/p&gt;
&lt;p&gt;Alternatives to coding interviews are &amp;ldquo;homework projects&amp;rdquo;. These projects consists of somewhat vague requirements that needs to be translated into a working program. They aim to test your ability to make reasonable guesses at the missing requirements and build something decent from them. In my experience this approach better reflects what a typical day as a software engineer will look like. Compared to the &amp;ldquo;classic&amp;rdquo; coding interview, homework projects remove the stress of being questioned and evaluated under tight time constraints. However, they require you to dedicate a few hours (or even days) of your valuable time, with no guarantee of a getting anything back in return.&lt;/p&gt;
&lt;h2 id=&#34;the-challenge&#34;&gt;The Challenge&lt;/h2&gt;
&lt;p&gt;My homework was to build a fullstack web application to visualize some &lt;a href=&#34;https://www.nfl.com/&#34;&gt;NFL&lt;/a&gt; statistics. The assignment also required using React and Node.js in the tech stack. I had no prior experience with React, but I was confident the learning curve wouldn&amp;rsquo;t be too steep since I already know &lt;a href=&#34;https://angular.io/&#34;&gt;Angular&lt;/a&gt; (a similar library). I had the time to dedicate myself fully to the homework, so I decided to take advantage of that and use the opportunity to learn React.&lt;/p&gt;
&lt;h2 id=&#34;the-tech-stack&#34;&gt;The Tech Stack&lt;/h2&gt;
&lt;p&gt;Since the landscape of JavaScript web development is constantly evolving, I started with researching the current &amp;ldquo;state of the art&amp;rdquo; and finally decided on Next.js and &lt;a href=&#34;https://www.typescriptlang.org/&#34;&gt;Typescript&lt;/a&gt;. For styling the frontend I settled on &lt;a href=&#34;https://tailwindcss.com/&#34;&gt;Tailwind CSS&lt;/a&gt;. TypeScript should come at no surprise as it is the de-facto standard for JavaScript development today. Thanks to its static typing, TypeScript allows the IDE to provide useful suggestion when coding and detect many errors at compile time.&lt;/p&gt;
&lt;p&gt;Next.js is a web framework based on React that offers &lt;a href=&#34;https://en.wikipedia.org/wiki/Server-side_scripting&#34;&gt;server-side rendering&lt;/a&gt; in addition to client-side. What truly impressed me about Next.js was its cohesive set of functionalities that cover both backend and frontend development out of the box and the &lt;a href=&#34;https://nextjs.org/docs/app&#34;&gt;App Router&lt;/a&gt;. The App router makes it easy to to create dynamic APIs and routes by using the files and directories with specific names. This approach not only saves time but also improves the project&amp;rsquo;s overall structure.&lt;/p&gt;
&lt;p&gt;Tailwind is a CSS framework that provides a low-level set of utility classes that wraps basic CSS directives. Unlike other frameworks (ex. &lt;a href=&#34;https://getbootstrap.com/&#34;&gt;Bootstrap&lt;/a&gt;) it doesn&amp;rsquo;t try to provide classes for predefined elements like cards or modals. I was skeptical about it because it seemed an unnecessary layer on top of CSS but I decided to give it a go given its popularity.&lt;/p&gt;
&lt;h2 id=&#34;embracing-the-learning-process&#34;&gt;Embracing the Learning Process&lt;/h2&gt;
&lt;p&gt;I find that I learn best when I am trying to build something. I started out by skimming through the official tutorials of React and then Next.js. Once I got the feeling on how to use the two I launched myself straight into the homework. At every step I would ask myself how to proceed, make a guess, and then check online the recommended way of solving it. This process starts slow, with me constantly searching and copy-pasting, but soon I start to internalize enough concepts to get going on my own.&lt;/p&gt;
&lt;h2 id=&#34;tailwind-css&#34;&gt;Tailwind CSS&lt;/h2&gt;
&lt;p&gt;This project made me reconsider my skepticism against Tailwind. Sure, it is simply wrapping CSS in simple classes, but by doing so it reduces its verbosity making it more concise, it standardizes the use of sizes, and finally it forces all styling to be tightly coupled to your components. So really, instead of writing CSS classes for your components you are writing the components themselves directly, saving one step. Furthermore by not having additional CSS classes you do not have to manage ever growing CSS files in your projects. When you need to make modifications you only change the components that are affected.&lt;/p&gt;
&lt;h2 id=&#34;e2e-testing&#34;&gt;E2E Testing&lt;/h2&gt;
&lt;p&gt;As I neared completion of the project, I decided to take it a step further by incorporating end-to-end (E2E) testing using &lt;a href=&#34;https://playwright.dev/&#34;&gt;Playwright&lt;/a&gt;. Playwright is a modern testing framework that allows you to automate browser interactions and simulate user behavior across different scenarios. The ease of writing and executing E2E tests with Playwright is astounding and makes me happy again about web development in 2024.&lt;/p&gt;
&lt;h2 id=&#34;conclusion-a-week-of-growth-and-achievement&#34;&gt;Conclusion: A Week of Growth and Achievement&lt;/h2&gt;
&lt;p&gt;As a developer I find that the best way to learn is by building something, and thanks to the interview project I now feel proficient in React, Next.js and Tailwind CSS.&lt;/p&gt;
&lt;p&gt;As I submitted the homework project and prepared for the interview, I reflected on the rapid growth and newfound confidence gained through this accelerated learning experience. Whether you&amp;rsquo;re a seasoned developer or a beginner, embarking on intensive learning journeys like this not only sharpens your skills but also fuels your passion for innovation in the ever-evolving tech industry.&lt;/p&gt;
&lt;h2 id=&#34;live-demo&#34;&gt;Live Demo&lt;/h2&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/sports-stats/images/screenshot.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/sports-stats/images/screenshot_hu_a7de2145c01e7edd.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/sports-stats/images/screenshot_hu_4f0c7b242345537e.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/sports-stats/images/screenshot_hu_1cd1bcf93cd9a7a.jpg&#34; alt=&#34;Screenshot&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Screenshot&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The live demo (desktop only) is hosted at: &lt;a href=&#34;https://sports-stats-demo.vercel.app&#34;&gt;https://sports-stats-demo.vercel.app&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source code: &lt;a href=&#34;https://github.com/skilion/sports-stats&#34;&gt;https://github.com/skilion/sports-stats&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Kiwi</title>
      <link>https://aradaelli.com/blog/kiwi/</link>
      <pubDate>Sun, 23 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/kiwi/</guid>
      <description>&lt;p&gt;Lately I wanted to increase my hands-on knowledge about &lt;a href=&#34;https://aws.amazon.com/&#34;&gt;Amazon Web Services (AWS)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For me, the best way to learn a new technology is trying to build something with it. So, I spent some time pondering and come up with a the idea of creating a simple &amp;ldquo;Twitter like&amp;rdquo; web application.&lt;/p&gt;
&lt;p&gt;The requirements I set were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To be able to see all the messages posted in the last 24h.&lt;/li&gt;
&lt;li&gt;To be able to post new messages.&lt;/li&gt;
&lt;li&gt;To automatically simulate multiple users posting messages every minute.&lt;/li&gt;
&lt;li&gt;To be able to scale for thousands of visitors.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I started by sketching a rough design for the architecture and then I went &amp;ldquo;shopping&amp;rdquo; on the AWS product page to see which services I could use. This is the end result:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/kiwi/images/architecture.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/kiwi/images/architecture_hu_3baf0949dbcea648.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/kiwi/images/architecture_hu_2e625dcf58c6bd86.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/kiwi/images/architecture_hu_f196c6d9c727772.png&#34; alt=&#34;Architecture Diagram&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Architecture Diagram&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Key decisions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The frontend will be a static &lt;a href=&#34;https://en.wikipedia.org/wiki/Single-page_application&#34;&gt;single-page application (SPA)&lt;/a&gt; which I could host directly on AWS S3.&lt;/li&gt;
&lt;li&gt;The backend endpoint for the APIs will be hosted on AWS Api Gateway.&lt;/li&gt;
&lt;li&gt;The backend services will be fully &lt;a href=&#34;https://en.wikipedia.org/wiki/Serverless_computing&#34;&gt;serverless&lt;/a&gt; using AWS Lambda.&lt;/li&gt;
&lt;li&gt;The storage for the system will be managed through DynamoDB.&lt;/li&gt;
&lt;li&gt;Queues will use AWS Simple Query Service (SQS).&lt;/li&gt;
&lt;li&gt;The whole infrastructure will be committed in the repository as &lt;a href=&#34;https://en.wikipedia.org/wiki/Infrastructure_as_code&#34;&gt;code&lt;/a&gt; by leveraging AWS Cloud Development Kit (CDK)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the frontend, I chose Angular for no other reason than to keep it fresh in my mind. After all, this project is solely for learning purposes.&lt;/p&gt;
&lt;p&gt;I made sure that I could host the whole system within the limits of the &lt;a href=&#34;https://aws.amazon.com/free/&#34;&gt;AWS Free Tier&lt;/a&gt;, so that I would not have to pay in order to host a simple demo web application.&lt;/p&gt;
&lt;p&gt;Here are a couple of tricks that I have learned.&lt;/p&gt;
&lt;h2 id=&#34;sqs-long-polling&#34;&gt;SQS Long Polling&lt;/h2&gt;
&lt;p&gt;Services monitoring SQS queues do so by periodically polling the queues to check for new messages. As SQS is priced on the number of request, it&amp;rsquo;s essential to minimize the number of polls.&lt;/p&gt;
&lt;p&gt;The recommended approach to achieve this is by enabling &lt;a href=&#34;https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html&#34;&gt;&amp;ldquo;Long polling&amp;rdquo;&lt;/a&gt;. Long polling allows Amazon SQS to wait until a message is available in a queue before sending a response, significantly reducing the number of requests per second.&lt;/p&gt;
&lt;p&gt;After setting the maximum wait time allowed for long polling, which is 20 seconds, I was expecting to see 3 requests per second in my queues. However, to my surprise, I noticed 15 requests per second in the monitoring dashboard. The mystery was solved by this &lt;a href=&#34;https://stackoverflow.com/questions/53372107/aws-sqs-long-polling-doesnt-reduce-empty-receives&#34;&gt;Stackoverflow question&lt;/a&gt;. It explains that queues wired to Lambdas (as in my architecture) are polled by 5 instances of the same Lambda by default, and this cannot be changed. While this caused a higher request rate, it is not a major concern for me since I have only two queues, and I will still be well below the threshold of the Free Tier for SQS.&lt;/p&gt;
&lt;h2 id=&#34;backend-endpoints-in-the-frontend&#34;&gt;Backend endpoints in the Frontend&lt;/h2&gt;
&lt;p&gt;Integrating the URL of my backend endpoint into the frontend using AWS CDK proved to be a bit challenging.&lt;/p&gt;
&lt;p&gt;Given that the frontend is static, it becomes necessary to hardcode the backend URL before building the Angular project. However, the nature of AWS CDK is to generate semi-random names for the declared services, making it impossible to guarantee that they won&amp;rsquo;t change with future edits. Ideally, the AWS CDK should trigger the frontend build as soon as it knows the backend URL, but unfortunately, that&amp;rsquo;s not possible.&lt;/p&gt;
&lt;p&gt;The workaround I discovered is to split the architecture into two separate &lt;a href=&#34;https://docs.aws.amazon.com/cdk/v2/guide/stacks.html&#34;&gt;&amp;ldquo;stacks&amp;rdquo;&lt;/a&gt;: one for the backend and one for the frontend. The backend stack can then utilize the &lt;a href=&#34;https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnOutput.html&#34;&gt;&amp;ldquo;output construct&amp;rdquo;&lt;/a&gt; to write the backend URL to a JSON file that can be directly referenced by the frontend.&lt;/p&gt;
&lt;h2 id=&#34;live-demo&#34;&gt;Live Demo&lt;/h2&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/kiwi/images/screenshot.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/kiwi/images/screenshot_hu_f79c646172c3c39.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/kiwi/images/screenshot_hu_ae487837b5d89d66.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/kiwi/images/screenshot_hu_a11222ad5dd5622e.png&#34; alt=&#34;Screenshot&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Screenshot&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The live demo is hosted at: &lt;a href=&#34;http://kiwi.aradaelli.com&#34;&gt;http://kiwi.aradaelli.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source code: &lt;a href=&#34;https://github.com/skilion/kiwi&#34;&gt;https://github.com/skilion/kiwi&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Don&#39;t make plans you cannot change</title>
      <link>https://aradaelli.com/blog/dont-make-plans-you-cant-change/</link>
      <pubDate>Tue, 04 Apr 2023 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/dont-make-plans-you-cant-change/</guid>
      <description>&lt;p&gt;I recently came back home from a 2 months trip in north and central America. During my travels, I had the pleasure of meeting two retired airline pilots who gave me a great piece of advice: &lt;em&gt;&amp;ldquo;never make plans that you cannot change, because no plans survive contact with reality&amp;rdquo;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Of course the bigger and distant in time the plan is, the more the quote proves true. It is something that experience teaches us, even if only intuitively.&lt;/p&gt;
&lt;p&gt;The quote is not new and it has been associated to many famous people with slight variations. But the truth remains.&lt;/p&gt;
&lt;p&gt;Hearing those words&amp;hellip; made me think. Because I broke the recommendation completely when planning for my long trip. I had bought a lot of plane tickets, way in advance, to save money. However, during my travels, I kept meeting people, like the two gentlemen, who told me about new places I would have loved to visit. But changing my plans to include the new places was impossible at that time. It would have been too expensive to change my tight flight schedule&amp;hellip; because I did not buy flexible flights!&lt;/p&gt;
&lt;p&gt;In that moment I consciously realized what my unconscious mind already knew. In a moment, I realized how many recommendations that spawned from that quote: &amp;ldquo;never put all your eggs in one basket&amp;rdquo;, &amp;ldquo;have time buffers for unknowns&amp;rdquo;, &amp;ldquo;get insurance for XYZ&amp;rdquo;, &amp;ldquo;do not buy what you cannot afford twice&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;I think the quote is a precursor of all the previous recommendations because it acts at a more abstract level of reality. At the simplest level, every instant, we set a goal, act it through and reassess. We make assumptions, plans, and goals all the time. But we cannot possibly ever know that things will take place as we expect them to. So we keep our investments diversified, we make space for unexpected events in our plans, we get insurance for our travels, we don&amp;rsquo;t spend all our money to buy a car or a house.&lt;/p&gt;
&lt;p&gt;I also want to mention it would be wrong to deduce that we should not make plans at all because of our inaccurate understanding of the world we live in. I know this because it can be a plausible conclusion in a moment of difficulties. We cannot dismiss planning exactly because we must live in this reality. If we do not make any plans, we will not get where we want. We are prey to our circumstances, and they will diverge from our desirable ones pretty quickly. If we just stop moving, we stop living. Our plans may be imperfect but if we expect them to fail, when it happens, we can adapt and move on.&lt;/p&gt;
&lt;p&gt;Stay in the flow.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Unity on Linux</title>
      <link>https://aradaelli.com/blog/unity-on-linux/</link>
      <pubDate>Thu, 30 Mar 2023 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/unity-on-linux/</guid>
      <description>&lt;p&gt;I have been dabbling with &lt;a href=&#34;https://unity.com/&#34;&gt;Unity&lt;/a&gt; lately. Linux is my main OS and I have encountered a few headaches  setting up my development environment.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/unity-on-linux/images/screenshot1.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/unity-on-linux/images/screenshot1_hu_8b3d21658cb035e7.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/unity-on-linux/images/screenshot1_hu_d45baaeb81cbc988.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/unity-on-linux/images/screenshot1_hu_cb0822252297db31.png&#34; alt=&#34;My Unity/Rider Setup&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;My Unity/Rider Setup&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;To be able to write scripts in Unity you need to use an &lt;a href=&#34;https://docs.unity3d.com/Manual/ScriptingSettingUp.html&#34;&gt;external code editor&lt;/a&gt;. Of course if you don&amp;rsquo;t care about auto-completion and debugging you can use any editor, but that&amp;rsquo;s not a realistic use case.&lt;/p&gt;
&lt;p&gt;The officially supported IDEs are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visual Studio&lt;/li&gt;
&lt;li&gt;Visual Studio Code&lt;/li&gt;
&lt;li&gt;JetBrains Rider&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;visual-studio&#34;&gt;Visual Studio&lt;/h1&gt;
&lt;p&gt;If you are on Windows the no-brainier solution is Visual Studio. However on Linux it is not available.&lt;/p&gt;
&lt;h1 id=&#34;visual-studio-code&#34;&gt;Visual Studio Code&lt;/h1&gt;
&lt;p&gt;My first choice was VS Code since it is free to use. However, at the time of writing (Q1 2023), it is hard to setup and can&amp;rsquo;t be used for debugging.&lt;/p&gt;
&lt;p&gt;To use VS Code you need to install the C# extension and a supported C# compiler to enable auto-completion. The current LTS version of Unity (LTS 2021) uses .NET Standard 2.0 and generates &lt;code&gt;.csproj&lt;/code&gt; files targeting .NET Framework &lt;code&gt;4.7.1&lt;/code&gt;. That means you cannot use the official Microsoft .NET 5+ compiler for Linux because it doesn&amp;rsquo;t support &lt;code&gt;4.7.1&lt;/code&gt;. In theory you could manually rewrite the &lt;code&gt;.csproj&lt;/code&gt; files, because .NET 5 is compatible with .NET Standard, but Unity will overwrite your &lt;code&gt;.csproj&lt;/code&gt; files without notice. That leaves you with the only option of installing the old &lt;a href=&#34;https://www.mono-project.com/&#34;&gt;Mono .NET Framework&lt;/a&gt; which, unfortunately, is a dying project. I am using Debian 11 and there is no repository from Mono to install the latest version although Debian 11 has been around since August 2021&amp;hellip; Fortunately the version of Mono for Debian 10 still works (note that you need to &lt;a href=&#34;https://wiki.debian.org/AptConfiguration&#34;&gt;pin the repository&lt;/a&gt; in APT or else APT will install an older version of Mono from the Debian &amp;ldquo;stable&amp;rdquo; repository).&lt;/p&gt;
&lt;p&gt;Even if you get auto-completion to work, you will have to use the UNofficial &lt;a href=&#34;https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug&#34;&gt;Debugger for Unity&lt;/a&gt; extension which I had no luck running at all. It would have been nice to find out before I spent hours installing Mono&amp;hellip;&lt;/p&gt;
&lt;p&gt;At this point we are left with only one option.&lt;/p&gt;
&lt;h1 id=&#34;jetbrains-rider&#34;&gt;JetBrains Rider&lt;/h1&gt;
&lt;p&gt;Rider is not free at all, but if you are a student you can get the Educational version for free.&lt;/p&gt;
&lt;p&gt;I tried to install Rider both manually (extracting the &lt;code&gt;.tar.gz&lt;/code&gt; to &lt;code&gt;/opt&lt;/code&gt;) and through &lt;a href=&#34;https://flathub.org/apps/details/com.jetbrains.Rider&#34;&gt;Flatpak&lt;/a&gt;. However both attempts did not get recognized by Unity so I could not get Unity to launch Rider correctly from inside the game editor.&lt;/p&gt;
&lt;p&gt;The only way that worked was by installing Rider with the &lt;a href=&#34;https://www.jetbrains.com/toolbox-app/&#34;&gt;JetBrains Toolbox App&lt;/a&gt;. Afterwards, Rider just worked. Both auto-completion and debugging. And I did not even need to install Mono! The official .NET distribution from Microsoft worked just fine.&lt;/p&gt;
&lt;p&gt;Finally I got a working Unity development environment!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Music Reactive Led Matrix</title>
      <link>https://aradaelli.com/blog/music-reactive-led-matrix/</link>
      <pubDate>Sun, 30 Jan 2022 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/music-reactive-led-matrix/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;For New Year&amp;rsquo;s Eve 2021, I decided to build a LED matrix that would react to the music being played.&lt;/p&gt;
&lt;p&gt;I got inspired for this project by visiting the Cyberdog store in Camden Town. I wanted to recreate the same feeling I had when seeing for the first time the awesome &lt;a href=&#34;https://duckduckgo.com/?q=cyberdog+dj+booth&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;DJ booth&lt;/a&gt; they have in the basement.&lt;/p&gt;
&lt;p&gt;I started planning and building it one month before. However the project was too ambitious for my experience with electronics, I made a few mistakes and I had to cut the features short to meet the deadline.&lt;/p&gt;
&lt;p&gt;I am very proud of the final result, I managed to implement the main effect I saw in Cyberdog and make it work just in time for new year. It was far from perfect but enough to create the right atmosphere:&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/videos/final.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h2 id=&#34;the-original-plan&#34;&gt;The Original Plan&lt;/h2&gt;
&lt;p&gt;My initial requirements were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;build a LED matrix by cutting up a few meters of LED strips&lt;/li&gt;
&lt;li&gt;use an &lt;a href=&#34;https://en.wikipedia.org/wiki/ESP32&#34;&gt;ESP32 microcontroller&lt;/a&gt; to drive the strips&lt;/li&gt;
&lt;li&gt;have an app on my smartphone to create the animations in sync with music&lt;/li&gt;
&lt;li&gt;make the app and the ESP32 communicate via Bluetooth LE (partially reusing code from my &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light&#34;&gt;previous project&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;be as portable as possible&lt;/li&gt;
&lt;li&gt;budget of £100&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The biggest cost would come from the LED strips so I checked EBay and decided to buy 20 meters of WS2812B Addressable RGB LED strips with a density of 30 LED/meter. With that I could create a &lt;code&gt;20x30&lt;/code&gt; matrix and if I spaced each strip by &lt;code&gt;10cm&lt;/code&gt; I could make it &lt;code&gt;2x1&lt;/code&gt; meters big. Big enough for a strong impact.&lt;/p&gt;
&lt;p&gt;The WS2812B LED strips work with &lt;code&gt;5V&lt;/code&gt;. I estimated that 600 (&lt;code&gt;20x30&lt;/code&gt;) LEDS would need a big &lt;code&gt;200W 5V&lt;/code&gt; power supply and thick wires to sustain the amount of current needed (about &lt;code&gt;36A&lt;/code&gt; assuming each LED consumes &lt;code&gt;0.06A&lt;/code&gt; at maximum brightness). To avoid buying the power supply and the thick cables I decided to just use my bench power supply instead, with a higher voltage (&lt;code&gt;12V&lt;/code&gt;+), and then connect a few &lt;a href=&#34;https://en.wikipedia.org/wiki/Buck_converter&#34;&gt;buck converters&lt;/a&gt; right before the LED strips to bring the voltage down to 5V.&lt;/p&gt;
&lt;p&gt;The LED strips come with adhesive tape so I decided to stick them on a &lt;a href=&#34;https://duckduckgo.com/?q=frosted+vinyl+film&amp;amp;iar=images&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;frosted vinyl film&lt;/a&gt; in order to be able to roll everything up when not in use. The frosted finish of the vinyl film helps hiding the cabling, leaving a cleaner look.&lt;/p&gt;
&lt;p&gt;On the software side, I could build upon the code of my &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light&#34;&gt;previous project&lt;/a&gt; and extend it to transmit an RGB matrix from my phone to the ESP32 which would in turn transmit it to the LED strip. In the app I could make some nice animations that would use the sound from the microphone as input.&lt;/p&gt;
&lt;p&gt;With all this in mind, I ordered the material, waited for delivery, and started building.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/1.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/1_hu_827999335bfc4e48.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/1_hu_1f98b95625fdfc2b.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/1_hu_aa4f09103b257da.jpg&#34; alt=&#34;Assembling the LED Matrix&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Assembling the LED Matrix&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;mistake-1-bad-power-estimations&#34;&gt;Mistake 1: Bad Power Estimations&lt;/h2&gt;
&lt;p&gt;My biggest mistake was over estimating the power capacity of the buck converters.&lt;/p&gt;
&lt;p&gt;I had experience with the super compact &lt;a href=&#34;https://duckduckgo.com/?q=mini+360+buck+converter&#34;&gt;&amp;ldquo;Mini 360&amp;rdquo; buck converter&lt;/a&gt; and I remembered from its spec that it could output up to &lt;code&gt;3A&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I had read somewhere that a single WS2812B LED could consume a maximum of &lt;code&gt;0.06A&lt;/code&gt;, so two strips of &lt;code&gt;1m&lt;/code&gt; should consume a maximum of &lt;code&gt;2 * 30 * 0.06A = 3.6A&lt;/code&gt;. I thought &lt;code&gt;0.06A&lt;/code&gt; was probably an extreme case and that the real limit would be lower so I decided to connect each Mini 360 to 2 strips.&lt;/p&gt;
&lt;p&gt;However, I overlooked the fact that &lt;code&gt;3A&lt;/code&gt; was the &lt;strong&gt;peak&lt;/strong&gt; output of the Mini 360, only sustainable for a short period of time. In my practical tests the Mini 360 becomes &lt;strong&gt;dangerously hot&lt;/strong&gt; over &lt;code&gt;1.5A&lt;/code&gt; and I realized that only when testing the LED matrix after all the soldering and cabling was done.&lt;/p&gt;
&lt;p&gt;The deadline was close, un-soldering and re-soldering everything to add more Mini 360s would mean hours of work which I simply didn&amp;rsquo;t had. In order to avoid missing the deadline I added some code to the ESP32 that would automatically limit the maximum brightness of the LEDs thus reducing the maximum current to a safe limit.&lt;/p&gt;
&lt;p&gt;Lessons learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;double check the specifications of your components&lt;/li&gt;
&lt;li&gt;thoroughly test a subset of your project before soldering everything&lt;/li&gt;
&lt;li&gt;if you underestimate the power you may be able to scale down the usage your components and get away with it 😉&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;mistake-2-mixing-5v-and-33v-logic&#34;&gt;Mistake 2: Mixing 5V and 3.3V Logic&lt;/h2&gt;
&lt;p&gt;The WS2812B LED strips are driven by &lt;code&gt;5V&lt;/code&gt; data signals. The ESP32 uses &lt;code&gt;3.3V&lt;/code&gt;, so common sense dictates that you need a &lt;a href=&#34;https://en.wikipedia.org/wiki/Level_shifter&#34;&gt;level shifter&lt;/a&gt; to interface the two. However this was not apparent to me because the LED strips work quite well &lt;em&gt;most of the time&lt;/em&gt; even with a &lt;code&gt;3.3V&lt;/code&gt; input.&lt;/p&gt;
&lt;p&gt;This is because &lt;code&gt;3.3V&lt;/code&gt; &amp;ldquo;high&amp;rdquo; signals are high enough to be recognized as &amp;ldquo;high&amp;rdquo; from &lt;code&gt;5V&lt;/code&gt; components, &lt;em&gt;most of the time&lt;/em&gt;. Glitches and flickers start appearing when refreshing the LED strips at high frequency:&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/videos/flicker.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;p&gt;However, I disregarded this problem as either some weak soldering or wrong voltage levels on my buck converters and went onward finishing building the LED matrix. Only at the very end, when I took the time to properly debug the issue I found the actual cause of the flickering.&lt;/p&gt;
&lt;p&gt;Since I did not want to wait for the delivery of a level shifter I started tinkering with the voltage levels of the buck converters and discovered that if I lowered the voltage of the buck converter that powered the first line of LEDs where the ESP32 was connected to, all the flickering would disappear.&lt;/p&gt;
&lt;p&gt;This makes sense since I am actually making the LEDs work in a voltage range closer to the ESP32. This &amp;lsquo;hack&amp;rsquo; works but it left my first two strips emitting a slightly different color than the rest. Luckily it is hardly noticeable when playing fast animations.&lt;/p&gt;
&lt;p&gt;Lessons learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;3.3V&lt;/code&gt; and &lt;code&gt;5V&lt;/code&gt; circuits require a level shifter to interface them&lt;/li&gt;
&lt;li&gt;lowering the supply voltage of the &lt;code&gt;5V&lt;/code&gt; circuit (in this case) is enough to get away with it 😉&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;mistake-3-assuming-real-time-programming-is-easy&#34;&gt;Mistake 3: Assuming Real-Time Programming Is Easy&lt;/h2&gt;
&lt;p&gt;Another mistake I made was to underestimate the complexity of building the software to drive the LED matrix.&lt;/p&gt;
&lt;p&gt;I assumed that extending the code I already had from my &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light&#34;&gt;previous project&lt;/a&gt; would not take much and left it for the last week before New Year. I did the change fairly quickly but then I hit a serious problem.&lt;/p&gt;
&lt;p&gt;The communication between my phone and the ESP32 is done using &lt;a href=&#34;https://en.wikipedia.org/wiki/Bluetooth_Low_Energy&#34;&gt;Bluetooth Low Energy&lt;/a&gt;. The ESP32 supports Bluetooth 4.2 which, configured with a large Maximum Transmission Unit (MTU) and the Data Length Extension Enabled (DLE), should about &lt;code&gt;478 KBit/s&lt;/code&gt; as measured in &lt;a href=&#34;https://www.novelbits.io/bluetooth-5-speed-maximum-throughput/&#34;&gt;this article&lt;/a&gt; (see Case 3).&lt;/p&gt;
&lt;p&gt;For my use case I would need to transmit the color for 600 pixel at least 30 times per second.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;600 * 3B (number of RGB colors) = 1800B
1800B * 30 = 54000B = 54KB
54KB * 8 = 432KBit
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;432KBit&lt;/code&gt; are about 10% lower than &lt;code&gt;478KBit&lt;/code&gt;, so, when planning, I thought I would not have any problem.&lt;/p&gt;
&lt;p&gt;However, reality is not that straightforward. The Bluetooth API are not really made for maximum throughput out of the box and optimizing both an Android app and the ESP32 requires reading lots of documentation and lots of trial and error. In the end, I did not have enough time to properly do it.&lt;/p&gt;
&lt;p&gt;My initial tests showed miserable performances, in the range of 1 to 5 frame per second, with noticeable change in speed from time to time. That was unacceptable to show animations that react in real-time with the music.&lt;/p&gt;
&lt;p&gt;Animations that slow are very hard to watch so I decided to create the animations directly on the ESP32 instead of my phone. That is not ideal because it is much faster to develop and release for a smartphone than a microcontroller.&lt;/p&gt;
&lt;p&gt;With the short time left I chose one animation, the histogram of the audio frequencies, and hardcoded it in the ESP32. My phone would then only calculate the height of the histogram bars and send it. Since the histogram itself is very little (&lt;code&gt;20B&lt;/code&gt;, 1 byte for each column) I could get away with my limited bandwidth.&lt;/p&gt;
&lt;p&gt;I had to make the histogram on the phone because it was the only device with a microphone. The ESP32 by itself cannot listen to sounds.&lt;/p&gt;
&lt;p&gt;For curiosity, the histogram is calculated using the &lt;a href=&#34;https://en.wikipedia.org/wiki/Fast_Fourier_transform&#34;&gt;Fast Fourier transform&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Lessons learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;real-time task are a long process of optimization, plan accordingly&lt;/li&gt;
&lt;li&gt;if you can&amp;rsquo;t meet the deadline, cut the features and you may get away with it 😉&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;mistake-4-dangling-power-cables&#34;&gt;Mistake 4: Dangling Power Cables&lt;/h2&gt;
&lt;p&gt;I guess this is one of the things one has to learn the hard way.&lt;/p&gt;
&lt;p&gt;Much like in software development you never do tests in Production, in hardware you do not leave your &amp;ldquo;delicate&amp;rdquo; components close to &amp;ldquo;dangerous&amp;rdquo; equipment like a power supply.&lt;/p&gt;
&lt;p&gt;When testing the LED matrix I had my power supply at &lt;code&gt;12V&lt;/code&gt; connected directly with &lt;a href=&#34;https://duckduckgo.com/?q=allicator+clips&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;alligator clips&lt;/a&gt;. My ESP32 was also nearby supplying the data to the LED strips. Accidentally, the data line from the ESP32 entered in contact with the alligator clips of the power supply, immediately destroying my ESP32 development board and a few meters of LED strips.&lt;/p&gt;
&lt;p&gt;Luckily this happened quite early so I could wait for the delivery of a replacement ESP32 and new LED strips. I now make sure to always isolate my dangling cables with some &lt;a href=&#34;https://duckduckgo.com/?q=masking+tape&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;masking tape&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Lessons learned:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;isolate parts of your projects that operate at different voltage&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;final-result&#34;&gt;Final Result&lt;/h2&gt;
&lt;p&gt;Here is a video that shows the internal cabling of the LED matrix. Before hanging it on the wall I simply folded the rest of the vinyl film to cover the circuit.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/videos/wip.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/final.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/final_hu_e48789ef4dfaf43c.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/final_hu_37d53704c4844a7d.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/music-reactive-led-matrix/images/final_hu_5ce6b7b1d5a36489.jpg&#34; alt=&#34;Final Result&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Final Result&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;When I turned the LED matrix on at New Year my friends were ecstatic. It made all the hours spent soldering and testing worth it.&lt;/p&gt;
&lt;p&gt;I have learned a lot from this project. It is something I had never attempted at this scale and I am now working on improving it to match my original plan. Stay tuned.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://news.ycombinator.com/item?id=30140641&#34;&gt;Comments&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why I Like D</title>
      <link>https://aradaelli.com/blog/why-i-like-d/</link>
      <pubDate>Sun, 09 Jan 2022 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/why-i-like-d/</guid>
      <description>&lt;p&gt;My engineer friends are surprised when I mention I know and I even wrote code in the &lt;a href=&#34;https://en.wikipedia.org/wiki/D_(programming_language)&#34;&gt;D programming language&lt;/a&gt; (aka Dlang).&lt;/p&gt;
&lt;p&gt;D is not exactly a mainstream language. According to the &lt;a href=&#34;https://www.tiobe.com/tiobe-index/&#34;&gt;Tiobe Index&lt;/a&gt;, which measures programming languages popularity, D doesn&amp;rsquo;t make the first 20th languages, as of today. Its peak was in 2009 when it reached the &lt;a href=&#34;https://www.tiobe.com/tiobe-index/d/&#34;&gt;12th position&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I discovered D in 2013. I can&amp;rsquo;t remember if it was from &lt;a href=&#34;https://hn.algolia.com/?q=dlang&#34;&gt;Hacker News&lt;/a&gt; or some random Google search. At the time I was looking for a new language to replace C/C++ because I had enough of the amount of obscure behaviors, crazy complicated template system, and long compilation times. When writing C++ I have limit myself to use a subset of the features of the language to avoid &amp;ldquo;shooting myself in the foot&amp;rdquo;. I wanted to switch to a more productive language where I could focus on writing code.&lt;/p&gt;
&lt;p&gt;My requirements for a new language were: compiled, strongly typed, easy to learn and use (think Python), and binary compatible with existing C libraries such as &lt;a href=&#34;https://en.wikipedia.org/wiki/OpenGL&#34;&gt;OpenGL&lt;/a&gt; and the various operating system libraries.&lt;/p&gt;
&lt;p&gt;My candidates at the time were &lt;a href=&#34;https://dlang.org/&#34;&gt;D&lt;/a&gt;, &lt;a href=&#34;https://go.dev/&#34;&gt;Go&lt;/a&gt;, and &lt;a href=&#34;https://www.rust-lang.org/&#34;&gt;Rust&lt;/a&gt;. They are all compiled languages, however Go did not have generic types at the time so I excluded it immediately. Being already familiar in C, D won over Rust easily, because the syntax of Rust is quite far from C compared to D. My only pet peeve against D was that it came with a built-in garbage collector and I was against it for performance reasons, but the GC can be disabled programmatically so I concluded that it was worth taking D for a test drive.&lt;/p&gt;
&lt;p&gt;Later in 2016, I registered for &lt;a href=&#34;https://www.microsoft.com/en-gb/microsoft-365/onedrive/online-cloud-storage&#34;&gt;Microsoft Onedrive&lt;/a&gt; to make use of a promotion and, being a Linux user, found the landscape lacking of a good client to sync my files. The best option was a client written in Python which I didn&amp;rsquo;t quite like so I decided to write &lt;a href=&#34;https://github.com/skilion/onedrive&#34;&gt;my own client&lt;/a&gt; and to use D to become more familiar with the language.&lt;/p&gt;
&lt;p&gt;In hindsight, that was a great choice. The need to write a good program for myself made me focus in learning D. I picked up &lt;a href=&#34;https://erdani.com/tdpl/&#34;&gt;one of the best books&lt;/a&gt; about it, written by Andrei Alexandrescu, and dived in. The book was great and it made me completely fall in love with the language.&lt;/p&gt;
&lt;p&gt;Here are the reasons.&lt;/p&gt;
&lt;h2 id=&#34;better-c&#34;&gt;Better C&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;D&lt;/strong&gt; main &amp;ldquo;reason d&amp;rsquo;etre&amp;rdquo; is removing the limitations that C and C++ have accumulated over the years, while keeping compatibility with their binary interface and similar syntax.&lt;/p&gt;
&lt;p&gt;If you already know C/C++ that&amp;rsquo;s a great thing. Remove the pre-processor, the template system, the architecture dependent differences (ex. the size of an &lt;code&gt;int&lt;/code&gt;), the cruft of legacy features that accumulated over the years (ex. different flavors of the standard library). Then start adding modern features like foreach, modules, &lt;a href=&#34;https://tour.dlang.org/tour/en/basics/delegates&#34;&gt;delegates&lt;/a&gt;, dynamic and associative arrays (aka dictionaries or maps). The resulting syntax is so similar to C/C++ that you can will pick it up in a day. Just try out the interactive &lt;a href=&#34;https://tour.dlang.org/&#34;&gt;Dlang Tour&lt;/a&gt; if you don&amp;rsquo;t believe me.&lt;/p&gt;
&lt;p&gt;A nice perk of the similar syntax when you are converting your code: you can assume that any expression that you wrote in C/C++ will lead the same result in D or it won&amp;rsquo;t compile (ex. because you may need an explicit cast).&lt;/p&gt;
&lt;p&gt;D strives to keep binary compatibility with C and C++ programs. That is excellent if you want to start porting your codebase or simply have to interface with legacy libraries. Furthermore you can directly link static libraries compiled in C within your D executable&amp;mdash;and vice versa&amp;mdash;as long as you translate the header files for the library.&lt;/p&gt;
&lt;h2 id=&#34;consistency&#34;&gt;Consistency&lt;/h2&gt;
&lt;p&gt;D has been designed from the ground up by a small number of very experienced people, namely &lt;a href=&#34;https://en.wikipedia.org/wiki/Walter_Bright&#34;&gt;Walter Bright&lt;/a&gt; and &lt;a href=&#34;https://en.wikipedia.org/wiki/Andrei_Alexandrescu&#34;&gt;Andrei Alexandrescu&lt;/a&gt;. Their unified vision is reflected both in the syntax and the standard library of the language.&lt;/p&gt;
&lt;p&gt;The standard library is rich of features. It provides both basic things like containers, date handling, math functions and more advanced things such as concurrency, regexes, and cryptography. You even get interfaces to common libraries like &lt;a href=&#34;https://sqlite.org/&#34;&gt;SQLite&lt;/a&gt; and &lt;a href=&#34;https://curl.se/&#34;&gt;Curl&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The standard library is built from the ground up making extensive use of &lt;a href=&#34;https://en.wikipedia.org/wiki/Generic_programming&#34;&gt;generic types&lt;/a&gt; and &lt;a href=&#34;https://tour.dlang.org/tour/en/basics/ranges&#34;&gt;ranges&lt;/a&gt; (equivalent of C++ or Python &lt;em&gt;iterators&lt;/em&gt;). A great example is &lt;a href=&#34;https://dlang.org/phobos/std_algorithm.html&#34;&gt;std.algorithm&lt;/a&gt;. All common operations like iteration, sorting, search, and comparison work on any existing or custom type that you will create (assuming you implement the expected interface for a range).&lt;/p&gt;
&lt;p&gt;Another thing I like are the syntax choices that make the language simple and predictable. For example you cannot have multiple inheritance of classes (only of interfaces) so you cannot fall into the &lt;a href=&#34;https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem&#34;&gt;diamond problem&lt;/a&gt; like in C++ or Java. Furthermore all that in C++ is achieved with the pre-processor and template metaprogramming can be achieved with the same syntax that you use for writing runtime code. More on this later.&lt;/p&gt;
&lt;h2 id=&#34;built-in-dynamic-and-associative-arrays&#34;&gt;Built-in dynamic and associative arrays&lt;/h2&gt;
&lt;p&gt;I like to define D as a wonderful marriage between C and Python. You have the advantages of compiled code with the powerful features of Python.&lt;/p&gt;
&lt;p&gt;In my experience, when coding, I will use dynamic and associative arrays (aka maps or dictionaries) 80% of the time. Having them built in the language is a incredible productivity boost as you don&amp;rsquo;t have to import some library or build your own. Furthermore you have dedicated syntax that make using them much less verbose than it would as if they were and external library.&lt;/p&gt;
&lt;p&gt;Some examples:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Create a dynamic array of 10 ints, initialized to 0
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;array&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Take a slice of the second half
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;half&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;array&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mf&#34;&gt;4.&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;dup&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Increment all elements by one (array-wise expression)
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;half&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Concatenate the two arrays
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;concat&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;array&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;~&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;half&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Create an associative array
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;dict&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Hello&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;World&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;23&lt;/span&gt; &lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Execute the code if &amp;#34;Hello&amp;#34; exists
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;*&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;value&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Hello&amp;#34;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;dict&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;c1&#34;&gt;// do something with value
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Element wise comparison
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;assert&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;dict&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;dict&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;generics-types&#34;&gt;Generics Types&lt;/h2&gt;
&lt;p&gt;Generic types are a breeze in D. They are intuitive and the compiler does a lot of smart inference behind the scene to optimize the resulting code.&lt;/p&gt;
&lt;p&gt;An example to give an idea:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Generic types are pre-pended to the actual arguments
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;lhs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;rhs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;lhs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;rhs&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;o&#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;c1&#34;&gt;// T is deduced to int
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Explicitly force T to be float
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result2&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;5.0&lt;/span&gt;&lt;span class=&#34;o&#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;c1&#34;&gt;// T is deduced to float
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result3&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What is even better is that a safe subset of D code can be evaluated by the compiler &lt;strong&gt;at compile time&lt;/strong&gt; thus allowing the possibility of checking complex conditions.&lt;/p&gt;
&lt;p&gt;For example here is function that can only be used when the types satisfy the given condition:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;find&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;E&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;haystack&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;E&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;needle&lt;/span&gt;&lt;span class=&#34;o&#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;c1&#34;&gt;// Check that T and E can be compared for inequality
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;is&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typeof&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;haystack&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;o&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;needle&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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;c1&#34;&gt;// Actual code of find()
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This example shows how to accept a variable number of arguments with different types:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// This function accepts variadic template parameters
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;write&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;...)(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;c1&#34;&gt;// This foreach loop is unrolled at compile time!
&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;c1&#34;&gt;&lt;/span&gt;	&lt;span class=&#34;k&#34;&gt;foreach&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;arg&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;args&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;c1&#34;&gt;// to() is a convenience function from the std library to convert types
&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;c1&#34;&gt;&lt;/span&gt;		&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;stringArg&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;to&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;arg&lt;/span&gt;&lt;span class=&#34;o&#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;stdout&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;rawWrite&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;stringArg&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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;o&#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&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;write&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;There are &amp;#34;&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;s&#34;&gt;&amp;#34; cows&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;compile-time-code-generation-metaprogramming&#34;&gt;Compile Time Code Generation (Metaprogramming)&lt;/h2&gt;
&lt;p&gt;I have hinted that D allows you to execute code at compile time, so why not execute code at compile time that generates other code? Let me explain that: you can generate strings, that contain D code, at compile-time, and have the compiler include them in your executable. Enter the magic world of the keyword &lt;code&gt;mixin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you need to generate a large structure of pre-computed values, you can do it!.&lt;/p&gt;
&lt;p&gt;If you need to generate boilerplate code and you want to avoid typing it, you can do it!&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Returns &amp;#34;int[name] = [0, 1, ..., count - 1]&amp;#34;;
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;createArray&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;string&lt;/span&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;s&#34;&gt;&amp;#34;int[&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;~&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;to&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;~&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;] &amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#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;n&#34;&gt;name&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;~&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34; = [ &amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#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;foreach&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&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;o&#34;&gt;..&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#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;n&#34;&gt;to&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;o&#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;s&#34;&gt;&amp;#34;, &amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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;s&#34;&gt;&amp;#34;];&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#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;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// here the magic happens
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mixin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;createArray&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;myArray&amp;#34;&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&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;assert&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;myArray&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;o&#34;&gt;]&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;o&#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;assert&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;myArray&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Creating raw strings may be overkill in some situations. So there is also a way to create injectable scopes of code with &lt;code&gt;mixin template&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;mixin&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;Foo&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;func&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;writeln&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Foo.func()&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;o&#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;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Bar&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;o&#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;mixin&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Foo&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;test&lt;/span&gt;&lt;span class=&#34;o&#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;o&#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;Bar&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Bar&lt;/span&gt;&lt;span class=&#34;o&#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;b&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;func&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// calls Foo.func()
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you need to generate super duper optimized code for custom use-case, you can do it! A great example of this are &lt;a href=&#34;https://dlang.org/phobos/std_regex.html#ctRegex&#34;&gt;compile time regexes&lt;/a&gt; which can generate optimized native machine code to match any regex.&lt;/p&gt;
&lt;h2 id=&#34;garbage-collector&#34;&gt;Garbage Collector&lt;/h2&gt;
&lt;p&gt;Some people may not consider the GC a feature, I certainly did not at the beginning. I came from a hard-core game developer mindset where you need to know the exact timing for every operation in your critical path. I lived by quotes like: &amp;ldquo;the programmer knows better how to manage memory&amp;rdquo; and &amp;ldquo;you cannot have unexpected pauses for GC collection&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;However it turns out that unless you are writing a computer game, a high frequency trading system, a web server, or anything that really cares about sub-second latency, chances are that a garbage collector is your best friend. It will remove the burden of having to think about memory management at all and at the same time guarantee that you won&amp;rsquo;t have any memory leaks in your code.&lt;/p&gt;
&lt;p&gt;In case you are writing a performance critical piece of software, remember you can turn off the garbage collector! People on forums like to bash that in such case you cannot use many functions from standard library. So what? If performances are essential for your system you are likely already writing you own utility library with highly optimized algorithms and data structures for your use case, so you won&amp;rsquo;t really miss the standard library much.&lt;/p&gt;
&lt;h2 id=&#34;hacker-features&#34;&gt;Hacker Features&lt;/h2&gt;
&lt;p&gt;If you had ever worked in the most &amp;ldquo;esoteric&amp;rdquo; aspect of coding such as: writing shellcodes, assembly language, executable packing, obfuscation, process hacking, etc. Here are a couple of gems that you&amp;rsquo;ll love:&lt;/p&gt;
&lt;p&gt;Hexadecimal strings:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Same as &amp;#34;\xAB\xCD\x01\x23\x45&amp;#34;
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;ABCD012345&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Including binary blobs&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-d&#34; data-lang=&#34;d&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Inline the content of &amp;#34;resource.bin&amp;#34;
&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;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;import&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;resource.bin&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;mature-developer-tools&#34;&gt;Mature developer tools&lt;/h2&gt;
&lt;p&gt;Compared to Go or Rust that have the backing of big companies, D took many years to get a solid ecosystem of productivity tools. I blame this as the main reason for D not being more widely adopted today.&lt;/p&gt;
&lt;p&gt;However nowadays there are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;3 compilers: the official reference compiler DMD, &lt;a href=&#34;https://wiki.dlang.org/GDC&#34;&gt;GCC&lt;/a&gt;, and &lt;a href=&#34;https://wiki.dlang.org/LDC&#34;&gt;LLVM&lt;/a&gt; which cover any architecture which you may want to develop for.&lt;/li&gt;
&lt;li&gt;Autocompletion and debugging for all &lt;a href=&#34;https://wiki.dlang.org/Editors&#34;&gt;major IDEs&lt;/a&gt;: Visual Studio, VS Code, Vim, Emacs, Sublime Text.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;package-manager&#34;&gt;Package Manager&lt;/h2&gt;
&lt;p&gt;In line with modern programming languages such as Python, Node Js and C#, D has it&amp;rsquo;s own official package manger, called &lt;a href=&#34;https://code.dlang.org/&#34;&gt;DUB&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To be honest here, the package ecosystem is not nearly as developed as Python or Node Js. But this is to be expected given the lower adoption that D has. Nevertheless you have the most common use cases covered such as web development, protocols such as gRPC or REST, parsers, interfaces with commonly used libraries like SDL, OpenGL, Linux and Windows system libraries.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Hopefully this post has gave you a bit of curiosity to learn about D yourself. If that&amp;rsquo;s the case I suggest you to spend 30 minutes on this &lt;a href=&#34;https://tour.dlang.org/&#34;&gt;interactive tutorial&lt;/a&gt; which will teach you the 80% of the language feature and practice them from your browser.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Ok, that&amp;rsquo;s nice&amp;hellip;&amp;rdquo;, you may say, &amp;ldquo;&amp;hellip;but what about real work, can I get paid to learn and write in D?&amp;rdquo;. Well sort of. There are a very few places in the world that hire people to write in D, but they are niches which you will love and they will love you back if you have the hacker mentality which has pushed you to learn this elegant programming language. You can find them on Google ;)&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&#34;https://news.ycombinator.com/item?id=29863557&#34;&gt;Comments&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Designing Data Intensive Applications, Chapter 1</title>
      <link>https://aradaelli.com/blog/designing-data-intensive-application-chapter-1/</link>
      <pubDate>Wed, 22 Dec 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/designing-data-intensive-application-chapter-1/</guid>
      <description>&lt;p&gt;This post is a summary of chapter 1 from the book &amp;ldquo;Designing Data Intensive Applications&amp;rdquo;. Chapter 1 introduces the fundamental terminology and metrics to evaluate data-intensive applications.&lt;/p&gt;
&lt;p&gt;At the time of writing, &amp;ldquo;DDIA&amp;rdquo; is the number 1 best seller on Amazon in the category &amp;ldquo;Data Modeling &amp;amp; Design&amp;rdquo;. In the book, the author, &lt;a href=&#34;https://martin.kleppmann.com/&#34;&gt;Martin Kleppmann&lt;/a&gt; covers the architecture of a broad range of databases and distributed data processing systems that are essential knowledge for engineers that want to to develop distributed, scalable modern applications that process huge amount of data.&lt;/p&gt;
&lt;h2 id=&#34;data-intensive-applications&#34;&gt;Data Intensive applications&lt;/h2&gt;
&lt;p&gt;Data-intensive means that the application is bounded by the amount of data, its complexity, and the speed at which the data is changing. This is opposed to compute-intensive application which are bounded by the amount of raw CPU power available.&lt;/p&gt;
&lt;p&gt;Data-intensive applications are usually built from standard building blocks. These blocks have been defined empirically over a long period of time. These blocks are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Databases: for medium and long term data storage.&lt;/li&gt;
&lt;li&gt;Caches: for speeding up reads and remembering the result of expensive operations for short term.&lt;/li&gt;
&lt;li&gt;Search indexes: to search and filter data in various ways, efficiently.&lt;/li&gt;
&lt;li&gt;Stream processing: for sending data to another process to be handles asynchronously.&lt;/li&gt;
&lt;li&gt;Batch processing: for periodically processing a large amount of accumulated data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However each of this blocks can be implemented in many different ways and most of the time an implementation can fall in more than one category. Therefore we need a more granular way to categorize data systems and we can use the non-functional requirements that we want from the system that ultimately we want to design:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reliability&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Maintainability&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;reliability&#34;&gt;Reliability&lt;/h3&gt;
&lt;p&gt;Reliable means that the system should work correctly (performing the correct function at the desired level of performance) even in faces of errors.&lt;/p&gt;
&lt;p&gt;Errors can be caused by hardware (power outages, hard disk failures, network partitioning, etc.), by software (code bugs, exhaustion of resources, cascading faults), or by the humans that operate those systems.&lt;/p&gt;
&lt;p&gt;Hardware errors can be reduced by adding redundancy, ex. backup generators, RAID systems, multiple network connections.&lt;/p&gt;
&lt;p&gt;Software errors can be reduced with testing, behavior monitoring, process isolation.&lt;/p&gt;
&lt;p&gt;Human errors can be reduced with sandboxes (i.e. non-production environments), gradual roll outs and fast roll backs, telemetry, training.&lt;/p&gt;
&lt;h3 id=&#34;scalability&#34;&gt;Scalability&lt;/h3&gt;
&lt;p&gt;As the system grows in data volume, traffic volume, or complexity there should be reasonable ways to handle that growth.&lt;/p&gt;
&lt;p&gt;Growth can happen on many axis such as number of concurrent users, volume of information processed, number of read and writes, or something else. These factors depends on the architecture of the system and they ultimately affect its &lt;em&gt;load&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Once these load factors have been identified we can define how their changes affect the performances of the system, again which performances we care about depends on the nature of the system. Examples of performance metrics are throughput, latency, or response time.&lt;/p&gt;
&lt;p&gt;When reporting on performance metrics it is common to use the average. However it is usually better to use &lt;a href=&#34;https://en.wikipedia.org/wiki/Percentile&#34;&gt;&lt;em&gt;percentiles&lt;/em&gt;&lt;/a&gt; (such as the median) because they tells how many users actually experience that performance. Also by looking at the higher percentiles you can see how bad your outliers are.&lt;/p&gt;
&lt;p&gt;Copying with load can be done in two ways: horizontal or vertical scaling. In reality you will most likely use a pragmatic mixture of the two approaches.&lt;/p&gt;
&lt;p&gt;While distributing the stateless services across multiple machines is fairly straightforward, taking a stateful system from a single machine to a distributed model can introduce a lot of complexity. The architecture of systems that operate at large scale is usually highly specific to the application.&lt;/p&gt;
&lt;h3 id=&#34;maintainability&#34;&gt;Maintainability&lt;/h3&gt;
&lt;p&gt;New people working on the system should be able to work on it productively either maintaining the current behavior or implementing new use cases.&lt;/p&gt;
&lt;p&gt;Three design principles help when creating maintainable systems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Operability: make it easy for the operations teams to keep the system running smoothly (health monitoring, debugging, capacity planning, establishing good practices for deployment and configuration, documentation, good defaults, predictable behavior).&lt;/li&gt;
&lt;li&gt;Simplicity: make it easy for new engineers to understand the system, by removing complexity as much as possible (good abstractions, decoupling of components).&lt;/li&gt;
&lt;li&gt;Evolvability: make it easy for engineers to make changes to the system in the future, adapting it for unanticipated use cases as requirements change (this is closely related to simplicity as easy to understands systems are usually easier to modify than complex ones).&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Stock Market Screener Demo</title>
      <link>https://aradaelli.com/blog/stock-screener/</link>
      <pubDate>Wed, 15 Dec 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/stock-screener/</guid>
      <description>&lt;p&gt;In the last couple of years I have been actively investing my savings in the Stock Market. I have learned a lot on how finance works but long story short, I am not interested in investing in the stock market anymore since I came to realize that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I don&amp;rsquo;t own enough capital to make substantial returns&lt;/li&gt;
&lt;li&gt;Beating the market average is difficult (it requires a &lt;em&gt;lot&lt;/em&gt; of time)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Therefore I&amp;rsquo;m better off by focusing on my job and investing in &lt;strong&gt;myself&lt;/strong&gt; rather than than the stock market. At least for the next 5 years or so.&lt;/p&gt;
&lt;p&gt;My surplus money can track the market average and I stay clear from crypto, on which I am not willing to risk any substantial amount of money, but that&amp;rsquo;s for another post.&lt;/p&gt;
&lt;p&gt;Anyway, before my crush on the stock market faded-and feeding off my engineering spirit-I was fascinated by the idea of developing my own &lt;a href=&#34;https://en.wikipedia.org/wiki/Automated_trading_system&#34;&gt;trading bots&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Developing trading strategies needs at minimum:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A strategy (duh!)&lt;/li&gt;
&lt;li&gt;Market data to backtest the strategy&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I decided to focus on market data first, and I quickly realized that there is no real good free source of it, unless you want to pay $$$. Then I found out about &lt;a href=&#34;https://www.alphavantage.co/&#34;&gt;Alpha Vantage&lt;/a&gt; which is a market data provider with a generous free tier which gives unlimited access to global market data, but it comes with a strong rate limit on the speed at which you can read it.&lt;/p&gt;
&lt;p&gt;So I went to work and developed a few Python scripts that would slowly crawl  Alpha Vantage each day and collect price and company information in a database from which I could easily run query or make simulations via &lt;a href=&#34;https://jupyter.org/&#34;&gt;Jupiter Notebooks&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I managed to get a working crawler but then quickly lost my interest in developing strategies. Instead of throwing away my work I decided to turn it in a basic stock market screener to add to my portfolio by adding a web interface on top.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/stock-screener/images/architecture.svg&#34;&gt;
    &lt;picture&gt;
      
      &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/stock-screener/images/architecture.svg&#34; alt=&#34;Architecture Diagram&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Architecture Diagram&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The project is mainly composed of 3 components: the Data Ingestion service, the Database, and the Stock Screener web app. They are all hosted on &lt;a href=&#34;https://azure.microsoft.com/en-gb/&#34;&gt;Microsoft Azure&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The arrows in the diagram represent the flow of market data.&lt;/p&gt;
&lt;p&gt;The Data Ingestion service is the crawler that I mentioned earlier. It is written in Python and uses &lt;a href=&#34;https://www.python-httpx.org/&#34;&gt;httpx&lt;/a&gt; to download data from Alpha Vantage and &lt;a href=&#34;https://github.com/mkleehammer/pyodbc/wiki&#34;&gt;pyodbc&lt;/a&gt; to talk with the database. I spent some time learning how to use async programming with Python to be able to parallelize the HTTP requests to Alpha Vantage, but then I hit the bottleneck of pyodbc which does not have async support at the moment.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot1.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot1_hu_2ed772ca555bfc91.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot1_hu_ed2ab6737022ca23.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot1_hu_94c61e212cc8b441.png&#34; alt=&#34;Stock List&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Stock List&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The Database is a classic relational SQL database which is good enough for my use case, without having to disturb the folks in the NoSQL world.&lt;/p&gt;
&lt;p&gt;The Web App is built with &lt;a href=&#34;https://dotnet.microsoft.com/en-us/apps/aspnet&#34;&gt;ASP.NET Core&lt;/a&gt;. The frontend uses Bootstrap 5, &lt;a href=&#34;https://htmx.org/&#34;&gt;htmx&lt;/a&gt; and &lt;a href=&#34;https://alpinejs.dev/&#34;&gt;Alpine.js&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is the first time I have worked with ASP.NET. Overall it was a good experience, ASP.NET is a mature technology with plenty of documentation. I developed the web app entirely within Visual Studio 2022 to see what Microsoft is up these days and I found it very simple to use and quite snappy. I was surprised to find out that Visual Studio Code with the C# Extension is capable to replace Visual Studio entirely, debugging capabilities included! I could do the development entirely on Linux or Mac seamlessly.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot2.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot2_hu_ff39b89b61aa1fbb.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot2_hu_6d0a213a951e27bc.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/stock-screener/images/screenshot2_hu_25a523fddd11f24a.png&#34; alt=&#34;Company Overview&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Company Overview&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The code is hosted on &lt;a href=&#34;https://github.com/skilion/stock-screener&#34;&gt;GitHub&lt;/a&gt;. A running demo can be accessed at &lt;a href=&#34;http://stock-screener-web-app.azurewebsites.net&#34;&gt;http://stock-screener-web-app.azurewebsites.net&lt;/a&gt; at least until the billing starts to be higher than a few quids a month.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Code, Chapter 5: Formatting</title>
      <link>https://aradaelli.com/blog/clean-code-chapter-5/</link>
      <pubDate>Fri, 10 Dec 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/clean-code-chapter-5/</guid>
      <description>&lt;p&gt;This post is a summary of chapter 5 of the book &amp;ldquo;Clean Code&amp;rdquo;, entitled &amp;ldquo;Formatting&amp;rdquo;. Chapter 5 contains guidelines to use when formatting your code.&lt;/p&gt;
&lt;p&gt;Code formatting is important. The organization, layout and arrangement of your code is a form of communication. And the quality of communication is what distinguishes a professional developer from a beginner.&lt;/p&gt;
&lt;h2 id=&#34;the-newspaper-metaphor&#34;&gt;The Newspaper Metaphor&lt;/h2&gt;
&lt;p&gt;Write your code like a well-written newspaper article. At the top you expect a headline and a summary that allow you to decide if it something that you want to read. As you continue downward all the details and facts of the story appear giving you the entire picture.&lt;/p&gt;
&lt;p&gt;Code should be written the same way. At the top put the high level concepts and algorithms and the bottom put the lowest level functions and details.&lt;/p&gt;
&lt;p&gt;If the newspaper were just one long story containing disorganized information and facts, then it would not be usable, and we would not read it.&lt;/p&gt;
&lt;h2 id=&#34;vertical-formatting&#34;&gt;Vertical Formatting&lt;/h2&gt;
&lt;p&gt;As a rule of the thumb the shorter the file the better. The number of lines in a source file should rarely be more than 500 and if longer you should consider splitting the functionality. The sweet spot should be between 100-200 lines.&lt;/p&gt;
&lt;p&gt;A typical source files has different concepts: package declaration, imports, class definition, properties, methods. We want to separate these concepts with blank lines to help the eye distinguish between the text blocks that make them up. Empty lines give visual cues to the eyes of the developer so that he can read the first line and decide whether to skip to the next block or keep reading.&lt;/p&gt;
&lt;p&gt;Code that is tightly related should appear close together and vertically dense (without blank lines) to help the reader identify code that has similar functionality.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Local variables should be declared as close as possible to their usage.&lt;/li&gt;
&lt;li&gt;Class properties should be declared at the top (or at the bottom depending on the convention) of the class but never in the middle. Properties are variables that should be used by most of the methods in the class.&lt;/li&gt;
&lt;li&gt;Functions that call each other (dependent functions) should be vertically close.&lt;/li&gt;
&lt;li&gt;Some functions may represents related concepts by having common naming or doing variations of the same basic task (conceptual affinity). They may not call each other but they fit nicely together. Examples: read and write, get and set, open and close.&lt;/li&gt;
&lt;li&gt;Function call dependencies should point to the bottom of the file. It means that the most called functions like utility and shared functions should be toward the end of the file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;horizontal-formatting&#34;&gt;Horizontal Formatting&lt;/h2&gt;
&lt;p&gt;Similarly to file length, as a rule of the thumb the shorter the lines in the file the better.&lt;/p&gt;
&lt;p&gt;You may have heard of the &lt;a href=&#34;https://en.wikipedia.org/wiki/Punched_card#The_Hollerith_card&#34;&gt;Hollerith limit&lt;/a&gt; of 80 characters per line, which is a bit arbitrary, and it does not really make sense anymore since we have wide monitors that can easily show up to 100-120 characters. However if the line starts to be longer than 200, it is a bit ridiculous and you must split it.&lt;/p&gt;
&lt;p&gt;Use horizontal white space to associate things that are strongly related and disassociate things that are more weakly related.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add space around operators to highlight precedence&amp;rsquo;s (ex. &lt;code&gt;var x = -a + b*c*d - 4*a;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t add space between function names and parameters but add space between the comma separated parameters (ex. &lt;code&gt;Console.WriteLine(&amp;quot;Welcome &amp;quot;, username, &amp;quot;!&amp;quot;);&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;dont-use-horizontal-alignment&#34;&gt;Don&amp;rsquo;t Use Horizontal Alignment&lt;/h3&gt;
&lt;p&gt;The alignment in code emphasize the wrong things. It is not useful to read code by column. If you have long lists that need to be aligned the problem is the length of the list and not the lack of alignment.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;CompanyOverview&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;   &lt;span class=&#34;n&#34;&gt;Symbol&lt;/span&gt;                  &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;   &lt;span class=&#34;n&#34;&gt;Description&lt;/span&gt;             &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;   &lt;span class=&#34;n&#34;&gt;Country&lt;/span&gt;                 &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;Price&lt;/span&gt;                   &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;   &lt;span class=&#34;n&#34;&gt;Currency&lt;/span&gt;                &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt;     &lt;span class=&#34;n&#34;&gt;MarketCapitalization&lt;/span&gt;    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt;     &lt;span class=&#34;n&#34;&gt;OutstandingShares&lt;/span&gt;       &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;PeRatio&lt;/span&gt;                 &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;CompanyOverview&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Symbol&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Description&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Country&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Price&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Currency&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;MarketCapitalization&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;long&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OutstandingShares&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;float&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;PeRatio&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;get&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;indentation&#34;&gt;Indentation&lt;/h3&gt;
&lt;p&gt;A source file is a hierarchy. There is information that belong to the file as a whole, to the individual classes, to the methods within the classes, and the code blocks within the methods.&lt;/p&gt;
&lt;p&gt;Indentation adds a visual cue to perceive this hierarchy, it allows the developer to rapidly see the structure of the file. Without it code would be an unreadable mess.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t break indentation for short statements. Maintain a consistent hierarchy even for one-liners.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Pizza&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;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;readonly&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&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;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;readonly&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredients&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;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&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;Pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;AddIngredient&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredient&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredients&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ingredient&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Pizza&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;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;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;readonly&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&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;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;readonly&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredients&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;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&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;Pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&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;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;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;name&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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;AddIngredient&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredient&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;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;ingredients&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ingredient&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;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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;team-rules&#34;&gt;Team Rules&lt;/h2&gt;
&lt;p&gt;Most of the time in your career you will be working with other people on an existing codebase. When working in a team, learn and follow the conventions that have been set by team mates. Everybody should agree on one convention and stick to it because consistency is more important than following best practices (which can sometime be arbitrary). As a programmer I expect the formatting I see in one file to be be the same in others. Having multiple styles adds unnecessary complexity.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Code, Chapter 4: Comments</title>
      <link>https://aradaelli.com/blog/clean-code-chapter-4/</link>
      <pubDate>Sat, 27 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/clean-code-chapter-4/</guid>
      <description>&lt;p&gt;This post is a summary of chapter 4 of the book &amp;ldquo;Clean Code&amp;rdquo;, entitled &amp;ldquo;Comments&amp;rdquo;. Chapter 4 contains a few examples of what to do and not to do when commenting code.&lt;/p&gt;
&lt;h2 id=&#34;comments-do-not-make-up-for-bad-code&#34;&gt;Comments Do Not Make Up for Bad Code&lt;/h2&gt;
&lt;p&gt;Having to write comments is often a failure of writing &lt;em&gt;expressive&lt;/em&gt; code. The code itself should be explaining what it is doing.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t use a comment when you can introduce a function.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Check to see if the pizza is cooked&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;p&#34;&gt;((&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;flags&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;COOKING_FLAG&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cookingTime&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;15&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;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;c1&#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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;isCooked&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;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;c1&#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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don&amp;rsquo;t use a comment if a variable can be renamed to add more context.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// time when the user submitted the request&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;TimeStamp&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;theTime&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;TimeStamp&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;userRequestTime&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;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// length in kilometers&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;kt&#34;&gt;double&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;routeLenght&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;double&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;routeLenghtInKilometers&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;/div&gt;&lt;h2 id=&#34;good-comments&#34;&gt;Good Comments&lt;/h2&gt;
&lt;p&gt;There are situations when comments are necessary and useful. Here are some cases.&lt;/p&gt;
&lt;h3 id=&#34;informative-comments-and-clarifications&#34;&gt;Informative Comments and Clarifications&lt;/h3&gt;
&lt;p&gt;Informative comments give information when the code cannot be more expressive than it already is.&lt;/p&gt;
&lt;p&gt;For example, when dealing with regular expressions it may be useful to add a description.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// match dates in the format dd.mm.yyyy only between years 1900-2099&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;dateMatcher&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Regex&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;@&amp;#34;(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})&amp;#34;&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;/div&gt;&lt;h3 id=&#34;explanation-of-intent&#34;&gt;Explanation of Intent&lt;/h3&gt;
&lt;p&gt;Sometimes a piece of code may may look odd. It could make the reader think: &amp;ldquo;Why was it written this way?&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;When you are writing something unconventional do add a comment to help the future developers understand your intentions.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;updatePage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Content&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;content&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;body&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;content&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;view&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;invalidate&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;c1&#34;&gt;// Invalidate the view twice to avoid rendering errors&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;view&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;invalidate&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;switch&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;operationType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OperationType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;READ&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;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OperationType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;UPDATE&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;row&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;refresh&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;break&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;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OperationType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DELETE&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;row&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;markToDelete&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;break&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;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OperationType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;CREATE&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;c1&#34;&gt;// do nothing&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;break&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;warning-of-consequences&#34;&gt;Warning of Consequences&lt;/h3&gt;
&lt;p&gt;Sometimes it is useful to warn about consequences that are not immediately apparent to the readers.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Trigger the operating system limit of running threads&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;c1&#34;&gt;// It will make the OS unresponsive for a few seconds&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;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&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 class=&#34;m&#34;&gt;0&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;&amp;lt;&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;1_000_000&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 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;thread&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;start&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;amplification&#34;&gt;Amplification&lt;/h3&gt;
&lt;p&gt;A comment may be used to amplify the importance of some operation that may otherwise be seen as unimportant.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Trigger the operating system limit of running threads&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;c1&#34;&gt;// It will make the OS unresponsive for a few seconds&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;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&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 class=&#34;m&#34;&gt;0&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;&amp;lt;&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;1_000_000&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 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;thread&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;start&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;public-apis&#34;&gt;Public APIs&lt;/h3&gt;
&lt;p&gt;When using a third-party library I always look for good documentation. It makes using them much more easier.&lt;/p&gt;
&lt;p&gt;If you are building a public interface that will be released to the world or used by other teams in your company, do add comments on it. It is preferred to use a standard format for this type of comments (such as Javadoc for Java or &lt;code&gt;///&lt;/code&gt; comments for C#) that allows you to generate documentation from your code.&lt;/p&gt;
&lt;h3 id=&#34;todo-comments&#34;&gt;TODO Comments&lt;/h3&gt;
&lt;p&gt;&amp;ldquo;To do&amp;rdquo; comments indicate that future work is needed but the developer just does not have the time to do it right now.&lt;/p&gt;
&lt;p&gt;Nowadays most IDEs have functionality to keep track of them so you can go back and get rid of them.&lt;/p&gt;
&lt;p&gt;They are is useful for example to explain why a function has an incomplete implementation and what should be done in the future.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sendText&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;message&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;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;c1&#34;&gt;// TODO: actually send the email&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;return&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;bakePizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Pizza&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pizza&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;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;c1&#34;&gt;// TODO: should use the new FireOven class&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;oven&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ElectricOven&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&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;oven&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setTemperatureDegrees&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;250&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;oven&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;waitUntilTemperatureIsReached&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;oven&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bake&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pizza&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;bad-comments&#34;&gt;Bad Comments&lt;/h2&gt;
&lt;h3 id=&#34;redundant-and-noise-comments&#34;&gt;Redundant and Noise Comments&lt;/h3&gt;
&lt;p&gt;Comment that does not add any useful information to the code is useless and should not be added. Like describing the content of a variable when its name already does a good job.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Pizza&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;c1&#34;&gt;// The ID of the pizza&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;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;id&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// The list of ingredients&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;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Ingredient&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ingredients&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// Default constructor&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;Pizza&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;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;c1&#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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;journal-comments&#34;&gt;Journal Comments&lt;/h3&gt;
&lt;p&gt;Sometimes people add a comment to record what they have changed. This comments accumulate to create a journal or log.&lt;/p&gt;
&lt;p&gt;However there is no need for such comments as your version control system does that for you already.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#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;cm&#34;&gt;  2021-01-25: Add support for HTTPS
&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;cm&#34;&gt;  2021-02-03: Retry download three times before failing
&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;cm&#34;&gt;  2021-02-05: Add getFileSize()
&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;cm&#34;&gt;  2021-03-18: Implement IFileStream
&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;cm&#34;&gt;*/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;position-markers&#34;&gt;Position Markers&lt;/h3&gt;
&lt;p&gt;Position Markers ends up just adding noise. Its better to let the proper indentation and code formatting to give the visual structure to your code.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cs&#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;c1&#34;&gt;// Actor class&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;cs&#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;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Actor&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;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;c1&#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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;commented-out-code&#34;&gt;Commented Out Code&lt;/h3&gt;
&lt;p&gt;There is no need to leave commented code. Control version system are good to keep track of what was there before. If you have committed it you won&amp;rsquo;t lose it.&lt;/p&gt;
&lt;p&gt;If you leave commented code the next developer will ask himself why. Are they important? Are they reminders? Or are they just leftovers no one bothered to clean up?&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Code, Chapter 3: Functions</title>
      <link>https://aradaelli.com/blog/clean-code-chapter-3/</link>
      <pubDate>Thu, 18 Nov 2021 09:50:39 +0000</pubDate>
      <guid>https://aradaelli.com/blog/clean-code-chapter-3/</guid>
      <description>&lt;p&gt;This post is a summary of chapter 2 of the book &amp;ldquo;Clean Code&amp;rdquo;. Entitled &amp;ldquo;Functions&amp;rdquo;, Chapter 3 introduces a series of principles to be used when writing functions. Functions deserve a full chapter about them because they are the first level of abstraction in any program.&lt;/p&gt;
&lt;h2 id=&#34;1-single-responsibility-principle-srp&#34;&gt;1. Single-responsibility Principle (SRP)&lt;/h2&gt;
&lt;p&gt;Your function should do one thing and that thing should clearly be stated in its name. At a glance, anybody can understand what it does without looking at the code.&lt;/p&gt;
&lt;p&gt;What does this principle mean in practice? It means that your function should only perform a handful of operations that are one level of abstraction below its name. If the function tries to do more than that, then you should be able to extract more functions by refactoring it.&lt;/p&gt;
&lt;p&gt;There are two signals that tells if a function is doing more than one thing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The number of lines of code is more than 20 or 30.&lt;/li&gt;
&lt;li&gt;There are more than 2 or 3 &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, and &lt;code&gt;while&lt;/code&gt; statements (nested or not).&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;synchronizeRemoteItems&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;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;Server&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getServerInstance&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;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getAvailableItems&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;foreach&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;Identifier&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;id&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getId&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;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;hasItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&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;RemoteItem&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteItem&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&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;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;remoteItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getHash&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getHash&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;())&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;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;upload&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&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;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;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&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;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;upload&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&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;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;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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;synchronizeRemoteItems&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;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;Server&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getServerInstance&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;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getAvailableItems&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;foreach&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;ensureItemIsSynced&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&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;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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ensureItemIsSynced&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Server&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&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;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;Identifier&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;id&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getId&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;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;hasItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&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;RemoteItem&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteItem&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&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;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;remoteItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getHash&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;getHash&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;())&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;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;upload&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&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;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;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&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;remoteServerInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;upload&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&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;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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Another relevant example is error handling. &amp;ldquo;Try/catch&amp;rdquo; blocks confuse the structure of the code and mix error processing with the business logic. So it is better to extract the bodies of the try and catch blocks out into functions of their own.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;synchronizeRemoteItems&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;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;try&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;Server&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getServerInstance&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;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getAvailableItems&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;foreach&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;ensureItemIsSynced&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&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;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;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;catch&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ConnectionException&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;logException&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&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;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;SyncFailedException&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;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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;synchronize&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;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;try&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;synchronizeRemoteItems&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;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;catch&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ConnectionException&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;logException&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&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;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;SyncFailedException&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;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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;synchronizeRemoteItems&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;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;Server&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getServerInstance&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;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getAvailableItems&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;foreach&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Item&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;item&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&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;ensureItemIsSynced&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remoteServerInstance&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;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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;2-use-the-least-number-of-arguments&#34;&gt;2. Use the least number of arguments&lt;/h2&gt;
&lt;p&gt;The more arguments the more difficult is to understand what the function does. You should never use more than 3 arguments. If you find yourself in the situation it is likely that some of those arguments should be wrapped in a &lt;code&gt;struct&lt;/code&gt; or &lt;code&gt;class&lt;/code&gt; because they are part of a concept that deserves a name of its own.&lt;/p&gt;
&lt;p&gt;Also, never use boolean flags. They imply that the function does two things, one when the flag is true and one when it&amp;rsquo;s false. What you really need is two distinct functions.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;drawRectangle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;width&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;height&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Rectangle&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;y&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;width&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;height&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;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&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;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;drawRectangle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Rectangle&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;rect&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;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;makePizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;vegan&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;makePizza&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;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;makeVeganPizza&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;/div&gt;&lt;h2 id=&#34;3-have-no-side-effects&#34;&gt;3. Have No Side Effects&lt;/h2&gt;
&lt;p&gt;Side effects are unexpected changes to the state of the program. It may be in the form of &lt;strong&gt;global variables&lt;/strong&gt; or unexpected variables of the class of the same method.&lt;/p&gt;
&lt;p&gt;Side effects create temporal coupling. Temporal coupling is an implicit relationship requiring the client to invoke one function after another. Basically it means that a function can only be called at certain times and incurring in the risk of unexpected side effects at others.&lt;/p&gt;
&lt;p&gt;If you must have side effects they should be clearly made explicit in the function name, ex. &lt;code&gt;Initialize()&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;4-avoid-output-arguments&#34;&gt;4. Avoid Output Arguments&lt;/h2&gt;
&lt;p&gt;Function that use output arguments are confusing and should be avoided in general. It&amp;rsquo;s not immediate to understand that an argument is an output and you certainly have to look the definition.&lt;/p&gt;
&lt;p&gt;Output arguments were widely used before object oriented (OO) programming, however in an OO language the need for output arguments disappears because when you are a calling a method, the object owning it is the intended output argument (&lt;code&gt;this&lt;/code&gt;).&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;addCheese&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Pizza&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Cheese&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;cheese&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;pizza&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cheese&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;/div&gt;&lt;h2 id=&#34;5-commandquery-separation&#34;&gt;5. Command/Query Separation&lt;/h2&gt;
&lt;p&gt;A function should either do something or answer a query, but not both. Doing both leads to confusion and it likely indicates that the function is doing two things.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Hashmap&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;setIfKeyExists&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;key&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;value&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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Hashmap&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;exists&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;key&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;key&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;value&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Returning error codes count as breaking this rule. It leads to creating deeply nested &lt;code&gt;if&lt;/code&gt; statements because you need to handle the errors immediately. Using exceptions instead enables to keep the business logic and the error processing code separated resulting in simplified code.&lt;/p&gt;
&lt;h2 id=&#34;6-dont-repeat-yourself-dry&#34;&gt;6. Don&amp;rsquo;t Repeat Yourself (DRY)&lt;/h2&gt;
&lt;p&gt;&amp;ldquo;Avoid code duplication&amp;rdquo; is something you have been told to death if you had a formal education in computer science, and for a good reason. If there is an algorithm that gets duplicated N times, the source code will require to be modified N-times should that algorithm ever change.&lt;/p&gt;
&lt;p&gt;Also the readability of your code base is improved if reduntant code is replaced with a single function.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Code, Chapter 2: Meaningful Names</title>
      <link>https://aradaelli.com/blog/clean-code-chapter-2/</link>
      <pubDate>Fri, 12 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/clean-code-chapter-2/</guid>
      <description>&lt;p&gt;This post is a summary of chapter 2 of the book &amp;ldquo;Clean Code&amp;rdquo;. Entitled &amp;ldquo;Meaningful Names&amp;rdquo;, Chapter 2 introduces a series of principles to be used when naming variables, functions, arguments, classes, and packages.&lt;/p&gt;
&lt;p&gt;At the time of writing, &amp;ldquo;Clean Code&amp;rdquo; is the number 3 best seller on Amazon in the category &amp;ldquo;Software Design, Testing &amp;amp; Engineering&amp;rdquo;. In the book, the author, &lt;a href=&#34;https://en.wikipedia.org/wiki/Robert_C._Martin&#34;&gt;Robert &amp;ldquo;Uncle Bob&amp;rdquo; Martin&lt;/a&gt; promotes a coding style that is simple to read and understand.&lt;/p&gt;
&lt;p&gt;Before I started coding professionally, I understated the value of choosing good names for variables and functions. Today I believe that a codebase with well named variables, functions, classes, etc. can be almost free of comments because the names themselves are enough to give context to the reader about what&amp;rsquo;s going on.&lt;/p&gt;
&lt;p&gt;Before diving in the rules, please note that the naming convention does not matter. A name could be &lt;code&gt;camelCaseName&lt;/code&gt;, &lt;code&gt;snake_case_name&lt;/code&gt; or even &lt;code&gt;kebab-case-name&lt;/code&gt;. The only thing that matters is which convention you use.&lt;/p&gt;
&lt;h2 id=&#34;1-use-intention-revealing-names&#34;&gt;1. Use Intention-revealing Names&lt;/h2&gt;
&lt;p&gt;The name of a declaration should make the reader understand exactly what it contains. As a rule of the thumb, if a declaration requires a comment, then the name does not reveal its intent.&lt;/p&gt;
&lt;p&gt;Avoid one letter names. Disregard the fact that they are widely used in examples and snippets, in that context they are mainly used to save space. When you are writing code professionally you are writing code that will be read and re-read by many people after you. Space is not a concern, brain cycles are.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t be afraid to make a name long. Long descriptive is better than short enigmatic.&lt;/p&gt;
&lt;p&gt;Examples:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;d&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// elapsed time in days&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;elapsedTimeInDays&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;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;len&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;myString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Length&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;for&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&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 class=&#34;m&#34;&gt;0&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;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;len&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 class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;cm&#34;&gt;/* ... */&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;myStringLength&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;myString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Length&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;for&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;charNum&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;charNum&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;myStringLength&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;charNum&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;++)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;cm&#34;&gt;/* ... */&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;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getContractIds&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;list&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;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;cm&#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;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;list&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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;private&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getContractIds&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;contractIds&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;List&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;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;cm&#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;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;contractIds&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;2-make-meaningful-distinctions&#34;&gt;2. Make Meaningful Distinctions&lt;/h2&gt;
&lt;p&gt;When you have similar named declarations it becomes confusing.&lt;/p&gt;
&lt;p&gt;A common case is number-series naming. They provide no clue of the author intention. For example a numbered series of parameters: &lt;code&gt;contract1&lt;/code&gt;, &lt;code&gt;contract2&lt;/code&gt;, &lt;code&gt;contract3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Another case is variables padded with noise words: &lt;code&gt;contractInfo&lt;/code&gt;, &lt;code&gt;contractData&lt;/code&gt;, &lt;code&gt;contractObject&lt;/code&gt;. They should be distinguished in such a way that the reader knows what are the differences they offer.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;copyMessage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Message&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;msg1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Message&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;msg2&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;copyMessage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Message&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;destination&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Message&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;source&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;/div&gt;&lt;h2 id=&#34;3-use-pronounceable-names&#34;&gt;3. Use Pronounceable Names&lt;/h2&gt;
&lt;p&gt;Names that you write will eventually be used in spoken language. This matters because programming is a social activity, people talk about and discuss code. If the names cannot be pronounced they will create additional burden when connecting sound to meaning.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ddMmYyyy&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DateTime&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Now&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ToString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;dd/MM/yyyy&amp;#34;&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ddddMmmmYyyy&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DateTime&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Now&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ToString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;dddd, dd MMMM yyyy&amp;#34;&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;shortDateTime&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DateTime&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Now&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ToString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;dd/MM/yyyy&amp;#34;&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;kt&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;longDateTime&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DateTime&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Now&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ToString&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;dddd, dd MMMM yyyy&amp;#34;&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;/div&gt;&lt;h2 id=&#34;4-use-searchable-names&#34;&gt;4. Use Searchable Names&lt;/h2&gt;
&lt;p&gt;Single-letter names and numeric constants are difficult to be searched. You may want to locate them for refactoring or simply reference but they end up being part of other definitions.&lt;/p&gt;
&lt;p&gt;Numeric constants are bad in general and its a well known &lt;a href=&#34;https://en.wikipedia.org/wiki/Magic_number_%28programming%29#Unnamed_numerical_constants&#34;&gt;counterproductive behavior&lt;/a&gt;. Hopefully you have been told about this one in your early days of learning programming.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;d&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;5&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;m&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#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;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&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 class=&#34;m&#34;&gt;0&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;&amp;lt;&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;365&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;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&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;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 class=&#34;n&#34;&gt;d&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;7&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;m&#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;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;m&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;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;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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DaysInYear&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;365&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;kd&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DaysInWeek&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;7&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;kd&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Monday&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;startWeekDay&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;5&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;mondaysCountInYear&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#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;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;day&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;day&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DaysInYear&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;day&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;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;p&#34;&gt;((&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;day&lt;/span&gt;  &lt;span class=&#34;p&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;startWeekDay&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DaysInWeek&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Monday&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;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;mondaysCountInYear&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;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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;5-avoid-encodings&#34;&gt;5. Avoid Encodings&lt;/h2&gt;
&lt;p&gt;Prefixing the type to variable names, the (&lt;a href=&#34;https://en.wikipedia.org/wiki/Hungarian_notation&#34;&gt;Hungarian Notation&lt;/a&gt;), is a reminiscence from a time when computer where several times less powerful and compilers far less developer friendly. Nowadays our IDEs can tell the type of our variables and the compiler can enforce static checking of types. Having the type encoded in the variable name makes harder to change the name and type of a variable plus it makes it harder to read!&lt;/p&gt;
&lt;p&gt;Other obscure practices like prefixing &lt;code&gt;m_&lt;/code&gt; to class properties or prefixing &lt;code&gt;_&lt;/code&gt; for private members is unnecessary. Your classes should be small enough that you don&amp;rsquo;t need them. Moreover, your editing environment can highlight class members to make them distinct from other declarations.&lt;/p&gt;
&lt;h2 id=&#34;6-class-names-are-nouns-methods-names-are-verbs&#34;&gt;6. Class Names Are Nouns, Methods Names Are Verbs&lt;/h2&gt;
&lt;p&gt;Classes and objects should have a noun or noun phrase names like: &lt;code&gt;Contract&lt;/code&gt;, &lt;code&gt;ContractParser&lt;/code&gt;, &lt;code&gt;FutureContract&lt;/code&gt;. Again avoid &amp;rsquo;noise&amp;rsquo; words like &lt;code&gt;Object&lt;/code&gt;, &lt;code&gt;Data&lt;/code&gt;, or &lt;code&gt;Info&lt;/code&gt;, that do not add anything useful to the name.&lt;/p&gt;
&lt;p&gt;Methods should have a verb or a verb phrase like &lt;code&gt;calculateValue&lt;/code&gt;, &lt;code&gt;save&lt;/code&gt;, &lt;code&gt;rollForward&lt;/code&gt;. Access, mutators, and predicates should be named for their value and prefixed with &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;is&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Contract&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sign&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;send&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;getMoneyAmount&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;isValid&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;7-pick-one-word-per-concept&#34;&gt;7. Pick One Word per Concept&lt;/h2&gt;
&lt;p&gt;Before writing new code to a repository it is essential to look at what is already there to imitate the naming style and the concept used.&lt;/p&gt;
&lt;p&gt;Many concepts have synonyms ex. &amp;ldquo;Controller&amp;rdquo; have synonyms like &amp;ldquo;Manager&amp;rdquo; or &amp;ldquo;Driver&amp;rdquo;. Another example: &amp;ldquo;Adapter&amp;rdquo;, &amp;ldquo;Decorator&amp;rdquo;, and &amp;ldquo;Wrapper&amp;rdquo;. &amp;ldquo;Aggregate&amp;rdquo;, &amp;ldquo;Collection&amp;rdquo;, and &amp;ldquo;Container&amp;rdquo;. &amp;ldquo;Fetch&amp;rdquo;, &amp;ldquo;Retrieve&amp;rdquo;, and &amp;ldquo;Get&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;You should word between synonyms and stick to it across your codebase.&lt;/p&gt;
&lt;h2 id=&#34;8-use-solution-and-problem-domain-names&#34;&gt;8. Use Solution and Problem Domain Names&lt;/h2&gt;
&lt;p&gt;Choose technical names for those thing which is appropriate. By technical terms I mean topics from Computer Science like algorithms, design patterns, mathematical terms, well-known acronyms.&lt;/p&gt;
&lt;p&gt;When there are no technical names for what you are doing, use names from the problem domain. You should at least be aware of the lexicon used by the client of your software, or else in you can always ask a domain expert.&lt;/p&gt;
&lt;h2 id=&#34;9-add-meaningful-context&#34;&gt;9. Add Meaningful Context&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s rare that declarations are meaningful by themselves. Most are closely linked to others. It makes sense to enclose them together in well-named struct, class, or namespace.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c#&#34; data-lang=&#34;c#&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;addressNumber&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;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;addressRoad&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;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;city&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;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;postCode&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&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Becomes:&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&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;struct&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Address&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;number&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;road&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;city&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;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;postCode&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;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Setting up my website</title>
      <link>https://aradaelli.com/blog/setting-up-my-website/</link>
      <pubDate>Mon, 01 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/setting-up-my-website/</guid>
      <description>&lt;p&gt;Hello world!&lt;/p&gt;
&lt;p&gt;Last week I got a back injury after a long streak of attending &lt;a href=&#34;https://en.wikipedia.org/wiki/Brazilian_jiu-jitsu&#34;&gt;Brazilian Jiu-Jitsu&lt;/a&gt; sparring sessions. So I am now forced to take rest and I have decided to build my personal website to host my portfolio and blog.&lt;/p&gt;
&lt;p&gt;In the past I would have built everything from scratch, which is fantastic to learn a lot. However it is quite stupid to waste 80% of my time reinventing the wheel and 20% writing actual content. So I have decided to give a go to &lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo&lt;/a&gt; a static website generator. So far I am quite impressed. It hits the sweet spot for me in terms of automation and flexibility. No doubt it is so popular.&lt;/p&gt;
&lt;p&gt;Using a pre-made template is a breeze, however I want to customize it fully so I am writing my own theme from scratch.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Bluetooth RGB Light</title>
      <link>https://aradaelli.com/blog/bluetooth-rgb-light/</link>
      <pubDate>Sat, 30 Oct 2021 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/bluetooth-rgb-light/</guid>
      <description>&lt;p&gt;I was scouting Amazon and eBay for a controllable light to bring to parties, but I was left disappointed. The low end market is full of low power lights which are not bright enough and are controlled through a lousy remote controller. To get decent devices you need to go in the high end space where you can easily spend a few hundreds quids.&lt;/p&gt;
&lt;p&gt;So I thought I should come up with my own solution.&lt;/p&gt;
&lt;p&gt;I started by coming up with a list of requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Portable and battery powered&lt;/li&gt;
&lt;li&gt;Multicolor&lt;/li&gt;
&lt;li&gt;Powerful enough to light up a dark room&lt;/li&gt;
&lt;li&gt;Controllable with a smartphone app&lt;/li&gt;
&lt;li&gt;Programmable with custom effects&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Given those requirements I started searching online for electric components that would fit the requirements.&lt;/p&gt;
&lt;p&gt;Since the light would be battery powered, energy consumption is critical. The most efficient form of lighting is provided by LEDs. I wanted a multicolor light so it needed to be an RGB led. I settled on a 10 watts &lt;a href=&#34;https://en.wikipedia.org/wiki/Chip_on_board&#34;&gt;Chip-on-Board (COB)&lt;/a&gt; RGB LED.&lt;/p&gt;
&lt;p&gt;For communication between the light and my smartphone I chose the &lt;a href=&#34;https://duckduckgo.com/?q=espressif+esp32&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;ESP32 microcontroller&lt;/a&gt; which, for less than 5 quids, gives you: Wireless, Bluetooth, 32 KiB of RAM, and 34 programmable pins, &lt;a href=&#34;https://en.wikipedia.org/wiki/Pulse-width_modulation&#34;&gt;Pulse-width modulation (PWM)&lt;/a&gt; signals, and much more which is not relevant for this project.&lt;/p&gt;
&lt;p&gt;For driving the LED, I was initially thinking of buying 3 separate LED driver modules, but they are quite expensive (compared to buying the individual components separately) unless you order them from China through Aliexpress or similar. However that would mean waiting for at least one month for delivery, so I decided to build my own LED driver from discrete components. Comparing the chips that existing LED driver are using and the availability of those chip I settled for using the &lt;a href=&#34;https://duckduckgo.com/?t=ffab&amp;amp;q=PT4115+schematic&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;PT4115&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Only when the chips arrived I realized that I had ordered them in the &lt;a href=&#34;https://en.wikipedia.org/wiki/Surface-mount_technology&#34;&gt;Surface-mount technology (SMD)&lt;/a&gt; package. Those are intended to be soldered on a custom &lt;a href=&#34;https://en.wikipedia.org/wiki/Printed_circuit_board&#34;&gt;printed circuit board (PCB)&lt;/a&gt;. However for my prototype I intended to use a simple soldering protoboard, so I had to solder &amp;ldquo;legs&amp;rdquo; to all the SMD components in order to be able to plug them in the protoboard.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/legs.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/legs_hu_14a20086173b4b3.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/legs_hu_13b2afe9970f65d8.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/legs_hu_a06d0119c6675e33.jpg&#34; alt=&#34;Adding &amp;ldquo;legs&amp;rdquo; to the PT4115&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Adding &amp;ldquo;legs&amp;rdquo; to the PT4115&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The circuit to run the PT4115 is quite simple and a reference design can be found in the official specifications along with the rules to pick the side components.&lt;/p&gt;
&lt;p&gt;For Reference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;DIM&lt;/strong&gt; is the PWM control pin&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CSN&lt;/strong&gt; is the control sensing pin which helps the chip detect the amount of current going in the LED&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SW&lt;/strong&gt; is the switch pin which is turned on and off automatically to keep the right amount of current flowing through the LED.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/pt4115_circuit.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/pt4115_circuit_hu_f858ef92ed79c806.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/pt4115_circuit_hu_afe51043540ce57b.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/pt4115_circuit_hu_fde041e5a46a3cb3.png&#34; alt=&#34;PT4115 sample circuit&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;PT4115 sample circuit&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Initially I thought to build my own case for the light, but after a quick search on eBay I found many variations of outdoor flood lights which I could simply modify for my purposes.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/original-light.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/original-light_hu_b6ed8e0cbb33d198.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/original-light_hu_3cf8eb3e4a3fb9.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/original-light_hu_3c285a66d7940497.jpg&#34; alt=&#34;Light Front&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Light Front&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The light from eBay came with its own LED driver mounted on the back. It was quite bulky and unnecessary so it was the first thing I removed.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/back-open.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/back-open_hu_ff4c7e49304cf2b9.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/back-open_hu_8b76a2bc034164fa.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/back-open_hu_388046c13c128ad5.jpg&#34; alt=&#34;Original LED Driver&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Original LED Driver&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Then I proceeded to open the led compartment and finding out how much space I had to fit my own circuits. I was pleased to find out that the case was quite oversized and I had plenty of space to fit everything I needed.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-1.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-1_hu_57858cf81e8f22e2.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-1_hu_34a5fd41a21710ed.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-1_hu_11669d0c6a64ac3c.jpg&#34; alt=&#34;Frame unmounted&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Frame unmounted&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-2.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-2_hu_ed9303da9fc2864a.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-2_hu_9bef7ab0a5c5b32d.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/front-open-2_hu_b72c6ff32bca540.jpg&#34; alt=&#34;Original LED&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Original LED&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The next step was to build the LED driver. I used a small piece of protoboard and duplicated 3 times the circuit that I have showed earlier for the PT4115. In the next photo I have highlighted the small SMD resistors for &amp;ldquo;Rs&amp;rdquo;. It is not an elegant solution, but it works.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/led-driver.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/led-driver_hu_98cd29ab18697a3b.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/led-driver_hu_67c3f3da86b00ef2.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/led-driver_hu_d56a492bfad4ea12.jpg&#34; alt=&#34;RGB LED Driver&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;RGB LED Driver&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;I had to do the same trick of adding &amp;ldquo;legs&amp;rdquo; to the ESP32 module as well in order to solder it. For powering it I chose to use a premade buck converter module, &lt;a href=&#34;https://duckduckgo.com/?q=mini+360+buck+regulator&amp;amp;iax=images&amp;amp;ia=images&#34;&gt;the mini-360&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/esp32.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/esp32_hu_8f7a2b59acc7fd3f.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/esp32_hu_40776aad2895d012.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/esp32_hu_918d7dc9037e9fd8.jpg&#34; alt=&#34;ESP32 WROOM&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;ESP32 WROOM&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Then it was time to connect everything together and test the result. In the next video you can see that the the LED turns on only for a brief moment. That&amp;rsquo;s because as soon as the ESP32 finishes booting its pins enter a low state, effectively turning off the LED drivers and the LED itself.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/videos/first-test.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;p&gt;Having verified that the circuit works I proceeded fitting everything nicely in the light case. I used the black tape to set in place some transparent plastic in order to isolate the circuit from the metal case and avoid shorts. The dangling cables that you can see taped at the top of the next photo are used to flash the firmware on the microcontroller.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/fitted.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/fitted_hu_48949428782ba008.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/fitted_hu_9703b59fd96ad04b.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/images/fitted_hu_dc97eea296022b5d.jpg&#34; alt=&#34;Fitting everything in the light case&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Fitting everything in the light case&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Next, it was time to write the firmware for the ESP32 so that it can control the individual colors and receive the commands from my smartphone. I read extensively the documentation for the ESP32 and found a couple of API for my use case: the &lt;a href=&#34;https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html&#34;&gt;LED Control (LEDC) API&lt;/a&gt; which allows me to output PWM signals and the &lt;a href=&#34;https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/nimble/index.html&#34;&gt;NimBLE library&lt;/a&gt; for Bluetooth Low Energy communication.&lt;/p&gt;
&lt;p&gt;After spending a couple of days understanding the examples from the documentation I managed to put together my own firmware that exposes one Bluetooth LE characteristic that directly maps to the 3 RGB channels of the LED. The code is available on &lt;a href=&#34;https://github.com/skilion/rgb-light-server&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The last remaining task was to build an Android App to connect to the ESP32 and send the light colors. I quickly hacked together a proof of concept that allows me to toggle the basic colors for testing, automatically switch between all colors randomly, flash the color at different speeds, smooth the color transition and control the light intensity (brightness). The code, again, is available on &lt;a href=&#34;https://github.com/skilion/rgb-led-control-app&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And here you can see the final result.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/bluetooth-rgb-light/videos/end-result.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;p&gt;Overall it has been a fun project that allowed me to play with electronics and learn a lot. The prototype hits all my requirements but the brightness is much less than I expected. I think a proper flood light should be at least 50W to make a good impression. I&amp;rsquo;ll come back at this project and see if I can upsize the LED while still keeping everything battery powered.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Map My Mountains</title>
      <link>https://aradaelli.com/blog/mapmymountains/</link>
      <pubDate>Fri, 01 Feb 2019 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/mapmymountains/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In Jan 2018, shortly after my graduation, I was offered a contract to work for a team of PhD students lead by &lt;a href=&#34;https://fraternali.faculty.polimi.it/&#34;&gt;Prof. Piero Fraternali&lt;/a&gt;. The team operated as part of the &lt;a href=&#34;https://www.deib.polimi.it/eng/home-page&#34;&gt;&amp;ldquo;Department of Electronics, Information and Bioengineering&amp;rdquo;&lt;/a&gt; inside the university of &lt;a href=&#34;https://www.polimi.it/&#34;&gt;Politecnico di Milano&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I was hired to develop a &lt;a href=&#34;https://en.wikipedia.org/wiki/Geographic_information_system&#34;&gt;Geographical Information System&lt;/a&gt; (GIS) from scratch to provide good quality data for an ongoing research project. The research project goal was to develop a &lt;a href=&#34;https://en.wikipedia.org/wiki/Machine_learning&#34;&gt;Machine Learning&lt;/a&gt; (ML) algorithm to recognize mountain peaks from the &lt;a href=&#34;https://en.wikipedia.org/wiki/Digital_elevation_model&#34;&gt;Digital Elevation Model&lt;/a&gt; (DEM) of the earth. Essentially a fancy way to find mountains using the 3D model of the earth.&lt;/p&gt;
&lt;p&gt;The outcome of any ML project is highly dependent on the quality of data used as input therefore it is worth to have a good pipeline in place that can clean and filter data.&lt;/p&gt;
&lt;p&gt;Furthermore we planned to use the data produced by the new GIS for &lt;a href=&#34;https://peaklens.com/&#34;&gt;&amp;ldquo;Peaklens&amp;rdquo;&lt;/a&gt; (created by the same team) which is an app that recognizes mountains using the camera of your smartphone. It works great and it is completely free, you should try it out for yourself!&lt;/p&gt;
&lt;h2 id=&#34;the-project&#34;&gt;The Project&lt;/h2&gt;
&lt;p&gt;The project consisted of three main tasks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a data model to store geographical data coming from different data sources with annotations and corrections.&lt;/li&gt;
&lt;li&gt;Create multiple data pipelines to import publicly accessible geographical data sources into our data model.&lt;/li&gt;
&lt;li&gt;Create a web application to allow human annotators to review the data and validate it through &lt;a href=&#34;https://en.wikipedia.org/wiki/Crowdsourcing&#34;&gt;crowdsourcing&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/mapmymountains/images/1.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/1_hu_1d8587b600461718.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/1_hu_b66009590bca7a07.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/mapmymountains/images/1_hu_3db179cbb5f125d2.jpg&#34; alt=&#34;Annotation View - 3D globe&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Annotation View - 3D globe&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;1-data-model&#34;&gt;1. Data Model&lt;/h2&gt;
&lt;p&gt;I kicked off the project with an iterative process of:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Collecting and defining the requirements as use cases.&lt;/li&gt;
&lt;li&gt;Designing a data model to account for the use case.&lt;/li&gt;
&lt;li&gt;Simulating the usage of the data model and finding new questions for the stakeholders.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The process required an interactive process with the people involved in the ongoing ML research project.&lt;/p&gt;
&lt;p&gt;I sketched the data model as &lt;a href=&#34;https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model&#34;&gt;Entity-Relationship&lt;/a&gt; and iteratively improved until it satisfied all the requirements the system needed to support. You can see the final result &lt;a href=&#34;https://gitlab.com/wds-co/mapmymountains/-/tree/main/data-model&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We had informal meetings to decide which database to use. The alternatives were either a traditional relational database (PostgreSQL) or a NoSQL document database (MongoDB).&lt;/p&gt;
&lt;p&gt;In the end we decided to go with PostgreSQL because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no need to scale (storage expectations &amp;lt;100GB, user base &amp;lt;100 people)&lt;/li&gt;
&lt;li&gt;it supports geometrical types out of the box which are convenient for geographical data (points, polylines, polygons)&lt;/li&gt;
&lt;li&gt;strong data consistency (the schema enforces types and relations)&lt;/li&gt;
&lt;li&gt;we expected the need for multiple JOINs between different data sources and user annotations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/mapmymountains/images/2.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/2_hu_9e6386ed9858e59f.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/2_hu_e705e7c1a85d6f8c.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/mapmymountains/images/2_hu_2b7183d1a65ea1b.jpg&#34; alt=&#34;Annotation View - 2D map&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Annotation View - 2D map&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;2-import-from-geographical-data-sources&#34;&gt;2. Import from Geographical Data Sources&lt;/h2&gt;
&lt;p&gt;Once the data model was defined, the next step was to import as much data as possible. For this reason I investigated publicly accessible geographical data sources, studied their format and APIs, wrote and tested scripts to download their data.&lt;/p&gt;
&lt;p&gt;The data model is able to store reference to the unique original identifier of each downloaded element so we could have potentially contributed back to each source following the Open Source spirit of giving back to the community.&lt;/p&gt;
&lt;p&gt;By the time my contract ended I had written scripts to import mountain peaks from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.openstreetmap.org/&#34;&gt;Open Street Maps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.geonames.org/&#34;&gt;GeoNames&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.nrcan.gc.ca/&#34;&gt;Canadian Geographical Names&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dati.lombardia.it/&#34;&gt;Open Data of Regione Lombardia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/mapmymountains/images/3.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/3_hu_dcb868ba577bfa24.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/3_hu_7ee18e3c00638073.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/mapmymountains/images/3_hu_13730976a6a14e84.png&#34; alt=&#34;View to toggle permissions per user&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;View to toggle permissions per user&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;3-crowdsourcing-web-app&#34;&gt;3. Crowdsourcing Web App&lt;/h2&gt;
&lt;p&gt;The last task was the development of a Web App to annotate and review the data. &lt;a href=&#34;https://1drv.ms/w/s!Ar26l2ZvsfJh-2Ntn2FmqRLeCGiJ?e=EJBBAs&#34;&gt;Here&lt;/a&gt; you can peek the requirements specification document.&lt;/p&gt;
&lt;p&gt;For the tech stack we agreed on using &lt;a href=&#34;https://nodejs.org/&#34;&gt;Node Js&lt;/a&gt; for back-end and &lt;a href=&#34;https://vuejs.org/&#34;&gt;Vue Js&lt;/a&gt; for frontend, the main reason being keeping all the code base in Javascript. The web app was hosted on the private cloud of Politecnico di Milano which is based on &lt;a href=&#34;https://www.openstack.org/&#34;&gt;Open Stack&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For visualizations I have used &lt;a href=&#34;https://cesium.com/platform/cesiumjs/&#34;&gt;Cesium Js&lt;/a&gt; which provides interactive 3D globes and &lt;a href=&#34;https://leafletjs.com/&#34;&gt;Leaflet Js&lt;/a&gt; for rendering 2D maps. For the UI I have used &lt;a href=&#34;https://bootstrap-vue.org/&#34;&gt;BootstrapVue&lt;/a&gt; which provides ready to use Vue components based on Bootstrap.&lt;/p&gt;
&lt;p&gt;For the development process I have followed an Agile approach with 2 weeks sprints after which I demoed the new features and collected feedback for the next iteration.&lt;/p&gt;
&lt;p&gt;I really enjoyed working on this project because it allowed me to get full-stack development experience and also some planning skills as I was fully entrusted in defining my tasks and delivering them. During the project I also mentored a student who then helped me in some development tasks.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/mapmymountains/images/4.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/4_hu_1b23dc33dccd1132.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/mapmymountains/images/4_hu_25a9ebb5a2585ed3.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/mapmymountains/images/4_hu_79db7fea1fe8ba1d.png&#34; alt=&#34;View to create new crowdsourcing campaigns&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;View to create new crowdsourcing campaigns&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;live-demo&#34;&gt;Live Demo&lt;/h2&gt;
&lt;p&gt;Before writing this article I decided to host a live instance of the Web App on Amazon AWS so that you can could see it live. I contacted Piero who kindly gave me permission to share the source code of the Web App for my portfolio, since it is not in use anymore.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Resuscitating&amp;rdquo; a project that is &amp;ldquo;only&amp;rdquo; 3/4 years old proved to be more difficult than I thought.&lt;/p&gt;
&lt;p&gt;I expected it to be fully working as I left it. However simply running it locally, using the latest stable Node Js resulted in some weird connection issues with the database that kept making my unit tests fail. I traced it back to the NPM library I used to connect to the DB (pg-promise) and updating it fixed the problem promptly.&lt;/p&gt;
&lt;p&gt;I have also fall victim of a strange bug where the Vue CLI Service did not exit after finishing building the production bundle. This didn&amp;rsquo;t cope well with my goal of having a CI pipeline because it makes the automated process hang and timeout. I fixed it again with more targeted package updates.&lt;/p&gt;
&lt;p&gt;I have tried updating all the NPM packages at once but that resulted in many incompatibilities appearing between my code and the new packages. Since I did not want to spend time fixing code, I only did targeted updates for specific packages.&lt;/p&gt;
&lt;p&gt;This proved me how unstable is the entire NPM/Node Js ecosystem. Today I rather use a self-contained web framework that provides everything out of the box such as ASP.NET, Django, Ruby on Rails, or Laravel, and stay away from the dependency hell that is the Javascript ecosystem with NPM.&lt;/p&gt;
&lt;p&gt;For hosting the Web App I have used: Amazon RDS for the database (I created a PostgreSQL instance), Amazon Elastic Beanstalk for the back-end REST API, and Amazon S3 for the front-end (configured to serve a static website). Both the back-end and front-end are served on vanilla HTTP to avoid having to deal with SSL certificates.&lt;/p&gt;
&lt;p&gt;Overall the setups works quite nicely, it fits well within the limit of the Amazon Free Tier. It also has continuous deployment thanks to Github Actions.&lt;/p&gt;
&lt;p&gt;You can find the live demo at: &lt;a href=&#34;http://mapmymountains.aradaelli.com&#34;&gt;http://mapmymountains.aradaelli.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source code: &lt;a href=&#34;https://gitlab.com/wds-co/mapmymountains&#34;&gt;https://gitlab.com/wds-co/mapmymountains&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;credits&#34;&gt;Credits&lt;/h2&gt;
&lt;p&gt;I want to mention the whole team at Politecnico di Milano with whom I have worked from 2018 to 2019. In 1 year I have learned a lot and I still have a great relationship with them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Piero Fraternali (&lt;a href=&#34;https://fraternali.faculty.polimi.it/&#34;&gt;Website&lt;/a&gt;-&lt;a href=&#34;https://www.linkedin.com/in/pierofraternali/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.co.uk/citations?user=IhFm8bIAAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Chiara Pasini (&lt;a href=&#34;https://www.linkedin.com/in/chiara-pasini-6091a7b5/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.co.uk/citations?user=KC8ZkF0AAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Darian Frajberg (&lt;a href=&#34;https://www.linkedin.com/in/darianf/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.co.uk/citations?user=fWJsLhgAAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Carlo Bernaschina (&lt;a href=&#34;https://www.bernaschina.com/&#34;&gt;Website&lt;/a&gt;-&lt;a href=&#34;https://www.linkedin.com/in/b3rn475/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.co.uk/citations?user=Pt83gAMAAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Nahime Torres (&lt;a href=&#34;https://www.linkedin.com/in/rocionahimetorres/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.co.uk/citations?user=7dZV0f8AAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Sergio Herrera Gonzalez (&lt;a href=&#34;https://www.linkedin.com/in/herrera-sergio/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.com/citations?user=lCD71y0AAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Federico Milani (&lt;a href=&#34;https://www.milanif.it/&#34;&gt;Website&lt;/a&gt;-&lt;a href=&#34;https://www.linkedin.com/in/federico-milani/&#34;&gt;Linkedin&lt;/a&gt;-&lt;a href=&#34;https://scholar.google.com/citations?user=Mtj9iDAAAAAJ&#34;&gt;Google Scholar&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Product Configurator</title>
      <link>https://aradaelli.com/blog/product-configurator/</link>
      <pubDate>Fri, 01 Sep 2017 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/product-configurator/</guid>
      <description>&lt;h2 id=&#34;intro&#34;&gt;Intro&lt;/h2&gt;
&lt;p&gt;In parallel to my master studies I enrolled in an honor program called &lt;a href=&#34;https://www.asp-poli.it/&#34;&gt;Alta Scuola Politecnica&lt;/a&gt;. The greatest thing about this program has been the graduation project which consisted in a collaboration with a real business.&lt;/p&gt;
&lt;p&gt;I joined a team of brilliant colleagues, from different backgrounds in management engineering, mechanical engineering and physics. Together we acted as a consulting team for a business, understood their problem, performed a research about the state of the art and delivered a solution.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/product-configurator/images/configurator.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/configurator_hu_9ca6792b2f04de83.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/configurator_hu_8f2c6991ae085baa.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/product-configurator/images/configurator_hu_26bbc631890e29fe.png&#34; alt=&#34;Screenshot of the website at the end of the configuration process&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Screenshot of the website at the end of the configuration process&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;The project I joined was sponsored by &lt;a href=&#34;https://www.inkmaker.com/&#34;&gt;Inkmaker Srl&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Inkmaker is a global producer of ink dispensing machines. These machines mix ink to produce the exact color required for printing or painting products at industrial scale.&lt;/p&gt;
&lt;p&gt;The ink dispensers are large and quite specialized machines. Clients may have strict constraints concerning the available plant area or uncommon requirements on the ink mixing capabilities. Therefore the development of each machine tends to be quite customized for each client.&lt;/p&gt;
&lt;p&gt;However Inkmaker also have a portfolio of entry-level machines that address the demand of their smaller customer with just a few variations. The vision of Inkmaker was to enable their small customers to self design their equipment by providing a set of standard modules to be mixed and matched. Those modules could be combined producing different assembly combinations and layouts to satisfy most request with minimal involvement from Inkmaker, thus increasing the overall efficiency.&lt;/p&gt;
&lt;p&gt;The solution identified by Inkmaker to realize this vision consisted in the development of a &lt;a href=&#34;https://en.wikipedia.org/wiki/Configurator&#34;&gt;product configurator&lt;/a&gt; that would allow clients to design their own machines with a few clicks, resulting in reduced &lt;a href=&#34;https://en.wikipedia.org/wiki/Lead_time&#34;&gt;lead time&lt;/a&gt; and errors in order interpretations.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/product-configurator/images/inventor.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/inventor_hu_a915d7b703b6e32b.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/inventor_hu_eca931769376c513.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/product-configurator/images/inventor_hu_df8f827ee9471215.png&#34; alt=&#34;Screenshot of a machine assembly&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Screenshot of a machine assembly&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;my-contribution&#34;&gt;My Contribution&lt;/h2&gt;
&lt;p&gt;My work was based on the results of my dear colleagues who took care of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Analyzing the business processes of Inkmaker (sales, design, purchase).&lt;/li&gt;
&lt;li&gt;Understanding the mechanical constraints of the product and define how to modularize it.&lt;/li&gt;
&lt;li&gt;Developing a model for generating a machine starting from the client requirements using the available modules.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I applied my skills in two areas:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Performing a research of the &lt;a href=&#34;https://en.wikipedia.org/wiki/State_of_the_art&#34;&gt;state of the art&lt;/a&gt; of existing product configurators.&lt;/li&gt;
&lt;li&gt;Implementing a prototype product configurator to showcase to Inkmaker.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;state-of-the-art&#34;&gt;State of the Art&lt;/h3&gt;
&lt;p&gt;My first task consisted in researching existing product configurators  to identify the best ones suited for the requirements of Inkmaker.&lt;/p&gt;
&lt;p&gt;I researched both:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Software available &amp;ldquo;off the shelf&amp;rdquo; that could be used to customize a generic product.&lt;/li&gt;
&lt;li&gt;Established product configurators from major retailers to study their offering and capabilities.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I wrote a report that summarized the pros and cons of each product, their features, their user interface (UI) and their configuration process.&lt;/p&gt;
&lt;p&gt;The outcome of the research lead to the discovery of a few products that were fit for Inkmaker use-cases. Here is a feature matrix comparing the products against our requirements:&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/product-configurator/images/feature_matrix.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/feature_matrix_hu_f73a88d65750719.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/feature_matrix_hu_980fda8de43c1119.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/product-configurator/images/feature_matrix_hu_19e88d9078e054f5.png&#34; alt=&#34;Feature matrix comparing selected configurators&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Feature matrix comparing selected configurators&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The best candidate &amp;ldquo;A&amp;rdquo; was &lt;em&gt;Autodesk Configurator 360&lt;/em&gt; (now discontinued).&lt;/p&gt;
&lt;h3 id=&#34;prototype&#34;&gt;Prototype&lt;/h3&gt;
&lt;p&gt;My second task consisted in learning the inner workings of Configurator 360, understanding how to integrate it in a customized experience for Inkmaker, and developing a prototype.&lt;/p&gt;
&lt;p&gt;Configurator 360 was a cloud based &lt;a href=&#34;https://en.wikipedia.org/wiki/Software_as_a_service&#34;&gt;software as a service&lt;/a&gt; (SaaS). CAD designs could be uploaded to it and then displayed through an interactive &lt;a href=&#34;https://en.wikipedia.org/wiki/Web_widget&#34;&gt;web widget&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I decided to build a web application that would first guide the customer through the configuration process, then calculate the best configuration for the ink dispenser, and finally provide the result to Configurator 360 which would then generate the engineering drawings, 3D visualizations, and bill of materials.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/product-configurator/images/requirements.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/requirements_hu_51b94b6bbc12507c.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/requirements_hu_93f9f517241548a0.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/product-configurator/images/requirements_hu_2a52492f85b0caff.png&#34; alt=&#34;Screenshot of the website during the configuration process&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Screenshot of the website during the configuration process&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The web application was built in C# ASP.NET with Javascript and JQuery for frontend. It was deployed on Amazon EC2 to provide a demo to show to Inkmaker. Customer details would be saved in a SQL database for reference and potentially integrate with the company ERP.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/product-configurator/images/architecture.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/architecture_hu_de46d50e215aa43b.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/product-configurator/images/architecture_hu_a2c2579681ea825c.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/product-configurator/images/architecture_hu_227c0dfabde2d8e4.png&#34; alt=&#34;Architecture diagram&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Architecture diagram&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&#34;credits&#34;&gt;Credits&lt;/h2&gt;
&lt;p&gt;I want to credit the rest of the &lt;a href=&#34;https://www.asp-poli.it/projects/modula-web-configurator-for-automatic-dispensing-system/&#34;&gt;Modula&lt;/a&gt; team from which I learned a lot and together we delivered this fantastic project.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Alex Saja (&lt;a href=&#34;https://www.linkedin.com/in/alexsaja/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Alfredo Fantetti (&lt;a href=&#34;https://www.linkedin.com/in/alfredo-fantetti-4722bbb7/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Arianna Rosa Brusin (&lt;a href=&#34;https://www.linkedin.com/in/arianna-rosa-brusin/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Giovanni Prencipe (&lt;a href=&#34;https://www.linkedin.com/in/giovanni-prencipe-926a7311b/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Sara Mottola (&lt;a href=&#34;https://www.linkedin.com/in/saramottola/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Stefano Amato (&lt;a href=&#34;https://www.linkedin.com/in/stefanoamato93/&#34;&gt;Linkedin&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Santa Ski</title>
      <link>https://aradaelli.com/blog/santa-ski/</link>
      <pubDate>Sun, 15 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/santa-ski/</guid>
      <description>&lt;p&gt;This game was made in 48h, for a local &lt;a href=&#34;https://en.wikipedia.org/wiki/Game_jam&#34;&gt;game jam&lt;/a&gt; that I organised with friends when I still was in University (good times).&lt;/p&gt;
&lt;p&gt;This game is a remake of a Microsoft classic: &lt;a href=&#34;https://en.wikipedia.org/wiki/SkiFree&#34;&gt;SkiFree&lt;/a&gt;. The protagonist is supposed to be Santa Claus, in case you were wondering.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/santa-ski/videos/gameplay.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;p&gt;I consider game jams great experiences for learning how to be pragmatical developers.&lt;/p&gt;
&lt;p&gt;Given the short time available one needs to focus on implementing features that matter. You do not have time to waste on writing code that solve problems that are already solved by a mature media framework. Loading assets, audio and video access, are all problems that can be solved immediately and not something worth spending time on like I did for earlier game projects.&lt;/p&gt;
&lt;p&gt;In 2 days, you barely have the time to build the core features of whatever idea you come up with.&lt;/p&gt;
&lt;p&gt;For this project I decided to use C++ with &lt;a href=&#34;https://en.wikipedia.org/wiki/Simple_and_Fast_Multimedia_Library&#34;&gt;SFML&lt;/a&gt; which provides access to graphics and input with very few lines of code.&lt;/p&gt;
&lt;p&gt;I have drawn all the game art, and I am really happy how it has given the game a consistent look&amp;amp;feel, as opposed to downloading a bunch of random images from the internet and mixing them together.&lt;/p&gt;
&lt;p&gt;Overall I am quite satisfied how productive this project has been compared to other ones where I decided to reinvent the wheel by building my own graphic framework from scratch. It is a testament to how building on top of well-established libraries saves time.&lt;/p&gt;
&lt;p&gt;The source code is available on &lt;a href=&#34;https://github.com/skilion/santa-ski&#34;&gt;GitHub&lt;/a&gt; and it can be compiled on Linux.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>We Are Made of Dreams</title>
      <link>https://aradaelli.com/blog/dreams/</link>
      <pubDate>Sun, 12 Oct 2014 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/dreams/</guid>
      <description>&lt;h2 id=&#34;intro&#34;&gt;Intro&lt;/h2&gt;
&lt;p&gt;For me, Minecraft could easily be the greatest game of all time. The main reasons being that it is a &amp;ldquo;meta-game&amp;rdquo;, a game that allows you to build other games.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/dreams/images/minecraft.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/dreams/images/minecraft_hu_98193caba59b47c2.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/dreams/images/minecraft_hu_d0b1de21880dc57d.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/dreams/images/minecraft_hu_bb3b5eeb804d0061.jpg&#34; alt=&#34;Minecraft&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Minecraft&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The first time I played it I was confused by the absence of a story to follow or objective to complete. But the more I played it, the more I started to be addicted because I was building my own world and creating my own rules! The utter simplicity and freedom that a world made of blocks could create really impressed me. Furthermore, people online created (and still are creating) staggering detailed worlds and custom games using official and custom servers.&lt;/p&gt;
&lt;p&gt;After playing Minecraft for a long time, I could not resist to try to build my own 3D engine and replicate the technology behind it. I read many articles which explained the inner workings of the game and then get to code.&lt;/p&gt;
&lt;p&gt;When I got a prototype working, I was puzzled on what to make out of it.&lt;/p&gt;
&lt;p&gt;I didn&amp;rsquo;t want to embark in making a full video game, so I decided to build a self-contained experience, a &lt;a href=&#34;https://en.wikipedia.org/wiki/Demoscene&#34;&gt;demo&lt;/a&gt;; or in simpler terms, an &amp;ldquo;interactive video&amp;rdquo;.&lt;/p&gt;



&lt;div class=&#34;vimeo&#34;&gt;
  &lt;div style=&#34;padding:56.25% 0 0 0;position:relative;&#34;&gt;
    &lt;iframe src=&#34;https://player.vimeo.com/video/223964278?h=25900eaca6&amp;amp;badge=0&amp;amp;autopause=0&amp;amp;player_id=0&amp;amp;app_id=58479&#34; frameborder=&#34;0&#34; allow=&#34;autoplay; fullscreen; picture-in-picture&#34; allowfullscreen style=&#34;position:absolute;top:0;left:0;width:100%;height:100%;&#34;&gt;&lt;/iframe&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;script src=&#34;https://player.vimeo.com/api/player.js&#34;&gt;&lt;/script&gt;
&lt;h2 id=&#34;analysis&#34;&gt;Analysis&lt;/h2&gt;
&lt;p&gt;The code is written in &lt;a href=&#34;https://dlang.org/&#34;&gt;D&lt;/a&gt; as at the time I decided it would become my go to language after a long search for a modern alternative to C++.&lt;/p&gt;
&lt;p&gt;Reading through the code today, the most interesting things are: the world data structure and the renderer architecture.&lt;/p&gt;
&lt;p&gt;The world is implemented as an &lt;a href=&#34;https://en.wikipedia.org/wiki/Octree&#34;&gt;&lt;em&gt;octree&lt;/em&gt;&lt;/a&gt;. An octree can be visualized as a giant cube that encloses all the space available for your world. Each node of the octree divides the space inside the cube in 8 sub-cubes. Then again each cube is recursively split in 8 more sub-cubes, until you arrive to the leaf nodes. A leaf node is the smallest representable unit of the world and it is represented as a single block on the screen.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/dreams/images/octree.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/dreams/images/octree_hu_54a19df92c7179b7.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/dreams/images/octree_hu_54b2a724faf8ad8d.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/dreams/images/octree_hu_cc6887de3dcb7ef6.png&#34; alt=&#34;Octree representation, source: mshgrid.com&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Octree representation, source: mshgrid.com&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;An octree is ideal for a &amp;ldquo;Minecraft like&amp;rdquo; world for two reasons.&lt;/p&gt;
&lt;p&gt;First, it naturally fits a world made of cubes beacause of its direct mapping of leaf nodes to world blocks.&lt;/p&gt;
&lt;p&gt;Second, it is very memory efficient when there are big empty spaces because the leaf nodes are not required to exist at all in memory. That is in contrast to a simple three-dimensional array which would still need to allocate the memeory but mark all the empty elements as &amp;ldquo;null&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;The renderer is built using OpenGL3 and therefore it uses the modern rendering pipeline using shaders. The render is also multithreaded by using multiple worker threads that build meshes in real time every time a world chunk is modified.&lt;/p&gt;
&lt;p&gt;Another thing I love is the built in map editor that allowed me to create the world that you can see in the demo.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/dreams/videos/editor.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h2 id=&#34;downloads&#34;&gt;Downloads&lt;/h2&gt;
&lt;p&gt;The source code is available on &lt;a href=&#34;https://github.com/skilion/dreams&#34;&gt;GitHub&lt;/a&gt; and it can be readily compiled on Windows and Linux. Pre-compiled binaries are also available.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Swizzle</title>
      <link>https://aradaelli.com/blog/swizzle/</link>
      <pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/swizzle/</guid>
      <description>&lt;h2 id=&#34;intro&#34;&gt;Intro&lt;/h2&gt;
&lt;p&gt;In 2013, all my friends were playing &lt;a href=&#34;https://en.wikipedia.org/wiki/Ruzzle&#34;&gt;Ruzzle&lt;/a&gt; on their smartphones. It was the viral game of the year but I was the only one not playing it. I only had a &lt;a href=&#34;https://en.wiktionary.org/wiki/dumbphone&#34;&gt;dumbphone&lt;/a&gt; so I could not join in the fun.&lt;/p&gt;
&lt;p&gt;I was fascinated by how addicting the game was, given its simplicity, and I started thinkering how I could replicate it.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/swizzle/videos/gameplay.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h2 id=&#34;analysis&#34;&gt;Analysis&lt;/h2&gt;
&lt;p&gt;The game is written in &lt;a href=&#34;https://dlang.org/&#34;&gt;D&lt;/a&gt; because at the time I was looking to replace C++ for making games. The more I used C++ the more I found myself spending time avoiding bad patterns and the growing complexity of the language with each major release.&lt;/p&gt;
&lt;p&gt;For this project I did not want to use any off the shelf multimedia framework because I wanted to challenge myself and use as less dependencies as possible. So I ended up having to deal with a lot of interfaces in order to use C libraries such as OpenGL, FreeType, and libpng. It turned out to be a huge amount of work so I reduced the scope and only made it work for Windows and not Linux as initially planned. After spending much of my time making interfaces for the C libraries, the game logic to re-implement Ruzzle turned out to be &lt;em&gt;minuscule&lt;/em&gt; in comparison.&lt;/p&gt;
&lt;p&gt;The game logic is all contained in one class: &lt;a href=&#34;https://github.com/skilion/swizzle/blob/master/word_table.d&#34;&gt;WordTable&lt;/a&gt;. And the most interesting functions are two.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/skilion/swizzle/blob/a2e788be864b15880b18407250bdb9009a3f5e95/word_table.d#L33&#34;&gt;WordTable.reset()&lt;/a&gt;. This function prepares the game board by placing the letters. It starts by taking a random word and placing its letters close to each other in the board. Then this process is repeated until there is no more space left. This algorithm ensures that any game has valid words to be discovered. A simpler approach, where letters are placed randomly in the board could lead to corner cases where no words are available in a game.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/swizzle/images/placing.png&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/swizzle/images/placing_hu_ae911f3ccfe83f3e.png&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/swizzle/images/placing_hu_97cd3b988b166558.png&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/swizzle/images/placing_hu_8134392904c7518.png&#34; alt=&#34;Example of placing the words: HELLO, WORLD, MUSIC&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Example of placing the words: HELLO, WORLD, MUSIC&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/skilion/swizzle/blob/a2e788be864b15880b18407250bdb9009a3f5e95/word_table.d#L128&#34;&gt;WordTable.findPossibleWords()&lt;/a&gt;. This function finds all available words in the game board. It uses a recursive algorithm that tries to match each word in the word list by trying each neighbor letter at the current position.&lt;/p&gt;
&lt;h2 id=&#34;downloads&#34;&gt;Downloads&lt;/h2&gt;
&lt;p&gt;The source code is available on &lt;a href=&#34;https://github.com/skilion/swizzle&#34;&gt;GitHub&lt;/a&gt; and it can be readily compiled on Windows using Visual D. Pre-compiled binaries are also &lt;a href=&#34;https://github.com/skilion/swizzle/releases&#34;&gt;available&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Jump And Run</title>
      <link>https://aradaelli.com/blog/jump-and-run/</link>
      <pubDate>Fri, 02 Sep 2011 00:00:00 +0000</pubDate>
      <guid>https://aradaelli.com/blog/jump-and-run/</guid>
      <description>&lt;h2 id=&#34;intro&#34;&gt;Intro&lt;/h2&gt;
&lt;p&gt;&amp;ldquo;Jump And Run&amp;rdquo; is a game I developed towards the end of high school and the first project I am really proud of.&lt;/p&gt;
&lt;p&gt;I was always attracted by the idea of building my own game but I had never tried it before. I had some basic experience with graphics from reading books and articles online but I only dabbled with some small graphical demos that I made during the long boring ours in our school lab.&lt;/p&gt;
&lt;p&gt;One day I decided to build proper game that would be fun to play with levels and enemies to kill.&lt;/p&gt;
&lt;p&gt;The end result suprised me, it turned out that I could turn my ideas into reality just by putting enough effort into it.&lt;/p&gt;
&lt;p&gt;Here is a gameplay video of the first level:&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/jump-and-run/videos/gameplay.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;When I was a kid the first type of video games I played were &lt;a href=&#34;https://en.wikipedia.org/wiki/Side-scrolling_video_game&#34;&gt;2D Side Scrollers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I still remember the two games which influenced me the most: &lt;a href=&#34;https://en.wikipedia.org/wiki/Super_Mario_Land&#34;&gt;Super Mario Land&lt;/a&gt; and &lt;a href=&#34;https://en.wikipedia.org/wiki/Claw_(video_game)&#34;&gt;Captain Claw&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Super Mario was the first game I ever played. I played it on a &lt;a href=&#34;https://en.wikipedia.org/wiki/Game_Boy&#34;&gt;Game Boy&lt;/a&gt; which my cousins lend to me because my parents were against buying game consoles (&amp;ldquo;You would waste all your time!&amp;rdquo;, so true in hindsight).&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/jump-and-run/images/supermarioland.jpg&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/jump-and-run/images/supermarioland_hu_85c54742f333bd36.jpg&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/jump-and-run/images/supermarioland_hu_8234e65beb6fe9be.jpg&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/jump-and-run/images/supermarioland_hu_bf55dedfd0ad792b.jpg&#34; alt=&#34;Super Mario Land gameplay&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Super Mario Land gameplay&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Later, when the first computer arrived in my home, my first PC game arrived shortly after. Captain Claw was so difficult for me and I never managed to beat the second level until a friend of mine (who had an internet connection! I still had not) discovered that &lt;a href=&#34;https://en.wikipedia.org/wiki/Cheating_in_video_games#Cheat_codes&#34;&gt;cheat codes&lt;/a&gt; were a thing.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
  &lt;a href=&#34;https://aradaelli.com/blog/jump-and-run/images/claw.gif&#34;&gt;
    &lt;picture&gt;
      &lt;source media=&#34;(min-width:600px)&#34; srcset=&#34;https://aradaelli.com/blog/jump-and-run/images/claw_hu_93b544793f8c4aee.gif&#34;&gt;
        &lt;source media=&#34;(min-width:1200px)&#34; srcset=&#34;https://aradaelli.com/blog/jump-and-run/images/claw_hu_c6a7d8e83069621c.gif&#34;&gt;
        &lt;img class=&#34;md__image&#34; src=&#34;https://aradaelli.com/blog/jump-and-run/images/claw_hu_e58142a855f1f1d0.gif&#34; alt=&#34;Captain Claw gameplay&#34;/&gt;
      
    &lt;/picture&gt;
  &lt;/a&gt;
  &lt;figcaption&gt;
    &lt;small&gt;&lt;i&gt;Captain Claw gameplay&lt;/i&gt;&lt;/small&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Jump And Run&amp;rdquo; is my tribute to those games and the endless hours I spent on them. I drew the art myself using &lt;a href=&#34;https://www.gimp.org/&#34;&gt;Gimp&lt;/a&gt;, downloaded the music from the &lt;a href=&#34;https://freemusicarchive.org&#34;&gt;Free Music Archive&lt;/a&gt; and sounds from &lt;a href=&#34;https://freesound.org/&#34;&gt;Freesound&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;analysis&#34;&gt;Analysis&lt;/h2&gt;
&lt;p&gt;Re-reading today the code today I see a lot of &lt;a href=&#34;https://en.wikipedia.org/wiki/Code_smell&#34;&gt;&amp;ldquo;code smells&amp;rdquo;&lt;/a&gt; like huge functions and bad names, however keep in mind that I just finished high school when I wrote it :).&lt;/p&gt;
&lt;p&gt;The game runs on a custom 2D Game Engine which I wrote in C++.&lt;/p&gt;
&lt;p&gt;I appreciate how neatly the generic parts of the engine are split in virtual classes that make sense. The framework of the engine with its initialization code is separate from the game logic. I remember being deeply influenced from the code of famous game engines of the time such as &lt;a href=&#34;https://github.com/stephank/surreal/&#34;&gt;Unreal Tournament&lt;/a&gt; and &lt;a href=&#34;https://github.com/id-Software/Quake-III-Arena&#34;&gt;Quake 3 Arena&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To draw on the screen I used &lt;a href=&#34;https://en.wikipedia.org/wiki/OpenGL&#34;&gt;OpenGL&lt;/a&gt; and for playing sounds I used &lt;a href=&#34;https://en.wikipedia.org/wiki/OpenAL&#34;&gt;OpenAL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I have forgotten how much time I spent rewriting much functionality of the standard library such as string and memory functions, file access, and various data structures. I was motivated by the fact that many game development articles recommended to avoid the standard library as it is not optimized for speed in most cases.&lt;/p&gt;
&lt;h3 id=&#34;map-editor&#34;&gt;Map Editor&lt;/h3&gt;
&lt;p&gt;I was very proud of the built-in map editor which allowed me to build maps with my basic drawing skills that would become alive with sound and enemies.&lt;/p&gt;
&lt;p&gt;The game world is composed of small squares. Each square has a background and foreground texture taken from a &lt;a href=&#34;https://en.wikipedia.org/wiki/Texture_atlas&#34;&gt;sprite sheet&lt;/a&gt;. Furthermore each square has a &amp;ldquo;type&amp;rdquo; property that can make it interact with the player by being solid, lethal, or a coin for example.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/jump-and-run/videos/editor.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h3 id=&#34;particle-system&#34;&gt;Particle System&lt;/h3&gt;
&lt;p&gt;Another thing I remember fondly is the &lt;a href=&#34;https://en.wikipedia.org/wiki/Particle_system&#34;&gt;particle system&lt;/a&gt;. It makes killing enemies very satisfying by releasing a swarm of &amp;ldquo;blood&amp;rdquo; particles which collide with the game world.&lt;/p&gt;
&lt;video controls&gt;
    &lt;source src=&#34;https://aradaelli.com/blog/jump-and-run/videos/splash.mp4&#34; type=&#34;video/mp4&#34;&gt;
&lt;/video&gt;
&lt;h2 id=&#34;downloads&#34;&gt;Downloads&lt;/h2&gt;
&lt;p&gt;The source code is available on &lt;a href=&#34;https://github.com/skilion/jump-and-run&#34;&gt;GitHub&lt;/a&gt; and it can be readily compiled on Windows and Linux. Pre-compiled binaries are also &lt;a href=&#34;https://github.com/skilion/jump-and-run/releases&#34;&gt;available&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>