<?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: David Armendáriz</title>
    <description>The latest articles on DEV Community by David Armendáriz (@davidarmendariz).</description>
    <link>https://dev.to/davidarmendariz</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%2F537820%2Fc1e1667e-b6aa-419f-8294-6290656a1a97.jpg</url>
      <title>DEV Community: David Armendáriz</title>
      <link>https://dev.to/davidarmendariz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davidarmendariz"/>
    <language>en</language>
    <item>
      <title>Creating a Discord bot with discord.js, Typescript and Heroku</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Wed, 11 May 2022 17:21:23 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/creating-a-discord-bot-with-discordjs-typescript-and-heroku-5829</link>
      <guid>https://dev.to/davidarmendariz/creating-a-discord-bot-with-discordjs-typescript-and-heroku-5829</guid>
      <description>&lt;p&gt;Hi! So, some months ago, I was interested in creating a bot for Discord. I searched for tutorials and they were not too good. Worst of all, they taught you how to deploy it to Repl.it. As a senior software dev, I was like: what? Repl.it is the last thing I would think about to deploy anything.&lt;/p&gt;

&lt;p&gt;I started coding the bot and the documentation again was not good. They even have wrong information on their docs so I had to ask people on the official discord.js server to clear some doubts. Sometimes people are nice, sometimes they aren't. They have concepts like cached guilds and uncached guilds that took me some time to grasp because they do weird things in Typescript.&lt;/p&gt;

&lt;p&gt;Anyway... I gathered all of that knowledge and decided to make a course in Udemy and Skillshare. Here you will learn a lot of things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typescript&lt;/li&gt;
&lt;li&gt;Reply to messages&lt;/li&gt;
&lt;li&gt;Create slash commands&lt;/li&gt;
&lt;li&gt;Create buttons and links&lt;/li&gt;
&lt;li&gt;Create message collectors&lt;/li&gt;
&lt;li&gt;Create embeds&lt;/li&gt;
&lt;li&gt;Create reactions collectors&lt;/li&gt;
&lt;li&gt;Create sub commands&lt;/li&gt;
&lt;li&gt;Get information about a user and its roles&lt;/li&gt;
&lt;li&gt;Add options to commands&lt;/li&gt;
&lt;li&gt;Add simple tests&lt;/li&gt;
&lt;li&gt;Deploy to Heroku and connect it to GitHub for CD&lt;/li&gt;
&lt;li&gt;Permissions&lt;/li&gt;
&lt;li&gt;Best practices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among other things...&lt;/p&gt;

&lt;p&gt;This is the link with the coupon code: &lt;a href="https://www.udemy.com/course/building-a-discord-bot-w-discordjs-typescript-and-heroku/learn/lecture/31964864?couponCode=DISCORDBOT#overview" rel="noopener noreferrer"&gt;https://www.udemy.com/course/building-a-discord-bot-w-discordjs-typescript-and-heroku/learn/lecture/31964864?couponCode=DISCORDBOT#overview&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>heroku</category>
    </item>
    <item>
      <title>TikTok logo with CSS only</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Sun, 25 Jul 2021 19:31:54 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/tiktok-logo-with-css-only-2fh6</link>
      <guid>https://dev.to/davidarmendariz/tiktok-logo-with-css-only-2fh6</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/r5hU4MYZ6u4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Never do this in Python!</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Sat, 24 Jul 2021 22:48:27 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/never-do-this-in-python-2m61</link>
      <guid>https://dev.to/davidarmendariz/never-do-this-in-python-2m61</guid>
      <description>&lt;p&gt;Do you know what happens if you pass a mutable object as a default argument in Python? What can go wrong?&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/MUrxkE9j6kM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>JavaScript tips: The labeled statement</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Sat, 29 May 2021 15:47:36 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/the-labeled-statement-in-javascript-20f8</link>
      <guid>https://dev.to/davidarmendariz/the-labeled-statement-in-javascript-20f8</guid>
      <description>&lt;p&gt;What if you type in the console something like this?&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="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You won't have any errors. This is valid JS!&lt;/p&gt;

