<?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: Jesse M. Holmes</title>
    <description>The latest articles on DEV Community by Jesse M. Holmes (@wolfhoundjesse).</description>
    <link>https://dev.to/wolfhoundjesse</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%2F87764%2F70cf9b72-0749-4859-b6bc-53d28f6b4122.jpeg</url>
      <title>DEV Community: Jesse M. Holmes</title>
      <link>https://dev.to/wolfhoundjesse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wolfhoundjesse"/>
    <language>en</language>
    <item>
      <title>Who is using Nx?</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Fri, 14 Jan 2022 15:39:48 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/who-is-using-nx-45em</link>
      <guid>https://dev.to/wolfhoundjesse/who-is-using-nx-45em</guid>
      <description>&lt;p&gt;I'm using Nx with React and Nest to build an application for work, and I love it. Are you doing anything interesting with &lt;a href="https://nx.dev/"&gt;Nx&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>discuss</category>
      <category>tooling</category>
    </item>
    <item>
      <title>Dependency Injection</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Mon, 23 Aug 2021 12:53:51 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/dependency-injection-317k</link>
      <guid>https://dev.to/wolfhoundjesse/dependency-injection-317k</guid>
      <description>&lt;h2&gt;
  
  
  Morgan's Flowers
&lt;/h2&gt;

&lt;p&gt;Morgan owns a flower shop, and it is important that they take delivery of new stock each day so that they can continue to supply their customers. &lt;/p&gt;

&lt;h2&gt;
  
  
  Without Dependency Injection
&lt;/h2&gt;

&lt;p&gt;Ashley pulls into the loading dock in a truck filled with fresh flowers. Morgan accepts the delivery and says, "Thanks, Ashley! I will see you tomorrow!"&lt;/p&gt;

&lt;p&gt;Morgan has decided to include Ashley as a valuable part of her system. What happens if Ashley doesn't deliver the flowers tomorrow? What if Ashley changes jobs, gets fired, or just isn't as reliable as Morgan expected? Because Ashley is built into Morgan's business system, Morgan is stuck. To make a change for their business, they are going to have to rebuild the entire supply chain again, interview other drivers, change delivery methods, adjust schedules, etc. Do you see the problem here?&lt;/p&gt;

&lt;h2&gt;
  
  
  With Dependency Injection
&lt;/h2&gt;

&lt;p&gt;Ashley pulls into the loading dock in a truck filled with fresh flowers. Morgan accepts the delivery and says, "Thanks!" Morgan doesn't know Ashley, and they don't care if Ashley is driving the truck tomorrow. &lt;em&gt;Morgan is only interested in taking delivery of the flowers, not who delivers them.&lt;/em&gt; In fact, if Morgan is dissatisfied with the delivery service, they can order the same flowers from a new delivery service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Did you find this analogy helpful?
&lt;/h2&gt;

&lt;p&gt;I'd like to write a series of posts like this one that I can refer back to when teaching. There is no code included in this example. Is that an issue? Is there a topic you'd like to tackle in this manner? Let me know!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Playlists and albums I've been listening to while I code, 2021 edition</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Mon, 31 May 2021 02:19:51 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/playlists-and-albums-i-ve-been-listening-to-while-i-code-2021-edition-43cl</link>
      <guid>https://dev.to/wolfhoundjesse/playlists-and-albums-i-ve-been-listening-to-while-i-code-2021-edition-43cl</guid>
      <description>&lt;p&gt;I plan to grow this list over the next couple of weeks. Enjoy!&lt;/p&gt;

