<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sandrina Pereira</title>
    <description>The latest articles on DEV Community by Sandrina Pereira (@sandrinap).</description>
    <link>https://dev.to/sandrinap</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F186512%2F72de16db-9a66-4d75-a9f2-b96806181367.JPG</url>
      <title>DEV Community: Sandrina Pereira</title>
      <link>https://dev.to/sandrinap</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sandrinap"/>
    <language>en</language>
    <item>
      <title>Git journal (Yet, another cheatsheet)</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Sat, 14 Aug 2021 17:29:19 +0000</pubDate>
      <link>https://dev.to/sandrinap/git-journal-yet-another-cheat-sheet-21a6</link>
      <guid>https://dev.to/sandrinap/git-journal-yet-another-cheat-sheet-21a6</guid>
      <description>&lt;p&gt;Liquid syntax error: 'raw' tag was never closed&lt;/p&gt;
</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A11Y study case: Breaking text on a specific word and Screen Readers implications</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Sun, 20 Sep 2020 17:43:16 +0000</pubDate>
      <link>https://dev.to/sandrinap/a11y-study-case-splitting-text-into-multiple-lines-and-screen-readers-implications-g72</link>
      <guid>https://dev.to/sandrinap/a11y-study-case-splitting-text-into-multiple-lines-and-screen-readers-implications-g72</guid>
      <description>&lt;p&gt;Asking to visually break a sentence in multiple lines on a strategic word is a common request from the design team, especially on landing pages. Eg “Hello /n human being”. However, that might affect a Screen Reader pitch flow in unexpected ways...&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario issue
&lt;/h3&gt;

&lt;p&gt;For example, let's imagine we have the title &lt;strong&gt;"Hello human being"&lt;/strong&gt; and we are asked to break it after the "hello" word.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello   
human being
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some common (poor) approaches I've seen being used around:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Add &lt;code&gt;&amp;lt;br /&amp;gt;&lt;/code&gt; between each line&lt;/strong&gt;: Don't do this! Despite being very common, because of its ease of use, it's semantically incorrect! &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; is meant to be used when the division of lines is significant. E.g. stress addresses, poems, etc...&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Add &lt;code&gt;&amp;lt;span /&amp;gt;&lt;/code&gt; with &lt;code&gt;display:block&lt;/code&gt; between each line&lt;/strong&gt;. This creates the same effect as &lt;code&gt;&amp;lt;br /&amp;gt;&lt;/code&gt; but without any semantics, which is good.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using flexbox:&lt;/strong&gt; Wrapping each line into an &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; and adding flexbox to the sentence itself with &lt;code&gt;flex-direction: column&lt;/code&gt; does the trick too.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, all of these three approaches have the same unexpected result in the VoiceOver screen reader pitch flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected pitch: &lt;em&gt;"Hello human being"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Actual pitch: &lt;em&gt;"Hello" [pause] human being."&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another common practice is to set &lt;code&gt;max-width&lt;/code&gt;, however, that solution is highly dependent on the text content. In this scenario that approach wouldn't work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9yvh2vhxvubcahbgeop6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9yvh2vhxvubcahbgeop6.gif" alt="Shocase failed max-width attempt" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's keep looking for a bulletproof solution instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Possible solution
&lt;/h3&gt;

&lt;p&gt;Among other experiments, using &lt;code&gt;write-space: pre-line;&lt;/code&gt; seem the best solution! We can create a literal newline or use &lt;code&gt;&amp;amp;NewLine;&lt;/code&gt; control character to break the text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"white-space:pre-line;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello       
human being&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"white-space:pre-line;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello &lt;span class="ni"&gt;&amp;amp;NewLine;&lt;/span&gt;human being&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just an example of how HTML semantics and CSS usage can affect the way text is read out loud in ways we might not expect.&lt;/p&gt;

&lt;p&gt;Here's a Codepen where you can try out the approaches described and other solutions attempts:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/sandrina-p/embed/VwadjVL?height=600&amp;amp;default-tab=html,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>html</category>
      <category>css</category>
      <category>frontend</category>
    </item>
    <item>
      <title>CSS-in-JS - styled vs css prop</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Tue, 04 Aug 2020 10:12:45 +0000</pubDate>
      <link>https://dev.to/sandrinap/css-in-js-styled-vs-css-prop-229e</link>
      <guid>https://dev.to/sandrinap/css-in-js-styled-vs-css-prop-229e</guid>
      <description>&lt;p&gt;CSS-in-JS lovers, please help me understand why I should prefer using styled over CSS prop.&lt;/p&gt;