&lt;p&gt;It turns out you can reference loops in Javascript. This was something I did not know a few days ago, but is a really cool and helpful feature in Javascript. In the following video, I explain you with examples how to use labeled statements.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/YosGqtogIo0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>programming</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Trying to make Webstorm like VSCode (Part 1)</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Thu, 04 Mar 2021 02:33:44 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/trying-to-make-webstorm-like-vscode-part-1-4m7g</link>
      <guid>https://dev.to/davidarmendariz/trying-to-make-webstorm-like-vscode-part-1-4m7g</guid>
      <description>&lt;p&gt;Hi folks! I recently needed to install PHPStorm as I am working on a complex PHP project and VSCode was not that good for PHP...&lt;br&gt;
I am trying to make a smooth transition, because I have always used VSCode for basically everything. I also downloaded Webstorm, so I am experimenting on Webstorm so that I can apply what I learned later on PHPStorm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unstaged files
&lt;/h2&gt;

&lt;p&gt;I think VSCode has a great and simple Git integration. Before you add a file to the stage you have the file like this:&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%2Fwbghi0vjco2cfohlo6cb.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%2Fwbghi0vjco2cfohlo6cb.png" alt="Alt Text" width="533" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I like that "plus" button, and managed to add it:&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%2Fdl92360fdaemxpdm5kdc.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%2Fdl92360fdaemxpdm5kdc.png" alt="Alt Text" width="383" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just go to Settings &lt;code&gt;(Ctrl + Alt + S) &amp;gt; Appearance &amp;amp; Behavior &amp;gt; VCS Local Changes Toolbar&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;You can add the "Add" button by clicking on the "Add actions..." and searching for the "Add" action inside &lt;code&gt;Version Control Systems &amp;gt; Git&lt;/code&gt; (sorry for that tongue twister 😂)&lt;/p&gt;

&lt;p&gt;Now, you can add the "Add" button to stage a file. I mostly use this functionality for when I don't want to add all files in the stage by using the terminal (i.e. &lt;code&gt;git add .&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Staged files (??)
&lt;/h2&gt;

&lt;p&gt;When the file is staged, you have a button to unstage a file in VSCode:&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%2F06qb0mu3j9opghh7dcl5.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%2F06qb0mu3j9opghh7dcl5.png" alt="Alt Text" width="543" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, I don't see this option in Webstorm. Neither there is a separation between "staged" and "unstaged" file in the Commit tab in Webstorm nor PHPStorm. Do you know how to achieve this or if this is possible? &lt;/p&gt;

&lt;p&gt;Thanks in advance.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Best way to handle lots of logic inside React Class Components</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Mon, 22 Feb 2021 23:14:12 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/best-way-to-handle-lots-of-logic-inside-react-class-components-1k5n</link>
      <guid>https://dev.to/davidarmendariz/best-way-to-handle-lots-of-logic-inside-react-class-components-1k5n</guid>
      <description>&lt;h1&gt;
  
  
  Context
&lt;/h1&gt;

&lt;p&gt;We have a (very huge) application where sometimes there are files with 1000+ lines of code. What makes these files big are the logic of some methods. Wether we have too much logic on our component or not is not something I would like to discuss, at the end of the day, this is a production app and we have limited resources and limited time, so we need to find the best way to optimize the codebase while meeting deadlines (welcome to the real world!).&lt;/p&gt;

&lt;p&gt;For example, suppose I have something like this:&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;class&lt;/span&gt; &lt;span class="nc"&gt;MyComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Lots of bindings&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;myHugeMethod1&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Lots of logic that depends on this.props and probably other (hopefully smaller) class methods&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;myHugeMethod2&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Lots of logic that depends on this.props and probably other (hopefully smaller) class methods&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// the render&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Our approach
&lt;/h2&gt;

&lt;p&gt;We have obviously thought about lots of things: utility functions, static methods and classes with a single method. I personally find the last one the best approach. And this is what we have agreed to be the best approach (although we are not 100% sure):&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;import&lt;/span&gt; &lt;span class="nx"&gt;MyHelperMethod1&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./MyHelperMethod1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyHelperMethod2&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./MyHelperMethod2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Lots of bindings&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myHelperMethod1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;myHelperMethod1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fixedProperties&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;myHelperMethod2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;myHelperMethod2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fixedProperties&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;myHugeMethod1&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;myHelperMethod1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setVariableProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;variableProperties&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;myHelperMethod1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;help&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;myHugeMethod2&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;myHelperMethod2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setVariableProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;variableProperties&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;myHelperMethod2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;help&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// the render&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;variableProperties&lt;/code&gt; variable is probably an object. And probably &lt;code&gt;this.props&lt;/code&gt; is going to be included inside of this object. It can feel odd, but that's how I do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you do it?
&lt;/h2&gt;