&lt;h2&gt;
  
  
  Playlists
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="100%" height="380px" src="https://open.spotify.com/embed/playlist/0cyH0TxFDgCQ2gQbs6shh2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe width="100%" height="380px" src="https://open.spotify.com/embed/playlist/5QjgJ20xSbkyfDY2iPERtz"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe width="100%" height="380px" src="https://open.spotify.com/embed/playlist/37i9dQZF1DX55dNU0PWnO5"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe width="100%" height="380px" src="https://open.spotify.com/embed/playlist/6dlwJYNRdkTfZMALZclyIx"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;iframe width="100%" height="380px" src="https://open.spotify.com/embed/playlist/2VYGEyET93LVLjG4FFpjMQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I need a personal laptop</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Fri, 21 May 2021 13:16:11 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/i-need-a-personal-laptop-54o7</link>
      <guid>https://dev.to/wolfhoundjesse/i-need-a-personal-laptop-54o7</guid>
      <description>&lt;p&gt;If you were going to buy a laptop for development, were operating system agnostic, and only required the machine to be fast and have the ability to virtualize, what would you look for? I've considered a late-model mac just so I can get into Swift (I'm not totally convinced about &lt;a href="https://swift.org/blog/swift-on-windows/"&gt;Swift on Windows&lt;/a&gt; yet), but I could just get a mini instead.&lt;/p&gt;

&lt;p&gt;I've worked with two machines in the past that I loved, a $3,000 Dell XPS 15 9550 and a $2,000 HP EliteBook G5 with half the RAM of the Dell. Both ran very smoothly.&lt;/p&gt;

&lt;p&gt;TIA!&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Sorting Strings in JavaScript with localCompare</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Wed, 18 Nov 2020 15:08:20 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/sorting-strings-in-javascript-with-localcompare-3fan</link>
      <guid>https://dev.to/wolfhoundjesse/sorting-strings-in-javascript-with-localcompare-3fan</guid>
      <description>&lt;p&gt;Take this list of strings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lyra&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Iorek&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pantalaimon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asriel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Serafina&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We want to sort it alphabetically. Naturally, we can &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort"&gt;check the MDN for Array.prototype.sort()&lt;/a&gt;, and we find that &lt;code&gt;names.sort()&lt;/code&gt; will do the job pain-free.&lt;/p&gt;

&lt;p&gt;A week after you've submitted your work, a ticket is opened and assigned to you: &lt;em&gt;Users are complaining that their names aren't in the correct order&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After taking a look, you see that Lee has submitted his name in lowercase. &lt;em&gt;Of course he did.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lyra&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Iorek&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pantalaimon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asriel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Serafina&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lee&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;// Result ['Asriel', 'Iorek', 'Lyra', 'Serafina', 'lee', 'pantalaimon']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, users with lowercase names are sorted at the end. They're in order by themselves, but Product may not get your sense of humor when you explain it to them.&lt;/p&gt;

&lt;p&gt;The reason lower case names are at the end has to do with their ASCII values. If you &lt;a href="http://www.asciitable.com/"&gt;check the chart&lt;/a&gt;, you'll see that lowercase letters have larger numerical ASCII values. Time to google &lt;em&gt;javascript sort strings ignore case&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now we've been introduced to a new method, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare"&gt;localeCompare&lt;/a&gt;. This method is packed with options that are available in all modern browsers. Check the usage chart at the bottom of the MDN page—some mobile browsers don't have full support for the options.&lt;/p&gt;

&lt;p&gt;Here's the finished sort:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lyra&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Iorek&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pantalaimon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asriel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Serafina&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lee&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localeCompare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en&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="na"&gt;sensitivity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;base&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;})))&lt;/span&gt;
&lt;span class="c1"&gt;// result: ['Asriel', 'Iorek', 'lee', 'Lyra', 'pantalaimon', 'Serafina']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
    </item>
    <item>
      <title>I'll take one of everything …</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Thu, 29 Oct 2020 10:38:27 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/i-ll-take-one-of-everything-al4</link>
      <guid>https://dev.to/wolfhoundjesse/i-ll-take-one-of-everything-al4</guid>
      <description>&lt;p&gt;This morning on &lt;em&gt;Things I Saw in Revenue Generating (Legacy) Code&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wait, so this modal is displaying an iframe that bootstraps the entire angularjs application, including the microfrontend container written in react, just to show a control for uploading a file? Cool, cool.&lt;/p&gt;