&lt;p&gt;Not knowing immediately if it's a "real" React component or just an HTML element (and which one) is driving me nuts. 😰&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// MyComponentStyles.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="s2"&gt;`
    color: tomato;
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="s2"&gt;`
  color: tomato;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// MyComponent.js&lt;/span&gt;
&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Approach #1 - I can easily tell what's the HTML tag
                      and spot any markup mistakes */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;css&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;Styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Pizza&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Approach 2: - Can't tell if it's an actual component or
                      just a "css wrapper". */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Pizza&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>react</category>
      <category>css</category>
      <category>help</category>
    </item>
    <item>
      <title>Psst, you can empower the designers on your team</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Wed, 04 Dec 2019 10:16:41 +0000</pubDate>
      <link>https://dev.to/sandrinap/psst-you-can-empower-the-designers-on-your-team-3681</link>
      <guid>https://dev.to/sandrinap/psst-you-can-empower-the-designers-on-your-team-3681</guid>
      <description>&lt;p&gt;Tips from a frontend developer to another.&lt;/p&gt;

&lt;p&gt;This zine is based on the article &lt;a href="https://www.smashingmagazine.com/2019/10/frontend-developers-empower-designers-work/" rel="noopener noreferrer"&gt;How Frontend Developers Can Empower Designer’s Work&lt;/a&gt; that I wrote for Smashing Magazine a few months ago. At the bottom, you can check the written version but for now check out the illustrative version! Feel free to &lt;a href="https://github.com/sandrina-p/sketching/tree/master/zine_empower_designers" rel="noopener noreferrer"&gt;download the printable version&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkplkqj42boe1c3gx4t7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkplkqj42boe1c3gx4t7t.png" alt="Cover" width="611" height="891"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr3kp4x0cn2pcc7iv51bx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr3kp4x0cn2pcc7iv51bx.png" alt="Page 1-2" width="800" height="565"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foj2hpaezamv87pneppel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foj2hpaezamv87pneppel.png" alt="Page 2-3" width="800" height="565"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb81x5lbhh3y42p8c90q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb81x5lbhh3y42p8c90q.png" alt="Page 3-4" width="800" height="565"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvh2lgzqcv1fsfg2ci8h5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvh2lgzqcv1fsfg2ci8h5.png" alt="Back" width="633" height="891"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now the written version:&lt;/p&gt;

&lt;h2&gt;
  
  
  Look beyond your code editor
&lt;/h2&gt;

&lt;p&gt;Remember these design principles when implementing user interfaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hierarchy&lt;/li&gt;
&lt;li&gt;Alignment&lt;/li&gt;
&lt;li&gt;Spacing&lt;/li&gt;
&lt;li&gt;Contract&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Teach them code, not how to code.
&lt;/h2&gt;

&lt;p&gt;Show to designers the joy of tweaking visuall stuff in the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dev Tools
&lt;/h3&gt;

&lt;p&gt;Refine layouts, fonts, spacings and animations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Playgrounds
&lt;/h3&gt;

&lt;p&gt;Explore and tweak on &lt;a href="//codepen.io/"&gt;Codepen&lt;/a&gt; or &lt;a href="//glitch.com/"&gt;Glitch&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Include each other in the process
&lt;/h2&gt;

&lt;p&gt;Ask designers to include you in their design process and include them in the development process as well.&lt;/p&gt;

&lt;p&gt;You'll discover they do much more than &lt;em&gt;"make things pretty"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;They'll better understand the web constraints and why a feature takes time to implement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Have doubts about the design specs? Ask First!
&lt;/h2&gt;

&lt;p&gt;Do not let assumptions turn into bad decisions. You’ll be risking the trust the designers put on you.&lt;/p&gt;

&lt;p&gt;Whenever in doubt, reach out and clarify the specs. This will show designers that &lt;strong&gt;you care as much as they do.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Don’t make workarounds by yourself
&lt;/h2&gt;

&lt;p&gt;When a designer asks you to implement a tricky design, don’t say &lt;em&gt;“It’s impossible”&lt;/em&gt; nor try to implement a cheap version of it.&lt;/p&gt;

&lt;p&gt;Explain to them, in simple terms, the constraints and be open to collaborating on a new solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Go off-the-record once in a while
&lt;/h2&gt;

&lt;p&gt;We all have tasks to deliver and roadmaps to finish. However, some of the best work happens off-the-record.&lt;/p&gt;

&lt;p&gt;Go sneak into their workspace and explore new things. You never know what can come from there!&lt;/p&gt;

&lt;h2&gt;
  
  
  Let designers be picky
&lt;/h2&gt;

&lt;p&gt;What it truly means to be picky:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose with care&lt;/li&gt;
&lt;li&gt;Ensure cohesion&lt;/li&gt;
&lt;li&gt;Create the best&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;be picky together &amp;lt;3&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>design</category>
      <category>showdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>React Context cheatsheet</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Mon, 28 Oct 2019 15:45:47 +0000</pubDate>
      <link>https://dev.to/sandrinap/react-context-cheatsheet-18n4</link>
      <guid>https://dev.to/sandrinap/react-context-cheatsheet-18n4</guid>
      <description>&lt;p&gt;The React Context API is one of the hottest features in React 16. However, it is one of those features where I see more developers struggling with, especially when consuming the context.&lt;/p&gt;

&lt;p&gt;Since its release I’ve been facing / asking / answering the same questions over and over again: How to use a component that consumes React Context and test it with Enzyme.&lt;/p&gt;

&lt;p&gt;This cheatsheet reflects my journey of discoveries related to React Context API and how to test it using Enzyme. If you find something wrong, missing or outdated, please let me know and I'll update it. 👩‍💻&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/7z3vpo3916"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

</description>
      <category>react</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Learning Hash Tables with drawings 🎨</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Tue, 20 Aug 2019 09:19:43 +0000</pubDate>
      <link>https://dev.to/sandrinap/learning-hash-tables-with-drawings-99o</link>
      <guid>https://dev.to/sandrinap/learning-hash-tables-with-drawings-99o</guid>
      <description>&lt;p&gt;I've been learning about Data Structures and it all seems very rocket science. 🙃 To help me understand it better (learning to learn) I've made a small Zine about one of them - Hash Tables ⚡️&lt;/p&gt;

&lt;p&gt;At the bottom, you can check the full written version with resources, but for now, check out the illustrative version!&lt;/p&gt;

&lt;p&gt;Feel free to &lt;a href="https://github.com/sandrina-p/sketching/blob/master/zine_hash-tables/print.png" rel="noopener noreferrer"&gt;download the printable version&lt;/a&gt;. Here's also the &lt;a href="https://github.com/sandrina-p/sketching/blob/master/zine_hash-tables/original.jpg" rel="noopener noreferrer"&gt;original handmade version&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs3oi4wamdf5y5zmoub3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs3oi4wamdf5y5zmoub3.png" alt="Zine Cover" width="633" height="894"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80jilg5lb3dn6u1no5lp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F80jilg5lb3dn6u1no5lp.png" alt="Intro" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fib9x8utdltygj2m5zzk7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fib9x8utdltygj2m5zzk7.png" alt="How to Handle Collisions" width="800" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fytnxdg45qaznhbbgyou4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fytnxdg45qaznhbbgyou4.png" alt="FAQ" width="800" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... and now the written version...&lt;/p&gt;

&lt;h1&gt;
  
  
  The Magic of Hash Tables
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What it is
&lt;/h2&gt;

&lt;p&gt;The most efficient data structure to 🔍Search, ➕Insert and 🗑Delete.&lt;/p&gt;

&lt;p&gt;Does all of it in &lt;strong&gt;O(1) complexity&lt;/strong&gt; on average (i.e. Takes the same time to  do it, no matter the size of data available)&lt;/p&gt;

&lt;p&gt;It's used for Caching, Database Searching, and Sets&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;An unordered collection of &lt;strong&gt;unique keys&lt;/strong&gt; is mapped to &lt;strong&gt;values&lt;/strong&gt; through the process of hashing.&lt;/p&gt;

&lt;p&gt;Take a key --&amp;gt; Run it in a hash function --&amp;gt; that generates a hash&lt;/p&gt;

&lt;p&gt;Portuguese --&amp;gt; ✨ --&amp;gt;  2&lt;br&gt;
French  --------&amp;gt; ✨ --&amp;gt;  0&lt;br&gt;
English -------&amp;gt; ✨ --&amp;gt;  3&lt;/p&gt;

&lt;p&gt;... and add it to the matched index on the table (also known as "bucket"):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;hash&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Salut&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Olá&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Hello&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Hashing is one-way!
&lt;/h3&gt;

&lt;p&gt;A hash can’t be converted back to its original key.&lt;/p&gt;

&lt;p&gt;ex: Hashing "English" returns 3, but with 3 you can't get "English"&lt;/p&gt;
&lt;h3&gt;
  
  
  A hash function must:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;🏎 Be fast to run.&lt;/li&gt;
&lt;li&gt;🧩 Uniform distribution.&lt;/li&gt;
&lt;li&gt;💥 Resolve hash collisions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How to handle Collisions?
&lt;/h2&gt;

&lt;p&gt;A collision happens when a key corresponds to a hash (index) already taken by another key.&lt;/p&gt;
&lt;h3&gt;
  
  
  Open Addressing
&lt;/h3&gt;

&lt;p&gt;When a bucket is already taken, other buckets are examined until an unused bucket is found.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💚 Fast when the number of collisions is small.&lt;/li&gt;
&lt;li&gt;🚨 Tables can’t be smaller than the number of keys.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Chaining
&lt;/h3&gt;

&lt;p&gt;A bucket can take multiple keys with the same index.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💚 Good for a large number of collisions.&lt;/li&gt;
&lt;li&gt;🚨 Wastage of space (some buckets are never used).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  💡FAQ
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is the ideal Load Factor?
&lt;/h3&gt;

&lt;p&gt;Some say it’s around 0.7. This means a table with 70 items should have around 100 buckets. But it’s a balance. The emptier the buckets, the faster it is, you have fewer collisions but more memory is used.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is Dynamic Resize?
&lt;/h3&gt;

&lt;p&gt;It happens when a table is getting out of balance - it’s too full or too empty. It resizes the table and rehashes the keys.&lt;/p&gt;
&lt;h3&gt;
  
  
  What’s the best Hash Function?
&lt;/h3&gt;

&lt;p&gt;There isn’t a one-fits-all solution. It’s a trade-off between speed and distribution.&lt;/p&gt;

&lt;p&gt;A good hash function is the secret to an efficient hash table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TIP:&lt;/strong&gt; When the keys are static use a Perfect Hash Function. * &lt;em&gt;No collisions&lt;/em&gt; * &lt;em&gt;No empty buckets&lt;/em&gt; *&lt;/p&gt;
&lt;h3&gt;
  
  
  When should I avoid Hash Tables?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Search is not the main operation.&lt;/li&gt;
&lt;li&gt;Need to iterate over the elements.&lt;/li&gt;
&lt;li&gt;There are duplicated keys.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  🎁 Bonus: Applying Simple Hash Table Concept in Javascript!
&lt;/h2&gt;
&lt;h3&gt;
  
  
  😰 When using If statements...
&lt;/h3&gt;

&lt;p&gt;You end in an if hell (or switch hell) when dealing with different scenarios to assign a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;viewport&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;fontSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;viewport&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;md&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;fontSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// else if ... else if ...&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⚡️ But using &lt;code&gt;key:value&lt;/code&gt; mapping...
&lt;/h3&gt;

&lt;p&gt;You get a direct lockup - O(1) complexity - no matter the number of options, with a cleaner code. How cool is that?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;
    &lt;span class="na"&gt;sm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;md&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fontSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjykay3ttsu0nclytueh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjykay3ttsu0nclytueh.png" alt="JS" width="630" height="894"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Resources to get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📝&lt;a href="https://en.wikipedia.org/wiki/Hash_table" rel="noopener noreferrer"&gt;Hash Tables - Wikipedia&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🎥&lt;a href="https://www.youtube.com/watch?v=KyUTuwz_b7Q&amp;amp;t=21s" rel="noopener noreferrer"&gt;Hash Tables and Hash Functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🎥 &lt;a href="https://www.youtube.com/watch?v=mFY0J5W8Udk" rel="noopener noreferrer"&gt;Hash Tables simplified&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>learning</category>
      <category>sketching</category>
      <category>showdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Bringing A Healthy Code Review Mindset To Your Team</title>
      <dc:creator>Sandrina Pereira</dc:creator>
      <pubDate>Mon, 29 Jul 2019 09:05:24 +0000</pubDate>
      <link>https://dev.to/sandrinap/bringing-a-healthy-code-review-mindset-to-your-team-f8o</link>
      <guid>https://dev.to/sandrinap/bringing-a-healthy-code-review-mindset-to-your-team-f8o</guid>
      <description>&lt;p&gt;Take a moment to remember the last time you collaborated in a code review. Did your team overcome feedback resistance and manage time expectations? Fostering a healthy mindset is the key to build trust and sharing knowledge with your colleagues.&lt;/p&gt;

&lt;p&gt;A code review is a moment in the development process in which you (as a developer) and your colleagues work together and look for bugs within a recent piece of code before it gets released. In such a moment, you can be either the code author or one of the reviewers.&lt;/p&gt;

&lt;p&gt;When doing a code review, you might not be sure of what you are looking for. On the other side, when submitting a code review, you might not know what to wait for. This lack of empathy and wrong expectations between the two sides can trigger unfortunate situations and rush the process until it ends in an unpleasant experience for both sides.&lt;/p&gt;

&lt;p&gt;In this article, I’ll share how this outcome can be changed by changing your mindset during a code review:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As a team&lt;/li&gt;
&lt;li&gt;As an author&lt;/li&gt;
&lt;li&gt;As a reviewer&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👩‍💻👨‍💻 As A Team
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Foster Out A Culture of Collaboration
&lt;/h3&gt;

&lt;p&gt;Before we start, it’s fundamental to understand the value of &lt;a href="https://sophiebits.com/2018/12/25/why-review-code.html" rel="noopener noreferrer"&gt;why code needs to be reviewed&lt;/a&gt;. Knowledge sharing and team cohesion are beneficial to everyone, however, if done with a poor mindset, a code review can be a huge time consumer with unpleasant outcomes.&lt;/p&gt;

&lt;p&gt;The team attitude and behavior should embrace the value of a nonjudgmental collaboration, with the &lt;strong&gt;common goal of learning and sharing&lt;/strong&gt; — regardless of someone else’s experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Include Code Reviews in Your Estimations
&lt;/h3&gt;

&lt;p&gt;A complete code review takes time. If a change took one week to be made, don’t expect the code review to take less than a day. It just doesn’t work like that. Don’t try to rush a code review nor look at it as a bottleneck.&lt;/p&gt;

&lt;p&gt;Code reviews are as important as writing the actual code. As a team, remember to &lt;strong&gt;include code reviews in your workflow&lt;/strong&gt; and set expectations about how long a code review might take, so everyone is synced and confident about their work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Save Time With Guidelines and Automatization
&lt;/h3&gt;

&lt;p&gt;An effective way to guarantee consistent contributions is to integrate a &lt;a href="https://github.com/stevemao/github-issue-templates" rel="noopener noreferrer"&gt;Pull Request template&lt;/a&gt; in the project. This will help the author to submit a healthy PR with a complete description. A PR description should explain what’s the change purpose, the reason behind it, and how to reproduce it. Screenshots and reference links (Git issue, design file, and so on) are the final touches for a self-explanatory submission.&lt;/p&gt;

&lt;p&gt;Doing all of this will prevent early comments from reviewers asking for more details. Another way of making code reviews seem less nitpicky is to use &lt;a href="https://github.com/collections/clean-code-linters" rel="noopener noreferrer"&gt;linters&lt;/a&gt; to find code formatting and code-quality issues before a reviewer even gets involved. Whenever you see a repetitive comment during the review process, look for ways to minimize it (being with better guidelines or code automatization).&lt;/p&gt;

&lt;h3&gt;
  
  
  Stay A Student
&lt;/h3&gt;

&lt;p&gt;Anyone can do a code review, and everyone must receive a code review — no matter the seniority level. Receive any feedback gratefully as an opportunity to learn and to share knowledge. &lt;strong&gt;Look at any feedback as an open discussion rather than a defensive reaction.&lt;/strong&gt; As Ryan Holiday says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“An amateur is defensive. The professional finds learning (and even, occasionally, being shown up) to be enjoyable; they like being challenged and humbled, and engage in education as an ongoing and endless process. (...)”&lt;/p&gt;

&lt;p&gt;— Ryan Holiday, Ego Is the Enemy&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Stay humble because the second you stop being a student, your knowledge becomes fragile.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Art Of Selecting Reviewers
&lt;/h3&gt;

&lt;p&gt;In my opinion, picking the reviewers is one of the most important decisions for an effective and healthy code review as a team.&lt;/p&gt;

&lt;p&gt;Let’s say your colleague is submitting a code review and decides to tag “everyone” because, unconsciously, she/he might want to speed up the process, deliver the best code possible or making sure everyone knows about the code change. Each one of the reviewers receives a notification, then opens the PR link and sees a lot of people tagged as reviewers. The thought of “someone else will do it” pops up in their minds, leading to ignore the code review and close the link.&lt;/p&gt;

&lt;p&gt;Since nobody started the review yet, your colleague will remind each one of the reviewers to do it, i.e. creating pressure on them. Once the reviewers start to do it, the review process takes forever because everyone has their own opinion and it’s a nightmare to reach a common agreement. Meanwhile, whoever decided to not review the code, is then spammed with zillions of e-mail notifications with all of the review comments, thus creating noise in their productivity.&lt;/p&gt;

&lt;p&gt;This is something I see happening more than I’d like: Pull Requests with a bunch of people tagged as reviewers and ending, ironically, in a non-productive code review.&lt;/p&gt;

&lt;p&gt;There are some common effective flows when selecting the reviewers: A possible flow is to pick two to three colleagues who are familiar with the code and ask them to be reviewers. Another approach, explained by Gitlab team is to have a &lt;a href="https://about.gitlab.com/2017/03/17/demo-mastering-code-review-with-gitlab/" rel="noopener noreferrer"&gt;chained review flow&lt;/a&gt; in which the author picks one reviewer who picks another reviewer until at least two reviewers agree with the code. Regardless of the flow you choose, &lt;strong&gt;avoid having too many reviewers&lt;/strong&gt;. Being able to trust your colleagues’ code’s judgment is the key to conduct an effective and healthy code review.&lt;/p&gt;

&lt;h3&gt;
  
  
  Have Empathy
&lt;/h3&gt;

&lt;p&gt;Spotting pieces of code to improve is just a part of a successful code review. Just as important is to communicate that feedback in a healthy way by showing empathy towards your colleagues.&lt;/p&gt;

&lt;p&gt;Before writing a comment, remember to put yourself in the other people’s shoes. It’s easy to be misunderstood when writing, so review your own words before sending them. Even if a conversation starts being ugly, don’t let it affect you — always stay respectful. Speaking well to others is never a bad decision.&lt;/p&gt;

&lt;h3&gt;
  
  
  Know how to compromise
&lt;/h3&gt;

&lt;p&gt;When a discussion isn’t solved quickly, take it to a personal call or chat. Analyze together if it’s a subject worth paralyzing the current change request or if it can be addressed in another one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Be flexible but pragmatic&lt;/strong&gt; and know how to balance efficiency (delivering) and effectiveness (quality). It’s a compromise to be made as a team. In these moments I like to think of a code review as an iteration rather than a final solution. There’s always room for improvement in the next round.&lt;/p&gt;

&lt;h3&gt;
  
  
  In-person Code Reviews
&lt;/h3&gt;

&lt;p&gt;Gathering the author and the reviewer together in a pair programming style can be highly effective. Personally, I prefer this approach when the code review involves complex changes or there’s an opportunity for a large amount of knowledge sharing. Despite this being an offline code review, it’s a good habit to leave online comments about the discussions taken, especially when changes need to be made after the meeting. This is also useful to keep other online reviewers up to date.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn from Code Reviews Outcomes
&lt;/h3&gt;

&lt;p&gt;When a code review has suffered a lot of changes, took too long or has already had too many discussions, gather your team together and analyze the causes and which actions can be taken from it. When the code review is complex, &lt;strong&gt;splitting a future task into smaller tasks&lt;/strong&gt; makes each code review easier.&lt;/p&gt;

&lt;p&gt;When the experience gap is big, adopting pair programming is a strategy with incredible results — not only for knowledge sharing but also for off-line collaboration and communication. Whatever the outcome, always aim for a healthy dynamic team with clear expectations.&lt;/p&gt;

&lt;h2&gt;
  
  
  📝 As An Author
&lt;/h2&gt;

&lt;p&gt;One of the main concerns when working on a code review as an author is to minimize the reviewer’s surprise when reading the code for the first time. That’s the first step to a predictable and smooth code review. Here’s how you can do it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Establish Early Communication
&lt;/h3&gt;

&lt;p&gt;It’s never a bad idea to talk with your future reviewers before coding too much. Whenever it’s an internal or external contribution, you could do a refinement together or a little bit of pair programming at the beginning of the development to discuss solutions.&lt;/p&gt;

&lt;p&gt;There’s nothing wrong in asking for help as a first step. In fact, working together outside the review is a first important step to prevent early mistakes and guarantee an initial agreement. At the same time, your reviewers get aware of a future code review to be made.&lt;/p&gt;

&lt;h3&gt;
  
  
  Follow the Guidelines
&lt;/h3&gt;

&lt;p&gt;When submitting a Pull Request to be reviewed, remember to add a description and to follow the guidelines. This will save the reviewers from spending time to understand the context of the new code. Even if your reviewers already know what it is about, you can also take this opportunity as a way to improve your writing and communication skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be your First Reviewer
&lt;/h3&gt;

&lt;p&gt;Seeing your own code in a different context allows you to find things you would miss in your code editor. Do a code review of your own code before asking your colleagues. Have a reviewer mindset and really go through every line of code.&lt;/p&gt;

&lt;p&gt;Personally, &lt;strong&gt;I like to annotate my own code reviews&lt;/strong&gt; to better guide my reviewers. The goal here is to prevent comments related to a possible lack of attention and making sure you followed the contribution guidelines. Aim to submit a code review just as you would like to receive one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be Patient
&lt;/h3&gt;

&lt;p&gt;After submitting a code review, don’t jump right into a new private message asking your reviewers to “take a look, it only takes a few minutes” and indirectly craving for that thumbs-up emoji. Trying to rush your colleagues to do their work is not a healthy mindset. Instead, &lt;strong&gt;trust your colleagues’ workflow&lt;/strong&gt; as they trust you to submit a good code review. Meanwhile, wait for them to get back to you when they are available. Don’t look at your reviewers as a bottleneck. Remember to be patient because hard things take time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be a Listener
&lt;/h3&gt;

&lt;p&gt;Once a code review is submitted, comments will come, questions will be asked, and changes will be proposed. The golden rule here is to not take any feedback as a personal attack. Remember that &lt;strong&gt;any code can benefit from an outside perspective.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don’t look at your reviewers as an enemy. Instead, take this moment to set aside your ego, accept that you make mistakes, and be open to learning from your colleagues, so that you can do a better job the next time.&lt;/p&gt;

&lt;h2&gt;
  
  
  👀 As A Reviewer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Plan Ahead of your time
&lt;/h3&gt;

&lt;p&gt;When you are asked to be a reviewer, don’t interrupt things right away. That’s a common mistake I see all the time. Reviewing code demands your full attention, and each time you switch code contexts, you are decreasing your productivity by wasting time in recalibrating your focus. Instead, plan ahead by allocating time slots of your day to do code reviews.&lt;/p&gt;

&lt;p&gt;Personally, I prefer to do code reviews first thing in the morning or after lunch before picking any other of my tasks. That’s what works best for me because my brain is still fresh without a previous code context to switch off from. Besides that, once I’m done with the review, I can focus on my own tasks, while the author can reevaluate the code based on the feedback.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be Supportive
&lt;/h3&gt;

&lt;p&gt;When a Pull Request doesn’t follow the contribution guidelines, be supportive — especially to newcomers. Take that moment as an opportunity to guide the author to improve his/her contribution. Meanwhile, try to understand why the author didn’t follow the guidelines in the first place. &lt;strong&gt;Perhaps there’s room for improvement&lt;/strong&gt; that you were not aware of before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check Out The Branch And Run It
&lt;/h3&gt;

&lt;p&gt;While reviewing the code, make it run on your own computer — especially when it involves user interfaces. This habit will help you to better understand the new code and spot things you might miss if you just used a default diff-tool in the browser which limits your review scope to the changed code (without having the full context as in your code editor).&lt;/p&gt;

&lt;h3&gt;
  
  
  Ask Before Assuming
&lt;/h3&gt;

&lt;p&gt;When you don’t understand something, don’t be afraid to say it and ask questions. When asking, remember to first read the surrounding code and avoid making assumptions.&lt;/p&gt;

&lt;p&gt;Most of the questions fit in these two types of categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;“How” Questions&lt;/strong&gt;&lt;br&gt;
When you don’t understand how something works or what it does, evaluate with the author if the code is clear enough. Don’t mistake simple code with ignorance. There’s a difference between code that is hard to read and code that you are not aware of. Be open to learn and use a new language feature, even if you don’t know it deeply yet. However, use it only if it simplifies the codebase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;“Why” Questions&lt;/strong&gt;&lt;br&gt;
When you don’t understand the “why”, don’t be afraid of suggesting to commenting the code, especially if it’s an &lt;a href="https://twitter.com/sophiebits/status/1063180141872898048" rel="noopener noreferrer"&gt;edge case or a bug fix&lt;/a&gt;. The code should be self-explanatory when it comes to explaining what it does. Comments are a complement to explaining the why behind a certain approach. Explaining the context is highly valuable when it comes to maintainability and it will save someone from &lt;a href="https://cdn-images-1.medium.com/max/1200/0*xhqIOAyiCzYl2z0G.gif" rel="noopener noreferrer"&gt;deleting a block of code that thought was useless&lt;/a&gt;. (Personally, I like to comment on the code until I feel safe about forgetting it later.)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Constructive Criticism
&lt;/h3&gt;

&lt;p&gt;Once you find a piece of code you believe it should be improved, always remember to recognize the author’s effort in contributing to the project and express yourself in a receptive and transparent way.&lt;/p&gt;

&lt;h4&gt;
  
  
  Open discussions.
&lt;/h4&gt;

&lt;p&gt;Avoid formalizing your feedback as a command or accusation such as “You should…” or “You forgot…”. Express your feedback as an open discussion instead of a mandatory request. Remember to comment on the code, not the author. If the comment is not about the code, then it shouldn’t belong in a code review. As said before, be supportive. Using a passive voice, talking in the plural, expressing questions or suggestions are good approaches to emphasize empathy with the author.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Instead of “Extract this method from here…” prefer “This method should be extracted…” or “What do you think of extracting this method…”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Be clear.
&lt;/h4&gt;

&lt;p&gt;A feedback can easily be misinterpreted, especially when it comes to expressing an opinion versus sharing a fact or a guideline. Always remember to clear that right away on your comment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unclear: “This code should be….”&lt;/p&gt;

&lt;p&gt;Opinion: “I believe this code should be…”&lt;/p&gt;

&lt;p&gt;Fact: “Following [our guidelines], this code should be…”.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Explain why.
&lt;/h4&gt;

&lt;p&gt;What’s obvious for you, might not be for others. It’s never too much explaining the motivation behind your feedback, so the author not only understands how to change something but also what’s the benefit from it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Opinion: “I believe this code could be…”&lt;/p&gt;

&lt;p&gt;Explained: “I believe this code could be (…) because this will improve readability and simplify the unit tests.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Provide examples.
&lt;/h4&gt;

&lt;p&gt;When sharing a code feature or a pattern which the author is not familiar with, complement your suggestion with a reference as guidance. When possible, go beyond MDN docs and share a snippet or a working example adapted to the current code scenario. When writing an example is too complex, be supportive and offer to help in person or by a video call.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Besides saying something such as “Using filter will help us to [motivation],” also say, “In this case, it could be something like: [snippet of code]. You can check [an example at Finder.js]. Any doubt, feel free to ping me on Slack.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Be reasonable.
&lt;/h4&gt;

&lt;p&gt;If the same error is made multiple times, prefer to just leave one comment about it and remember the author to review it in the other places, too. Adding redundant comments only creates noise and might be contra-productive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep the Focus
&lt;/h3&gt;

&lt;p&gt;Avoid proposing code changes unrelated to the current code. Before suggesting a change, ask yourself if it’s strictly necessary at that moment. This type of feedback is especially common in refactors. It’s one of the many trade-offs between efficiency and effectiveness that we need to make as a team.&lt;/p&gt;

&lt;p&gt;When it comes to refactors, personally, I tend to &lt;strong&gt;prefer small but effective improvements.&lt;/strong&gt; Those are easier to review and there’s less chance of having code conflicts when updating the branch with the target branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Expectations
&lt;/h3&gt;

&lt;p&gt;If you leave a code review half-done, let the author know about it, so time expectations are under control. In the end, also let the author know if you agree with the new code or if you would like to re-review it once again later.&lt;/p&gt;

&lt;p&gt;Before approving a code review, ask yourself if you are comfortable about the possibility of touching that code in the future. If yes, that’s a sign you did a successful code review!&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn to Refuse a Code Review
&lt;/h3&gt;

&lt;p&gt;Although nobody admits it, sometimes you have to refuse a code review. The moment you decide to accept a code review but try to rush it, the project’s quality is being compromised as well as your team’s mindset.&lt;/p&gt;

&lt;p&gt;When you accept to review someone’s else code, that person is trusting your capabilities — it’s a commitment. If you don’t have the time to be a reviewer, just say no to your colleague(s). I really mean it; don’t let your colleagues wait for a code review that will never be done. &lt;strong&gt;Remember to communicate and keep expectations clear.&lt;/strong&gt; Be honest with your team and — even better — with yourself. Whatever your choice, do it healthily, and do it right.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Given enough time and experience, doing code reviews will teach you much more than just technical knowledge. You’ll learn to give and receive feedback from others, as well as make decisions with more thought put into it.&lt;/p&gt;

&lt;p&gt;Each code review is an opportunity to grow as a community and individually. Even outside code reviews, remember to foster a healthy mindset until the day it comes naturally to you and your colleagues. Because sharing is what makes us better!&lt;/p&gt;




&lt;p&gt;This article was &lt;a href="https://www.smashingmagazine.com/2019/06/bringing-healthy-code-review-mindset/" rel="noopener noreferrer"&gt;originally written at Smashing Magazine&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>productivity</category>
      <category>workflow</category>
      <category>process</category>
    </item>
  </channel>
</rss>
