<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Daniel Kiesshau on Medium]]></title>
        <description><![CDATA[Stories by Daniel Kiesshau on Medium]]></description>
        <link>https://medium.com/@danielkiesshau1?source=rss-42e46fab480a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_GLE479i6UVYdNi4Jv8rOg.jpeg</url>
            <title>Stories by Daniel Kiesshau on Medium</title>
            <link>https://medium.com/@danielkiesshau1?source=rss-42e46fab480a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:10:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielkiesshau1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Vital Role of Data Structures & Algorithms in SW Engineering]]></title>
            <link>https://danielkiesshau1.medium.com/the-vital-role-of-data-structures-algorithms-in-sw-engineering-6b7432292b5e?source=rss-42e46fab480a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b7432292b5e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-career]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <dc:creator><![CDATA[Daniel Kiesshau]]></dc:creator>
            <pubDate>Sat, 04 May 2024 17:36:19 GMT</pubDate>
            <atom:updated>2024-05-04T17:39:31.022Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U76HBdj6ArZ9jyky3KC4Pg.jpeg" /><figcaption><a href="https://www.freepik.com/free-vector/technological-ecology-concept_6600476.htm#query=binary%20tree&amp;position=0&amp;from_view=keyword&amp;track=ais&amp;uuid=1b350063-4564-41ce-929a-e7267152735f">Image by Freepik</a></figcaption></figure><h3>Why is it so important?</h3><ol><li>Tech interviews</li><li>Fundamentals in Software Engineering</li><li>Start seeing patterns in how high-level solutions are architected and low-level libraries are implemented</li></ol><h3>Data Structures &amp; Algorithms in my career</h3><p>At the beginning of my career, I wasn’t tested on algorithms. So, it became something that was always left aside. And to be frank, I didn’t even know why I needed to learn it. I started focusing on it only after 4 years of working experience (I know, really late, right?)</p><p>I recommend people start practicing it earlier because it is like an investment for the long term. You can’t master it in one or three months, and you probably won’t see the connections between what you are practicing and how it is applied in tech.</p><h3>Where will you see the concept applied?</h3><ul><li>Performance Optimization/big O: Why some codes might not be performative and how to optimize them</li><li>Database Optimization/search algorithms: How databases perform queries and optimize them</li><li>System Architecture/Hashing: How workload is divided between instances in a Load Balancer</li><li>Frontend Development/trees: How a library like React renders and decides which component it must update</li><li>Resource Management/array vs linked list: How to manipulate really large lists efficiently</li><li>Cache Implementation/map, linked lists: If I were to build a cache like Memcached, what data structure would I use and how would it impact the performance?</li></ul><p>These are oversimplified examples (and not entirely correct) because some of these require System Design knowledge, and almost always have many alternative solutions. It is just a simple list to instigate curiosity about the importance of the topic (an extensive one might be done in future articles)</p><h3>The most obvious reason to learn</h3><p>Of course, I am talking about tech interviews. Depending on your seniority, you will probably have more rounds of technical interviews testing other things. But if you are applying for a developer position, up to 80 or 90% will request a test of D&amp;A. The more senior position you are applying to, you are also expected to show your soft skills in communication, dealing with ambiguity, etc.</p><p>But the important thing that I have partially already said, is to just start practicing it every day a little and as early as possible in your career</p><h3>Extra benefit from learning D&amp;A</h3><p>Some people probably won’t notice. But there are software engineers who are used to jumping into coding really fast before pondering different solutions (low or high level).</p><p>One of the first things you learn when tackling D&amp;A problems is that you need to be wise in how you approach them. That is a great habit to cultivate. Imagine you are creating a solution architecture that will impact how one startup will develop and run their business in the next 1–2 years, If you just “make it work”, there will be many more problems than if you had taken your time and saw the “big picture” before providing a solution.</p><p>A good problem-solving flow would be:</p><ol><li>Understand the problem</li><li>Try pondering one or two possible ways to solve it</li><li>Draw/Write the solution (no code yet)</li><li>Run a few test cases manually (no code)</li><li>See the costs of your solution [Big(O)]</li><li>See if you can optimize it -&gt; go back to step 3 if that is the case</li><li>Code it!</li></ol><h3>Final suggestions and How I’ve learned it</h3><ol><li>Learn the Data Structure &amp; Famous Algorithms</li><li>Read the book: Grokking Algorithms: An Illustrated Guide for Programmers and Other Curious People</li></ol><ul><li>The book is really good to get a grasp of the concepts in a light way</li></ul><p>3. <a href="https://leetcode.com/">Leetcode</a></p><ul><li>Your go-to place to exercise the brain muscles related to D&amp;A</li><li>Which questions and in what order should you practice? <a href="https://neetcode.io/practice">neetcode</a> got you</li></ul><p>4. Try solving only EASY questions first</p><ul><li>Spend 5–8 min understanding the questions</li><li>If you are interviewing, you want to explain what you are understanding</li><li>Write or draw an algorithm (don’t start coding yet)</li><li>Big(O) — Determine the space and time complexity of the solution</li><li>Run a few test cases by hand to see if your solution will work</li><li>After 15–30min, if you can’t figure out a solution by then, look for the solution on youtube or see at <a href="https://www.youtube.com/@NeetCode">leetcode</a> (they have a solutions tab)</li></ul><p>5. After you are decently consistent in solving easy ones, try throwing a few medium problems</p><h3><strong>Thanks for reading!</strong></h3><p>Feel free to share your opinion and experience in the comments</p><p><a href="https://www.linkedin.com/in/daniel-kiesshau-a23859116/">LinkedIn</a> , <a href="https://substack.com/@danielkiesshau">Substack</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b7432292b5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DORA — Software Delivery Research Metrics]]></title>
            <link>https://danielkiesshau1.medium.com/dora-software-delivery-research-metrics-77514d2a4b59?source=rss-42e46fab480a------2</link>
            <guid isPermaLink="false">https://medium.com/p/77514d2a4b59</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Daniel Kiesshau]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 19:17:13 GMT</pubDate>
            <atom:updated>2022-11-01T19:17:13.147Z</atom:updated>
            <content:encoded><![CDATA[<h3>DORA — Software Delivery Research Metrics</h3><h3>What is DORA?</h3><p>DORA (DEVOPS RESEARCH &amp; ASSESSMENT) is an academic research program that is made from over 32,000 professionals world wide. It shows metrics about how companies are delivering software to their end user (and even cutural aspects related to it).</p><h3>Why should we use DORA or similar researches?</h3><p>DORA is probably one of the best places to benchmark what your team/company are doing compared to other companies in a global research scale. You can even see what are the improvements you should be focusing and how to work on them.</p><h3>How to use it?</h3><p>First things first, I think it is very productive to just take an overall look on a graph google designed that shows how each theme relates to each other. For example, how continuous delivery results in less deployment pain and less rework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*lBO1ciydPdXzKY4tArn9Bw.png" /><figcaption>DORA’s graph showing how each topic is related</figcaption></figure><p>After that, do their <a href="https://www.devops-research.com/quickcheck.html">quick check formulary</a>. This will show how well you are and what you should be focusing on.</p><p>The formulary has 5 simple questions about delivery processes and metrics related to delivering software to the end users.</p><h4>More specifically:</h4><ol><li>Lead time: time to deliver a commit to production</li><li>Deploy frequency</li><li>Time to restore: Time taken to restore a service that has gone down</li><li>Change fail percentage: Amount of bugs generated for each feature deployed to production</li><li>Industry: The industry your organization is</li></ol><p>After that, DORA’s site will show you how your company is compared to other ones from the same industry (or if you want from other industries too), and a suggestion about what you could be working on.</p><h3>Deciding what to focus</h3><p>I answered the quick test as if the company was having some kind of trouble delivering to end users quickly (less than one month to deliver a code change).</p><p>The result of a hypothetical company I did was this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2YC9TmvHEO0qL5LZ255JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0M16abX9Yha2ASC8saMQg.png" /></figure><p>The best thing besides what I already wrote in this article is that google has a lot of content related to what they suggest you to work on.</p><p>You could also see what they are suggesting for you to focus on and go back to the home page of DORA and complement your understading with the macro view the graph of how topics of actions and benefits relates with what you are going to focus.</p><h3>Final comments</h3><p>DORA is an awesome tool and resource I will be using for a long time. It has been doing these types of researches since 2014.</p><p>I felt like I needed to share this because I didn’t see many people talking about it through my career. So there goes my contribution to spreading this wonderful resource.</p><p><a href="https://www.devops-research.com/research.html">DORA — Home Page</a></p><p><a href="https://www.devops-research.com/quickcheck.html">DORA — Quick Check Tool</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77514d2a4b59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoupling Logic From React Components]]></title>
            <link>https://medium.com/swlh/decoupling-logic-from-react-components-f6035646c275?source=rss-42e46fab480a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6035646c275</guid>
            <category><![CDATA[react-best-practices]]></category>
            <category><![CDATA[react-components]]></category>
            <category><![CDATA[react-decouple-logic]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Daniel Kiesshau]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 22:46:36 GMT</pubDate>
            <atom:updated>2020-11-22T20:02:55.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MHuDjUDG6KNaTSwr8F_4-Q.jpeg" /></figure><p>React / React Native techniques to have smaller components</p><p>Have you ever had trouble with big components that have too many responsibilities? Well, so did I. That&#39;s why I&#39;m sharing what I have learned with my experience.</p><p>There are 6 ways (explored in this article) to achieve the decoupling. Each of them have their pros and cons. And we should not try to apply one technique for all scenarios.</p><ol><li><strong>Classes</strong></li><li><strong>Container Components</strong></li><li><strong>Hight Order Components</strong></li><li><strong>Redux + Middlewares </strong>(<strong>Context API </strong>is also a good choice for small projects/functions)</li><li><strong>Custom Hooks</strong></li><li><strong>Render Props</strong></li></ol><h3><strong>Study case</strong></h3><p>Imagine we have a software that have only one page for a restaurant. This page should be responsible for <em>Listing and Filter</em> <strong>available meals</strong>.</p><p>The wireframe given to us was that one bellow, it is a list of meals showing a image, a title and a price of a meal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*CFdgtpR9yYE8XXv4Yvv82A.png" /><figcaption>Basic Listing page with search feature</figcaption></figure><p>Lets keep it simple, abstract that use case for a more complex and bigger example, and you will see it the benefits for using one of the strategies.</p><h3>The &quot;okay&quot; component</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca624b1f303dd7fa62a7f8e296b45e94/href">https://medium.com/media/ca624b1f303dd7fa62a7f8e296b45e94/href</a></iframe><p>The problems with this component is:</p><p><strong>Too many responsibilities: </strong>the component is responsible for <strong><em>making API calls</em></strong>, having the <strong><em>logic to show Load indicator,</em></strong> <strong><em>filter</em></strong> the result and, of course, <strong><em>to show the data</em></strong> to the user.</p><p><strong>API calls in the component: </strong>Generaly that is a bad practice, but it is not the end of the world, we should just be carefull if that api call is reused somewhere else to not repeat code <strong><em>(DRY).</em></strong></p><h3>Classes</h3><p>That aproach can be used to extract API calls, and business logic for domain Models. If we had a bigger app that reused those logics used in this component, we would see a higher impact using classes, but since our case is very basic. We can extract 2 things with classes in this component, <strong>API calls</strong> and <strong>Filter logic</strong>.</p><p><strong>Result</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aa54b09cfb5c057b63ccfcaf05b8cc2/href">https://medium.com/media/9aa54b09cfb5c057b63ccfcaf05b8cc2/href</a></iframe><p>Things will get more interesting now, all techniques ahead can decouple logic and functions from our &quot;<strong>Restaurant&quot;</strong> component.</p><h3><strong>Container Components</strong></h3><p>This time we will split the code for: <strong><em>&quot;getMeals&quot;, &quot;filterMeals&quot; and &quot;load status&quot;.</em></strong><em> </em>In this case we would use <strong>MealContainer</strong> to be the entry component for our app because <strong>&quot;Restaurant&quot; </strong>will receive all actions and data from <strong>props </strong>now.</p><p><strong>Result</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03b60b846b941b43de79035a0e3ef49d/href">https://medium.com/media/03b60b846b941b43de79035a0e3ef49d/href</a></iframe><h3><strong>High Order Component</strong></h3><p>One thing I didn&#39;t see when I first studied HOCs can be used for more things than just to increment <em>New functionalities</em> for other components. With HOCs you can actually separate responsibilities too.</p><p><strong>Result</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/704767e815c916e6503ef9cc342c68c9/href">https://medium.com/media/704767e815c916e6503ef9cc342c68c9/href</a></iframe><p>In this scenario our <strong>&quot;Restaurant&quot; </strong>component became the entry of our app.</p><p>Now you are probably thinking <em>&quot;okay, but you basically changed the name of </em><strong><em>MealsContainer </em></strong><em>to </em><strong><em>withMealsController </em></strong><em>and created a HOC for </em><strong><em>LoadIndicator!&quot;… </em></strong>Exactly! but we have<em> </em>more <strong>flexibility</strong> with this pattern, we can create components that will show our load indicator, and the biggest gain is: being able to<strong> reuse the &quot;MealsController&quot; </strong>for other components <strong>totally decoupled</strong> from our <strong>child component</strong>!</p><h3>Redux + Middlewares</h3><p>To understand this section I assumed you know how to used<strong> Redux + Saga. </strong>If you don&#39;t want check out their documantation think <strong>redux</strong> as a <strong>state manager </strong>and <strong>saga</strong> a <strong>middleware</strong> that helps us to create <strong>async actions</strong> within redux.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67336ce2710569477b0f888cabdc6621/href">https://medium.com/media/67336ce2710569477b0f888cabdc6621/href</a></iframe><p>Using these libraries we have in this case, the same benefits from using HOCs but using them enables us to <strong>&quot;connect&quot; </strong>or<strong> &quot;subscribe&quot; to state or actions </strong>with any component we want, making the components that connect to Redux see only what they need and reuse their functions easily.</p><h3>Custom Hooks</h3><p><strong>Result</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1ed452cc00ffe1e63bbfd87960ddb36/href">https://medium.com/media/b1ed452cc00ffe1e63bbfd87960ddb36/href</a></iframe><h3>Conclusion</h3><p>Our benchmark is the <strong>“okay” component</strong> snippet, that has <strong>50 lines of code </strong>and <strong>0 reusability. </strong>Note that theses techniques are not excludent, I gradually maintained some of the patterns as the examples advanced.<strong><br></strong>Also, consider that this conclusion is not a rule of thumb to apply in any project. Always remeber that any choice comes with a <strong>trade-off,</strong> just learn the concepts and decide <strong>when and which we should apply.</strong></p><h4><strong>Classes</strong></h4><p><strong>Pros:</strong></p><ul><li><strong>reduced 10% </strong>lines of code</li><li>encapsulated logic for API calls and list Filter&#39;s logic</li></ul><p><strong>Cons:</strong></p><ul><li>The component still have a lot of responsibilities</li><li>Low reusability</li></ul><h4><strong>Container Components</strong></h4><p><strong>Pros:</strong></p><ul><li><strong>&quot;Restaurant&quot;</strong> turned into a <em>Presentational Component. </em>That means we can change the way our UI look without caring too much about breaking &quot;controller&quot; logic from <em>Container component</em></li><li>Separeted concerns for <strong>&quot;Restaurant&quot;</strong> to focus only on showing data.</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Gained 16% </strong>lines of code</li><li>Can only be used with <strong>&quot;Restaurant&quot;</strong> component</li></ul><h4><strong>Hight Order Components</strong></h4><p><strong>Pros:</strong></p><ul><li>Same Pros from &quot;<strong>Container Components&quot;</strong></li><li>Can be reused with any component!</li><li><strong>&quot;Restaurant&quot; </strong>component became more readable</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Gained 28% </strong>lines of code</li></ul><h4><strong>Redux + Middlewares</strong></h4><p><strong>Pros:</strong></p><ul><li>Same Pros from “<strong>Hight Order Components&quot;</strong></li><li>Redux enables components to <strong>subscribe to only what we need,</strong> so we have another benefit that wasn&#39;t really explored in this example due to the simplicity.</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Gained 300% </strong>lines of code (This increase of lines of code is scary, but all the boilerplate results in some good trade-offs, explore that in their doc).</li></ul><p><strong>Bonus: </strong>Try to make the redux aproach but using <strong>MobX or Recoil(experimental by the date of this article). </strong>The result is quite interesting.</p><h4><strong>Custom Hooks</strong></h4><p><strong>Pros:</strong></p><ul><li>Same Pros from “<strong>Hight Order Components”</strong></li><li>Better choice because React is highly adopting this pattern, since it is better than using class components.</li></ul><p><strong>Cons:</strong></p><ul><li><strong>Gained 34% </strong>lines of code</li></ul><p><em>Thanks for reading all the way here, any suggestions and critics are welcome :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6035646c275" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/decoupling-logic-from-react-components-f6035646c275">Decoupling Logic From React Components</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Better Practices With Clean Code]]></title>
            <link>https://medium.com/swlh/better-practices-with-clean-code-c8ee6f4979c3?source=rss-42e46fab480a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8ee6f4979c3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Daniel Kiesshau]]></dc:creator>
            <pubDate>Sat, 24 Oct 2020 18:45:52 GMT</pubDate>
            <atom:updated>2020-10-30T02:55:15.406Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8Dw0S-xV-vGbzs-94JMNA.jpeg" /></figure><p><strong>Why should we care about clean code?</strong></p><p>The main reason to care about clean code is due to the developer team&#39;s speed to maintain and deliver more functionalities in an existing project. It&#39;s not just about <em>aesthetics</em>, the people involved in the project will have more ease and less stress to work on it.</p><p><strong>Roadmap to achieve a cleaner code:</strong></p><ul><li>The boy scout rule</li><li>Variables</li><li>Functions</li><li>Comments</li><li>Formatting</li><li>Unit Tests</li><li>Refactoring</li></ul><p><strong>Introduction</strong></p><p>One thing all developers should perceive is that they are writting not only for machines to interpret their code, but for humans either. It&#39;s important because not only others will need to understand the code, but himself too, because he may have started working on other projects or features in the future, and when he comes back, the developer will be out of context.</p><p>So, when we are coding, we should consider the order and &quot;Human&quot; meaning of the classes/functions/variables/components. It must not be just a procedural &quot;cake recipe&quot;.</p><p><strong>The boy scout rule</strong></p><blockquote>Leave your code better than you found it</blockquote><p>That may seem like a obvious advice, and it is! But it&#39;s not about when we leave our project we need to make it perfect. Instead, it advices us to gradually and frequently refactor our code. That way, it won&#39;t slow us down, it will just speed us up when we get back to that code, and since we are not trying to achieve the holy grail, most unrealistic perfect code, it shouldn&#39;t take too long to do it.</p><p><strong>Variables</strong></p><p>Rules that can significantly improve the code:</p><ol><li><strong>Meaningful names</strong></li><li><strong>Pronounceable/Searchable names</strong></li></ol><p><strong>Dirty Example</strong></p><p>Note that <strong>&quot;<em>x&quot;, </em>&quot;<em>y&quot; , &quot;r&quot;, &quot;special&quot;, &quot;anmals&quot;, &quot;f&quot; </em></strong>and<strong><em> &quot;a&quot;</em></strong><em> </em>have names that doesn&#39;t mean anything for humans, they just store values that we need to look in the code for their meaning.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/906d296d258cb282aca2d5fe5c19f0a5/href">https://medium.com/media/906d296d258cb282aca2d5fe5c19f0a5/href</a></iframe><p><strong>Clean Example</strong></p><p>Now we know what each variable does in its context. And we don&#39;t have the magic number &quot;0.5&quot; floating arround, we can see why it is there.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/183f8e53df2eacc831d2ddf3a98dcd72/href">https://medium.com/media/183f8e53df2eacc831d2ddf3a98dcd72/href</a></iframe><p><strong>Functions</strong></p><p>Rules that can significantly improve the code:</p><ol><li><strong>Function names (follow the same principle as variables)</strong></li><li><strong>Size of the function (Vertically and Horizontally)<br></strong>Usually when a functions is too big, it is probably not following the principles of <strong><em>“Single Responsibility Principle”</em> (SRP) </strong>or<strong> <em>“Don&#39;t Repeat Yourself”</em> (DRY).</strong></li><li><strong>It shouldn&#39;t have more than 3 parameter<br>This one is debatable</strong>, but one thing we can all agree is that less parameters is better for testing (since there are less combinations of inputs and expected outputs), understanding and use of the function.</li></ol><p><strong>Dirty Example</strong></p><p>Here we can&#39;t scale the function if we had more loans and we have duplication of codes in lines 19–22 and 26–29.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a78ccffb8f28dffd68f66d82068fc0c7/href">https://medium.com/media/a78ccffb8f28dffd68f66d82068fc0c7/href</a></iframe><p><strong>Clean Example</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbf3353ad63a13b4e030f0d35504e6da/href">https://medium.com/media/bbf3353ad63a13b4e030f0d35504e6da/href</a></iframe><p>4.<strong> Indenting<br></strong>Since the indenting guides us when we are reading, it should always make sense. Content of functions, conditions, classes should match their opening and closing brackets, giving a sense that the code inside the bracket &quot;belongs&quot; to that section.</p><p>5. <strong>Have no side effects<br></strong>In this function, it says to us that it will &quot;check the password passed&quot;, but if you look at line 3, you will see that it has a second responsibility to &quot;startAdminSession&quot; if the password is &quot;Admin&quot;. That is certainly an side effect that this function should not be responsible of.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfe5941b7d9d6c45212b2d2f228cc1e1/href">https://medium.com/media/cfe5941b7d9d6c45212b2d2f228cc1e1/href</a></iframe><p>7. <strong>Guard clauses<br></strong>I started really to notice this when I learned swift language, because it has a <strong><em>&quot;guard (condition) else { return }&quot; </em></strong>statement that really started to make sense for code cleanness for me and check for null variables of course.</p><p><strong>Dirty Example</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56c9c7715603ef9982a6387a5849ec00/href">https://medium.com/media/56c9c7715603ef9982a6387a5849ec00/href</a></iframe><p><strong>Clean example</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e24b599dfce51f31d804f194fd4d0fa/href">https://medium.com/media/9e24b599dfce51f31d804f194fd4d0fa/href</a></iframe><p><strong>Comments</strong></p><p>If you feel the need to write a comment, try to refactor your code first, in a way that it will be self-explanatory. There are cases that they are really hard, but try to minimize the most you can. And there is always a risk that your comment will be left behind in terms of updated to your code, leading to confusion afterwards.</p><p><strong>Good comments</strong></p><ol><li><strong>Warning of consequences: </strong>This one should be used moderately, but it could prevent unwanted consequences from happening.</li><li><strong>TODO/FIXME: </strong>They can be used as reminder, but if written in the project must be prioritized to not accumulate all over the project. Usually that is better controlled outside of the project.</li><li><strong>JSDoc like comment:</strong> They can be used to document more complex code.</li></ol><p><strong>Bad Comments</strong></p><ol><li><strong>Redundant</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9183f423b7701c4d48985e7e667731bc/href">https://medium.com/media/9183f423b7701c4d48985e7e667731bc/href</a></iframe><ol><li><strong>Comments vs Variable/Functions<br></strong>Usually well named variables and functions gives a good notion of what it does. Think about our previous example function <strong>&quot;checkAdmin&quot;</strong>, is it a good name? it could be better, a clearer definition would be <strong>&quot;IsAdminAuthenticated&quot;.</strong></li><li><strong>Commented-out code<br></strong>This one a caught myself falling into it. The problem is if you comment a code and let it stay in your project, no one except you will know if they can delete that code, because it certainly has a reason to being there instead of deleted. If we keep doing that practice, we will overload our project with undesired polution of commented code (of course, there are exceptions for this).</li></ol><p><strong>Unit Tests<br></strong>Best practices of TDD always tells us to write our code first, and then our production code. There are four things you should consider when dealing with tests:</p><ol><li><strong>The three Laws of TDD<br></strong>1. You may not write production code until you have written a failed unit test.<br>2. You may not write more of a unit test than is sufficient to fail and not compiling is failing.<br>3. You may not write more production code than is sufficient to pass the currently failing test.</li><li><strong>One assert per test </strong>(similar to the DRY principle, don&#39;t do too much in a single test)</li><li><strong>F.I.R.S.T</strong></li></ol><ul><li><strong>FAST: </strong>tests should fast, because slow tests will discourge us to run it frequently.</li><li><strong>INDEPENDENT: </strong>tests should not be dependent because they can cause a chain effect of failures that is hard to deal.</li><li><strong>REPEATABLE: </strong>tests should be able to run in any enviroment, develop, homlog, production, it doesn&#39;t matter which environment it is running.</li><li><strong>SELF-VALIDATING: </strong>tests should alway output a boolean, because it will speed up the reading of the result of the tests.</li></ul><p><strong>Restructring vs Refactoring</strong></p><blockquote>Restructuring is any rearrangement of parts of a whole. It’s a very general term that doesn’t imply any particular way of doing the restructuring.</blockquote><blockquote>Refactoring is a very specific technique, founded on using small behavior-preserving transformations (themselves called refactorings)</blockquote><blockquote>— Martin Fowler</blockquote><p><strong>Why refactoring is important?</strong></p><ul><li><strong>Improves the Design of the software</strong></li><li><strong>Boosts programming speed</strong></li><li><strong>It makes code easier to read</strong></li><li><strong>It helps find bugs</strong></li><li><strong>It helps to understand better the code you are working on</strong></li></ul><p>I won&#39;t explore in this article techniques of refactoring, because it would get too long for that. But I just wanted to mention it because it really help us as developers to make a more maintanable project and grow as professionals.</p><p>If you want to know more about this kind of content, try reading the books that are in the <strong>&quot;References&quot;</strong> section, I used them to learn and write this article. Since there is a lot of content there, I just made a synthesis of things that impacted me the most .</p><p><strong>References:</strong></p><p><em>Robert Cecil Martin, Clean Code (Prentice Hall, 2008).</em></p><p><em>Kent Beck and Martin Fowler, Refactoring: Improving the Design of Existing Code ( Addison-Wesley Professional, 2018).</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8ee6f4979c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/better-practices-with-clean-code-c8ee6f4979c3">Better Practices With Clean Code</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>