&lt;p&gt;I want to hear about your approaches to handle these situations.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
      <category>oop</category>
      <category>javascript</category>
    </item>
    <item>
      <title>My first LeetCode problem with GoLang</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Mon, 22 Feb 2021 00:40:36 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/my-first-leetcode-problem-with-golang-5a4h</link>
      <guid>https://dev.to/davidarmendariz/my-first-leetcode-problem-with-golang-5a4h</guid>
      <description>&lt;p&gt;Hi everyone! &lt;br&gt;
I am learning Go and I find it an awesome programming language. I solved my first LeetCode problem using this language:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/QDsMIRU3o-Q"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>go</category>
      <category>programming</category>
    </item>
    <item>
      <title>This is my identity number validator package (NPM)</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Sun, 21 Feb 2021 15:36:27 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/this-is-my-identity-number-validator-package-npm-36oi</link>
      <guid>https://dev.to/davidarmendariz/this-is-my-identity-number-validator-package-npm-36oi</guid>
      <description>&lt;p&gt;Some time ago, I released an extremely simple project, yet extremely useful: an identity number validator package. &lt;br&gt;
In my country (Ecuador) we have a simple algorithm to validate if an identity number (we call it "cédula") is valid or not. I have worked in many projects where we need to validate this, and I had to re-write the algorithm every time. So why not make it public?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/identity-number-validator" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/identity-number-validator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you have something similar in your country? If yes, would you like to contribute?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>discuss</category>
      <category>contributorswanted</category>
    </item>
    <item>
      <title>If programmers were writers...</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Fri, 19 Feb 2021 02:48:39 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/if-programmers-were-writers-a93</link>
      <guid>https://dev.to/davidarmendariz/if-programmers-were-writers-a93</guid>
      <description>&lt;p&gt;We as programmers can learn a lot from writers.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The first draft has a high chance to suck
&lt;/h2&gt;

&lt;p&gt;It doesn't matter if you are an expert in Django or Express or React or whatever. The first version of your code will suck. But don't worry, it's perfectly normal. And you will be refactoring that code later, won't you?&lt;/p&gt;

&lt;h2&gt;
  
  
  2. You have to proofread your own work
&lt;/h2&gt;

&lt;p&gt;Other people proofread your work via pull requests. But you need to also proofread your code before doing that pull request! This is what I &lt;em&gt;normally&lt;/em&gt; do. Start creating a pull request, but don't create it. Just look at the changes on those &lt;em&gt;beautiful&lt;/em&gt; UIs in GitHub, Bitbucket or GitLab. Did you accidentally include a &lt;code&gt;console.log&lt;/code&gt;? Don't worry, just remove it and start proofreading your work again. Start asking yourself questions. Should I move this variable to a constant? Should I move this piece of code to its own method? After you think your code is perfect, create that pull request!&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Let others proofread your work
&lt;/h2&gt;

&lt;p&gt;Ok, this one is pretty obvious. Your code needs to be reviewed before going to production right? Well, I just want to add something else here: &lt;strong&gt;never, ever, take a pull request personally&lt;/strong&gt;. Pull requests are there for you to be better, not to harm your ego.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. There will be a second or third draft
&lt;/h2&gt;

&lt;p&gt;This is related to point 1. Remember I told you to refactor your code? Well, as Nike says: &lt;em&gt;just do it&lt;/em&gt;. And if you are touching someone else's code, be that guy in the team to leave the house clean. That means, refactor other people code if necessary!&lt;/p&gt;

&lt;h2&gt;
  
  
  5. A finished piece is better than a perfect WIP
&lt;/h2&gt;

&lt;p&gt;Again, &lt;em&gt;just do it&lt;/em&gt;. If you are seeking perfection and never deploying code, then why are you writing code? Code will never be perfect. Just push that damn code to production already.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Keep a cohesive narrative
&lt;/h2&gt;

&lt;p&gt;Write code as if you were writing a predictable yet exciting tale. In software development, predictable is in some sense good. You are writing your React app with class based components? That's fine. But please, don't start mixing functional components and class based components because YOLO. &lt;/p&gt;