&lt;p&gt;Tell me about something interesting you've seen in code recently!&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>There is more than one way to make your code readable</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Mon, 15 Jun 2020 16:53:37 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/there-is-more-than-one-way-to-make-your-code-readable-37e7</link>
      <guid>https://dev.to/wolfhoundjesse/there-is-more-than-one-way-to-make-your-code-readable-37e7</guid>
      <description>&lt;p&gt;Let's say you find the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;generateId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; 
      &lt;span class="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charCodeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&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;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;profileId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;generateId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;setId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&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;profileId&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;What do we know about this effect? &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It runs when the profileId changes and if some other id is equal to zero. &lt;/li&gt;
&lt;li&gt;The profileId is converted from a string to a string array.&lt;/li&gt;
&lt;li&gt;The string array is reduced using a generateId function that returns &lt;code&gt;(acc += cur.charCodeAt(0)) % 8 + 1&lt;/code&gt;, &lt;em&gt;whatever that is&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If a less experienced developer finds this in a React component, they may be confronted with a few obstacles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How comfortable are they with &lt;code&gt;.reduce()&lt;/code&gt;? What are &lt;em&gt;acc&lt;/em&gt; and &lt;em&gt;cum&lt;/em&gt;? &lt;/li&gt;
&lt;li&gt;What is &lt;em&gt;x&lt;/em&gt;, and why are we setting the other ID to whatever &lt;em&gt;x&lt;/em&gt; is?&lt;/li&gt;
&lt;li&gt;What is the intent of the effect? Why is it needed?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A more experienced developer, perhaps even the developer who wrote this code, will face similar obstacles. How can we write this code so that someone can understand what is going on right away? Here are a few attempts.&lt;/p&gt;
&lt;h2&gt;
  
  
  Comment your code, and use variable names that reveal their intent
&lt;/h2&gt;

&lt;p&gt;Variable are &lt;em&gt;things&lt;/em&gt;, and we should name those things well! Call them what they are! It's not an ID, it's an Avatar ID. This would be an improvement even without the comment block. I prefer to think of &lt;code&gt;.reduce()&lt;/code&gt; as having state, explained beautifully by Joel in under 5 minutes:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
    &lt;a href="/joelnet/minute-javascript-array-s-reduce-method-18h0" class="video-image"&gt;
      &lt;span class="video-timestamp"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pl4ssD2Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/video-camera-9a2eda0979fd9ce3933037481ee8828557b6c7f5533e1de458b8c2648a60b097.svg" alt="video camera"&gt;
        04:58&lt;/span&gt;
    &lt;/a&gt;
  &lt;a href="/joelnet" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lP1yLOkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--C4Det9gy--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/2416/ba54e7d3-3e6d-494c-95a8-6721d250a6de.jpg" alt="joelnet image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/joelnet/minute-javascript-array-s-reduce-method-18h0" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Minute JavaScript - Array's reduce method&lt;/h2&gt;
      &lt;h3&gt;JavaScript Joel ・ Jun  8 '20 ・ 1 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#video&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;An informative comment or comment block causes no penalty to performance, and you won't lose cool points for writing one. I promise the developer reading your code would rather understand what is going on than being impressed by your one-line function.&lt;/p&gt;