&lt;p&gt;Just wanted to share this with you. Bye, bye! And also, don't forget to subscribe to my channel: &lt;a href="https://www.youtube.com/channel/UC4jmaY21ri9n3DteRwuoJaA" rel="noopener noreferrer"&gt;YouTube Channel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>codequality</category>
    </item>
    <item>
      <title>JavaScript Primitives have methods and properties! Wait what?</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Sun, 14 Feb 2021 16:33:25 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/javascript-primitives-have-methods-and-properties-wait-what-h26</link>
      <guid>https://dev.to/davidarmendariz/javascript-primitives-have-methods-and-properties-wait-what-h26</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/phglBX1FHuc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Hey guys! How are you?&lt;/p&gt;

&lt;p&gt;Last time, I was discussing with a colleague that everything in Python was an object. Even numbers. To show this, I just did the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;__add__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# should print 4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is, numbers have &lt;em&gt;methods&lt;/em&gt;.&lt;br&gt;
The same is true for other programming languages like Ruby.&lt;br&gt;
However, in basically every other programming language (including JavaScript) we do have primitives. How do we create them? Well, with single or double quotes, like this:&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;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;foo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we take the type of this variable it will be of type string:&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// "string"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How do we create string objects? Like this:&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;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// "object"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thus, if we compare the values of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; we will get:&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you know, the &lt;code&gt;==&lt;/code&gt; operator will compare for equality after doing any necessary type conversions. The &lt;code&gt;===&lt;/code&gt; operator won't do any conversion. And as &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; are of different types, then we get &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can also get primitives from &lt;code&gt;String&lt;/code&gt; calls in a non constructor context. That means, called without the &lt;code&gt;new&lt;/code&gt; keyword).&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;let&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;String&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// "string"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you see, this time the &lt;code&gt;===&lt;/code&gt; operator returns &lt;code&gt;true&lt;/code&gt; because &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; are both primitives.&lt;/p&gt;

&lt;h2&gt;
  
  
  But then, why we can call methods of primitives?
&lt;/h2&gt;

&lt;p&gt;Certainly, we can do something like this:&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// "FOO"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can get the &lt;code&gt;length&lt;/code&gt; property of a primitive and call a &lt;code&gt;toUpperCase&lt;/code&gt; method. Wait what? How can a primitive have &lt;em&gt;properties&lt;/em&gt; and &lt;em&gt;methods&lt;/em&gt;? &lt;/p&gt;

&lt;p&gt;Well, they don't. It depends on the &lt;strong&gt;context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When a method is to be invoked on a primitive string or a property lookup occurs, JavaScript &lt;strong&gt;will automatically wrap the string primitive and call the method or perform the property lookup&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The same happens with the other primitives in JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;BigInt&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Symbol&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get the primitive value from these objects, just call the &lt;code&gt;valueOf()&lt;/code&gt; method. For example:&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;let&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;valueOf&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty cool!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>6 things we can learn from writers</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Thu, 04 Feb 2021 02:16:53 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/6-things-we-can-learn-from-writers-4lkh</link>
      <guid>https://dev.to/davidarmendariz/6-things-we-can-learn-from-writers-4lkh</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Gkdk38PHPVI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL; DR&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your first draft always sucks&lt;/li&gt;
&lt;li&gt;Proofread your own work&lt;/li&gt;
&lt;li&gt;Let others proofread your work&lt;/li&gt;
&lt;li&gt;There will probably be a second or third draft&lt;/li&gt;
&lt;li&gt;A finished piece is better than a perfect work in progress&lt;/li&gt;
&lt;li&gt;Keep a cohesive narrative&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>writing</category>
      <category>codenewbie</category>
      <category>codequality</category>
      <category>programming</category>
    </item>
    <item>
      <title>Sorting comparator</title>
      <dc:creator>David Armendáriz</dc:creator>
      <pubDate>Tue, 02 Feb 2021 02:41:52 +0000</pubDate>
      <link>https://dev.to/davidarmendariz/sorting-comparator-20hl</link>
      <guid>https://dev.to/davidarmendariz/sorting-comparator-20hl</guid>
      <description>&lt;p&gt;In Javascript, we have the sort method for arrays. If "a" is less than "b" by some ordering criterion, then we return -1. If "a" is greater than "b" by the ordering criterion, we return 1. This is the basic idea to sort things. We can do the same for Python. In this video, I solve the problem of sorting by a score in &lt;strong&gt;descending order&lt;/strong&gt; and then by name in &lt;strong&gt;ascending order&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/U1mZwzOVD4A"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