&lt;p&gt;If you are fortunate enough to be mentoring junior developers with some frequency, there is also no penalty for leveraging the community for the bits of the JavaScript developers don't touch every day.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="cm"&gt;/**
   * Generate the avatar id
   * 
   * 1. convert licensingProfileId from string into string array
   * 2. (reducer) sum the ascii code for each character
   * 3. (reducer) mod by 8 for the 8 possible avatars
   * 4. (reducer) add 1 to generate the possible id
   *
   * Learn more about .reduce():
   * MDN: (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
   * Minute JavaScript: (https://dev.to/joelnet/minute-javascript-array-s-reduce-method-18h0)
   * 
   * .charCodeAt(0) returns the ascii code of a string character at the index passed in. 
   * In this case, item is always a single-character string.
   */&lt;/span&gt;
  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;generateAvatarId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&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="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; 
      &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charCodeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&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;avatarId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;avatarId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;licensingProfileId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;generateAvatarId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;setAvatarId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;avatarId&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&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;licensingProfileId&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Shorter code isn't necessarily more readable
&lt;/h2&gt;

&lt;p&gt;Remember when your math teacher would hand your assignments back covered in red ink with &lt;em&gt;Show your work!!&lt;/em&gt; written across the top? Just me? Feel free to follow this strategy here as well. I personally wouldn't go as far as this example with transient/placeholder variables at each step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="cm"&gt;/**
   * Generate the avatar id
   */&lt;/span&gt;
  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;generateAvatarId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&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="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;asciiCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charCodeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Get a number from the string character&lt;/span&gt;
      &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;asciiCode&lt;/span&gt; &lt;span class="c1"&gt;// state is the sum of the ascii codes&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;
    &lt;span class="p"&gt;}&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;avatarId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// transform string to array so that we can use .reduce()&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stringArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;licensingProfileId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
      &lt;span class="c1"&gt;// starting from 0, sum the ascii codes for each character in the profileId&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;asciiCodeSum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;stringArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;generateAvatarId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="c1"&gt;// There are only 8 avatars to choose from&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;selectedAvatar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;asciiCodeSum&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
      &lt;span class="c1"&gt;// Add 1 to assign an ID of 1–8&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;selectedAvatarId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;selectedAvatar&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="nx"&gt;setAvatarId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedAvatarId&lt;/span&gt;&lt;span class="p"&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;licensingProfileId&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whatever combination of techniques you decide to use, the result will save questions and head scratching when the code has been stale for a while.&lt;/p&gt;

</description>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Justifying Tech Debt</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Tue, 19 May 2020 18:17:03 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/justifying-tech-debt-318d</link>
      <guid>https://dev.to/wolfhoundjesse/justifying-tech-debt-318d</guid>
      <description>&lt;p&gt;As requested, I just spelled out the business value of adding timestamps to logs. What's your story?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Who is using a PinePhone?</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Tue, 03 Mar 2020 16:11:28 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/who-is-using-a-pinephone-4jog</link>
      <guid>https://dev.to/wolfhoundjesse/who-is-using-a-pinephone-4jog</guid>
      <description>&lt;p&gt;I just paid off my iPhones. I'm used to being a few generations behind, and my relatively young iPhone X is going strong. I've been an iPhone user since the 3G, and I've never really considered making a change.&lt;/p&gt;

&lt;p&gt;I came across something interesting on a Twitch stream last week, &lt;a href="https://www.pine64.org/pinephone/"&gt;the PinePhone&lt;/a&gt;. From what I learned, it's a smart phone running on slightly dated hardware and a Linux operating system. Also, it's $119, just a few bucks shy of the $1,200 iPhone I would be upgrading to.&lt;/p&gt;

&lt;p&gt;There are inexpensive components in the store to allow you to upgrade and configure as you like, and there is even a smart watch. I am intrigued to say the least.&lt;/p&gt;

&lt;p&gt;So … have any of you fine people grabbed one of these? The searchbar says no one is talking about it, to say the least.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>linux</category>
    </item>
    <item>
      <title>Currently I'm Thinking About Writing Currently</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Fri, 28 Feb 2020 13:27:12 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/currently-i-m-thinking-about-writing-currently-4g94</link>
      <guid>https://dev.to/wolfhoundjesse/currently-i-m-thinking-about-writing-currently-4g94</guid>
      <description>&lt;p&gt;Good morning, friends! Here's a brief message on clear and concise communication: currently, currently is one of the most overused words in our industry currently.&lt;/p&gt;

&lt;p&gt;Tech recruiters are especially generous with this word.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Currently we are seeking a developer with 31 years of Angular experience&lt;/li&gt;
&lt;li&gt;We are currently located in Annapolis&lt;/li&gt;
&lt;li&gt;Currently we build software at the moment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you are laughing at the third example—it's my personal favorite offender.&lt;/p&gt;

&lt;p&gt;Consider these alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We seek a developer with 2 years of React experience, or experience in other libraries/frameworks and an interest in learning on the go.&lt;/li&gt;
&lt;li&gt;We are in Annapolis Junction (Marylanders may get this reference)&lt;/li&gt;
&lt;li&gt;We build software&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Often &lt;em&gt;currently&lt;/em&gt; is a placeholder word, like &lt;em&gt;um&lt;/em&gt;. It can be used for emphasis or to imply upcoming changes, such as, "We have no openings currently." It creates a weakness where you want to be communicating in an active voice. Did you notice the subtle, bonus difference between these two sentences?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Currently we are seeking a developer&lt;/li&gt;
&lt;li&gt;We seek a developer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which one is more affirming, more in command? &lt;/p&gt;

&lt;p&gt;If you don't find this advice helpful, or if you think that I'm gatekeeping, let me know in the comments.&lt;/p&gt;

</description>
      <category>career</category>
    </item>
    <item>
      <title>Which algorithms are you using to build software for the web?</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Mon, 17 Feb 2020 15:26:57 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/which-algorithms-are-you-using-to-build-software-for-the-web-4j19</link>
      <guid>https://dev.to/wolfhoundjesse/which-algorithms-are-you-using-to-build-software-for-the-web-4j19</guid>
      <description>&lt;p&gt;Which algorithms are you using from your computer science days when building software for the web? How often do you utilize them in the front end?&lt;/p&gt;

&lt;p&gt;I re-read this excellent article by Molly Struve, and these are the questions that came to mind. 🤯&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Fix This Before Commit!</title>
      <dc:creator>Jesse M. Holmes</dc:creator>
      <pubDate>Fri, 17 Jan 2020 16:04:20 +0000</pubDate>
      <link>https://dev.to/wolfhoundjesse/fix-this-before-commit-265k</link>
      <guid>https://dev.to/wolfhoundjesse/fix-this-before-commit-265k</guid>
      <description>&lt;p&gt;I saw this beauty today during a code review, and it brought a set of tools to mind:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Fix this before commit  */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Locations&lt;/span&gt; &lt;span class="na"&gt;locationOptions&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;locationOptions&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  ToDo Extensions for VS Code
&lt;/h3&gt;

&lt;p&gt;There are a number of extensions that will take a comment like &lt;code&gt;\\TODO: Fix this before commit&lt;/code&gt; and highlight it. If color coordination is your strong point, some of them allow you to customize your comment highlights according to the text so that, e.g., &lt;code&gt;\\WONTFIX&lt;/code&gt; can be a pretentious shade of blue. Others will scan your code for such comments and compile them into a tree in your sidebar. Whatever your preference, just make sure you're utilizing a productivity tool that will catch your attention before your unfixed commit makes it to production. &lt;em&gt;Hint: Writing tests aren't just a good idea—they're preventative in nature!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Obviously I am not the first to write about this:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/eclecticcoding" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7UdcWViL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--ON4q7XYS--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/69818/4ac54d27-6960-4a16-9615-bfbff7176484.jpg" alt="eclecticcoding image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/eclecticcoding/todo-list-in-vscode-2mnb" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;TODO list in VSCode&lt;/h2&gt;
      &lt;h3&gt;Chuck  ・ Aug 14 '19 ・ 2 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#vscode&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;Comment below with your favorites!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
