<?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>Forem: José Clovis Ramírez de la Rosa</title>
    <description>The latest articles on Forem by José Clovis Ramírez de la Rosa (@clovis1122).</description>
    <link>https://forem.com/clovis1122</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%2F83707%2F1519969d-9ff4-4096-837f-d728de74312a.jpeg</url>
      <title>Forem: José Clovis Ramírez de la Rosa</title>
      <link>https://forem.com/clovis1122</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/clovis1122"/>
    <language>en</language>
    <item>
      <title>Does your team use React Hooks? Mine doesn't</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Thu, 06 Jun 2019 11:24:41 +0000</pubDate>
      <link>https://forem.com/clovis1122/do-your-team-use-react-hooks-mine-doesn-t-52a7</link>
      <guid>https://forem.com/clovis1122/do-your-team-use-react-hooks-mine-doesn-t-52a7</guid>
      <description>&lt;p&gt;So there it goes. &lt;a href="https://reactjs.org/docs/hooks-intro.html"&gt;React v16.8 introduced hooks&lt;/a&gt;, a way to use state and other React features without writing classes. Folks who started a new project or managed to migrate their existing project already have access to use hooks!&lt;/p&gt;

&lt;p&gt;We've recently managed to migrate to React 16.8, but still, haven't made it to Hooks yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  I didn't think it would be a big deal
&lt;/h2&gt;

&lt;p&gt;Some weeks after the migration, I had to implement a feature that shows a modal to the users and allows them to withdraw from all the jobs that they applied to. I had already used hooks in a project before and was anxious to start creating some awesome hooks! &lt;a href="https://medium.com/@dawchihliou/replacing-react-reduxs-connect-with-react-hooks-1c65e2a6909"&gt;Using this article&lt;/a&gt;, I made a custom &lt;code&gt;useCurrentUser&lt;/code&gt; hook which looks neat, and when I needed state, I got my hands on &lt;code&gt;useState&lt;/code&gt; instead of converting the component to a class.&lt;/p&gt;

&lt;p&gt;When I first made the PR, to my surprise, none of my Senior coworkers understood what I was doing!&lt;/p&gt;

&lt;h2&gt;
  
  
  The offender
&lt;/h2&gt;

&lt;p&gt;Due to the way the project was made, we do data fetching inside the component. How do we do it with Hooks? Checking on the &lt;a href="https://reactjs.org/docs/hooks-faq.html#how-can-i-do-data-fetching-with-hooks"&gt;docs&lt;/a&gt;, I used the following workaround:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight jsx"&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;let&lt;/span&gt; &lt;span class="nx"&gt;ignore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nx"&gt;getSubscriptions&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt;&lt;span class="nx"&gt;isSeeking&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sendNewsTips&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ignore&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&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;}&lt;/span&gt;
      &lt;span class="nx"&gt;setIsSeeking&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isSeeking&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;setNewsTips&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sendNewsTips&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;setOriginalIsSeeking&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sendNewsTips&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;return&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="nx"&gt;ignore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Overall they didn't like the idea, but this piece of code threw them off. The code just seemed too cryptical to anyone reading it, particularly the &lt;code&gt;ignore&lt;/code&gt; variable and how it is being used. Seems like using a class would make it look a lot cleaner.&lt;/p&gt;

&lt;h2&gt;
  
  
  The reasons against Hooks
&lt;/h2&gt;

&lt;p&gt;I took notes of their main concerns and made the following list:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introducing hooks is a big change to the project that requires team discussion to check if we should start writing all the new components using hooks.&lt;/li&gt;
&lt;li&gt;Hooks are still new, incomplete, and encourages code like the above which is too cryptical in comparison with the class-based way to do it.&lt;/li&gt;
&lt;li&gt;Hooks might be the future, but they're not the present. There're a lot of components written using classes and switching between them makes it hard to be productive (NOTE: they don't agree with &lt;a href="https://twitter.com/dan_abramov/status/1135407371566624769"&gt;this tweet&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Sometimes it might be faster to deliver the feature using a class-based approach rather than writing hooks.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Thoughts?
&lt;/h2&gt;

&lt;p&gt;It makes sense to me that if the team is not onboard with hooks yet, it might be better to hold it off. Eventually, hopefully, it might be reconsidered later on.&lt;/p&gt;

&lt;p&gt;Do you/your team use Hooks? Why or Why not?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>YOU and YOUR TEAM should start taking technical decisions!</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Sun, 02 Jun 2019 02:41:19 +0000</pubDate>
      <link>https://forem.com/clovis1122/you-and-your-team-should-start-taking-technical-decisions-3cfo</link>
      <guid>https://forem.com/clovis1122/you-and-your-team-should-start-taking-technical-decisions-3cfo</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://images.unsplash.com/photo-1531429062145-f089688084a6"&gt;Photo by Lubo Minar on Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Uh, oh, that dead code again.&lt;/p&gt;

&lt;p&gt;Much of the time we let the managers know that there's &lt;em&gt;a lot&lt;/em&gt; of technical debt in the code: untested code, leaky abstractions, sometimes even variables named &lt;code&gt;a, b&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt;. We need to set up a CI and a linter. But when?&lt;/p&gt;

&lt;p&gt;In this post, you'll see why you should care about taking technical decisions, and why you need to start participating, proposing, and/or proactively make them along with your team.&lt;/p&gt;

&lt;h3&gt;
  
  
  I always thought that these depended on management!
&lt;/h3&gt;

&lt;p&gt;Software is meant to help people accomplish their goal. Also turns out, Managers are the ones that know &lt;em&gt;what needs to be done&lt;/em&gt; from a business perspective to accomplish the goals. Therefore, it makes sense that they should decide &lt;em&gt;when&lt;/em&gt; it would be a good time to tackle the technical debt?&lt;/p&gt;

&lt;p&gt;When I initially reached this conclusion, I abandoned refactor. I abandoned tests and radicalized my point of view about business having the final say on every technical decision. Blogs like these became my mantra: &lt;em&gt;&lt;a href="https://omniti.com/seeds/your-code-may-be-elegant.html"&gt;Your code may be elegant, but mine f***ing works&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Turns out, you also know what needs to be done
&lt;/h3&gt;

&lt;p&gt;A year ago, I stumbled across this passage from &lt;em&gt;&lt;a href="https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164"&gt;Clean Architecture&lt;/a&gt;, by Uncle Bob&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  Fight for the Architecture.
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;“Fulfilling this responsibility means wading into a fight—or perhaps a better word is “struggle.” Frankly, that’s always the way these things are done. The development team has to struggle for what they believe to be best for the company, and so do the management team, and the marketing team, and the sales team, and the operations team. It’s always a struggle.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The passage opened a crack on my beliefs. Why should we fight with the people that know &lt;em&gt;what needs to be done&lt;/em&gt;? Shouldn't the managers be the one factoring out all the constraints, including technical debt? Turns out most of the times these constraints are overlooked - indeed, only the people experiencing the problem knows that the problem exists.&lt;/p&gt;

&lt;p&gt;Most of the bigger goals depends on smaller goals to be achieved. &lt;strong&gt;It's the work of the doers - people like you, who make things happen&lt;/strong&gt;. Who else knows best what you need to do in order to accomplish your tasks?&lt;/p&gt;

&lt;h3&gt;
  
  
  You are responsible for the success of the product -- and your work
&lt;/h3&gt;

&lt;p&gt;When unexpected things happen - be it breaking a fragile piece of code, or failing to meet a previously agreed deadline - who's to be blamed? Turns out you're the one responsible for estimating your tasks and working on it within the constraints. Unexpected things often occur of a lack of quality in the work that you're expected to flawlessly do.&lt;/p&gt;

&lt;p&gt;If you estimate a task to be completed in 3 hours, but it ends up taking 8 hours - because by doing it you broke something else and had to spent 5 hours tracing and fixing the issues - &lt;strong&gt;YOU will be responsible of it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure quality in your work - that is, to meet the requirements within the given constraints while avoiding unexpected issues, you need to impose certain quality requirements to the work that you do. Does it require tests? Does it require to pass a linter? These tasks don't necessarily deliver a feature to your customers, but helps you to do so!&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping up
&lt;/h3&gt;

&lt;p&gt;You, who work on the code on a daily basis, know best what kind of problems you're dealing with. To solve these problems, you must take actions. If you don't and instead rely on your product owner or another authoritative person to, they might not see the problem until it becomes too late. When things start to crumble and you're unable to meet your estimations - the fault with be on you.&lt;/p&gt;

&lt;p&gt;Because you want to do the best out of your work and hold it to high-quality standards, you need to proactively take actions to combat the technical debt. Doing this is part of your work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://overreacted.io/fix-like-no-ones-watching/"&gt;Fix like no one's watching&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;Apart from the linked content, this article helped me a lot to articulate my ideas around the topic: &lt;a href="https://blog.ploeh.dk/2019/03/18/the-programmer-as-decision-maker"&gt;The programmer as decision maker&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>writing</category>
      <category>motivation</category>
      <category>devtips</category>
      <category>career</category>
    </item>
    <item>
      <title>I got my first returned ticket on a project. TWICE.</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Tue, 16 Apr 2019 12:45:47 +0000</pubDate>
      <link>https://forem.com/clovis1122/i-got-my-first-ticket-returned-on-a-new-project-twice-22n8</link>
      <guid>https://forem.com/clovis1122/i-got-my-first-ticket-returned-on-a-new-project-twice-22n8</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mCN5dpyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgflip.com/2ypiy4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mCN5dpyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgflip.com/2ypiy4.jpg" alt="So you're telling me you're pushing code without testing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's the same mistake from all the times. A seemly easy ticket is assigned to you. You quickly go through the code and recognize that one line that's causing the issue...&lt;/p&gt;

&lt;h2&gt;
  
  
  The Scenario
&lt;/h2&gt;

&lt;p&gt;I was assigned a task: "&lt;em&gt;The company's URL is not working properly&lt;/em&gt;". I first managed to reproduce the issue and saw that the current URL was being appended with some kind-of dot-notation inside square brackets.&lt;/p&gt;

&lt;p&gt;This code caught my attention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"company-details"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {% if company.logo %}
          &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"{{ company.logo.url }}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      {% endif %}
  &lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Company Details&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ company.description }}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"social"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    {% if company.homepage %}
      &lt;span class="c"&gt;&amp;lt;!-- NOTICE THE NEXT LINE --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"[[ company.homepage.url ]]"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;target=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    {% endif %}

    {% for link in company.links.all %}
        {% if link.share_platform %}
            &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{ link.url }}"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;target=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"{% static images/app/company/background.jpg %}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        {% endif %}
    {% endfor %}
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I quickly noticed the square brackets that were out of context here. I quickly changed the brackets, commit and pushed the code to QA.&lt;/p&gt;

&lt;p&gt;QA returned the ticket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing audacity with more audacity
&lt;/h2&gt;

&lt;p&gt;When I saw the evidence, it seemed like the square brackets were still there. I checked GitHub to see if I pushed the right code, then made a search for all the places where we were using the company's homepage.&lt;/p&gt;

&lt;p&gt;Turns out there was a second template where the same error was made. "&lt;em&gt;Okay, this is definitively the issue!&lt;/em&gt;" - I said to myself, and yet once again - quickly fixed, committed, and pushed yet more untested code. &lt;strong&gt;I was completely confident that this was the issue.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nevermind me. QA returned the ticket, again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing things right
&lt;/h2&gt;

&lt;p&gt;Turns out this time the company's URL was sending the user back to... the same page. Seeing the ticket being returned for the second time sent me back to the Earth. This evidently wasn't something I could do with eyes closed, so I decided that I would do it the right way this time.&lt;/p&gt;

&lt;p&gt;After reviewing the case I found out that &lt;code&gt;company.homepage&lt;/code&gt; was a string! There was no &lt;code&gt;url&lt;/code&gt; property, so nothing was being rendered. I fixed the issue but this time I entered to the application as a normal user to make sure that it was fixed. Confirming this, I pushed the code to QA again, keeping an eye on it until it passed QA successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR, always test what you're doing
&lt;/h2&gt;

&lt;p&gt;Sometimes, we might fall under the temptation of making changes and assuring that it will work. You may do it because you don't want to spend time compiling the project, turning up&amp;amp;down those &lt;code&gt;docker-compose&lt;/code&gt; services, redeploying your code to Dokku or, like me, simply didn't want to go to your project's company page to click on an URL.&lt;/p&gt;

&lt;p&gt;As tedious as the validation process may be, in the long run, you'll waste much less time testing your changes before passing them to QA. They will also keep your QA metrics healthy :)&lt;/p&gt;

</description>
      <category>qa</category>
      <category>test</category>
    </item>
    <item>
      <title>Top docker images that I tend to use ad-hoc</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Thu, 31 Jan 2019 02:42:41 +0000</pubDate>
      <link>https://forem.com/clovis1122/top-docker-images-that-i-tend-to-use-ad-hoc-342g</link>
      <guid>https://forem.com/clovis1122/top-docker-images-that-i-tend-to-use-ad-hoc-342g</guid>
      <description>&lt;p&gt;Docker is a great tool for building and shipping Software. Many teams around the world are taking advantages of its features. For Development, it is particularly useful to be able to declare your whole stack in a &lt;code&gt;docker-compose.yml&lt;/code&gt; file and bringing it up and down with all the dependencies and packages that it needs to run.&lt;/p&gt;

&lt;p&gt;I tend to use Docker a lot, not only as part of a project but also to perform several ad-hoc tasks. The primary benefit for me is that I don't have to bother installing and then removing the required software - a Docker image is all that's needed to spin-up a container! Here's the top list of Docker images that I tend to use ad-hoc.&lt;/p&gt;

&lt;p&gt;1.Adminer&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fmanuelcesarini.it%2Fwp-content%2Fuploads%2F2017%2F05%2Fadminer-logo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fmanuelcesarini.it%2Fwp-content%2Fuploads%2F2017%2F05%2Fadminer-logo.jpg"&gt;&lt;/a&gt;&lt;br&gt;
Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. It comes very handily when you need to access an external Database and having a UI will be of help.&lt;/p&gt;

&lt;p&gt;Docker command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 adminer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-p 8080:8080 = link the host port 8080 with the container port 8080.
-d = run on detached mode.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Nginx&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.logolynx.com%2Fimages%2Flogolynx%2F61%2F61c738af9de36116116271f3003c9f07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.logolynx.com%2Fimages%2Flogolynx%2F61%2F61c738af9de36116116271f3003c9f07.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nginx is a high-performance Web server and the go-to solution for multiple companies around the world. If you've ever had to configure it then you may appreciate being able to do it in your machine, rather than having to connect to the host where it is running.&lt;/p&gt;

&lt;p&gt;Docker command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80:80 &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/usr/share/nginx/html nginx bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-p 80:80 = link the host port 80 with the container port 80.
-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /usr/share/nginx/html is the place inside the container where it will be mounted.
nginx bash = run bash inside nginx (Inside the container you can run nginx commands as much as you want).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Ansible&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcSAUWECBfidOSKEcRqfj_EYKCCd7oTnSIvgETsE0QGXZNajCRwi" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcSAUWECBfidOSKEcRqfj_EYKCCd7oTnSIvgETsE0QGXZNajCRwi"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ansible is an automation tool for apps and IT infrastructure. It is like Chef and Puppet. You tell Ansible how to connect to the host and define how the host should be configured, and it will go to configure the host for you.&lt;/p&gt;

&lt;p&gt;Docker command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/app ansible bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /app is the place inside the container where it will be mounted.
ansible bash = run bash inside ansible (Inside the container you can run ansible commands as much as you want).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Sqlite3&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2AfMPUMki182HzyVZvo_awDw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2AfMPUMki182HzyVZvo_awDw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. The data can be stored either on a single file in the disk or in-memory.&lt;/p&gt;

&lt;p&gt;I've been using sqlite3 a lot lately to interact with a Python webscrapper that have the data in an SQLite file. The CLI and the instructions could get better, but definitively does the job!&lt;/p&gt;

&lt;p&gt;Docker command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/root/db &lt;span class="nt"&gt;--entrypoint&lt;/span&gt; bash nouchka/sqlite3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /root/db is the place inside the container where it will be mounted.
--entrypoint = sets the entrypoint command of the container. In this case, the entrypoint will be Bash.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes about the docker run commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can add &lt;code&gt;--rm&lt;/code&gt; and it will remove the container as soon as it stops.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the ones that I tend to use nowadays. Of course, I also use ad-hoc images when I'm learning something (latest were Python3 and Elixir/Phoenix) or under other circumstances (checking if I'm ready for Node V10 or giving maintenance to an old PHP5.4 app).&lt;/p&gt;

&lt;p&gt;Of course, if you're running an ad-hoc container a lot for one specific project, you may want to consider using &lt;code&gt;docker-compose&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;Do you usead-hoc images in your day-to-day? Which ones?&lt;/p&gt;

</description>
      <category>docker</category>
    </item>
    <item>
      <title>I love to document my code. Am I doing it wrong?</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Sat, 08 Sep 2018 11:17:51 +0000</pubDate>
      <link>https://forem.com/clovis1122/i-love-to-document-my-code-am-i-doing-it-wrong-1n54</link>
      <guid>https://forem.com/clovis1122/i-love-to-document-my-code-am-i-doing-it-wrong-1n54</guid>
      <description>&lt;p&gt;I've been saved countless of times by people who document their code, and also doomed by people who doesn't. At some point I just started to love comments, even the most redundant ones. &lt;strong&gt;I strongly believe that a comment is never wrong, unless outdated or misleading&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sadly not much people seems to like this stance. Instead of documenting our functions, we rely on the naming convention and writing expressive code to figure out the &lt;code&gt;what&lt;/code&gt; and the &lt;code&gt;why&lt;/code&gt; of any code. Sometimes we even have aesthetic troubles with it, as if the comments were distracting us from the code itself.&lt;/p&gt;

&lt;p&gt;I like to write expressive code, but I don't see it as a replacement of proper documentation.&lt;/p&gt;

&lt;p&gt;Am I doing it wrong?&lt;/p&gt;

</description>
      <category>code</category>
      <category>documenting</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Don't make that function async.</title>
      <dc:creator>José Clovis Ramírez de la Rosa</dc:creator>
      <pubDate>Thu, 19 Jul 2018 01:00:36 +0000</pubDate>
      <link>https://forem.com/clovis1122/dont-make-that-function-async-9m6</link>
      <guid>https://forem.com/clovis1122/dont-make-that-function-async-9m6</guid>
      <description>&lt;p&gt;Today's a good day to write Javascript code. ES2015 and the newest features that are coming to the language every year makes it a joy to use. With ES2017, Javascript gained Async/Await, which gives a more concise, expressive syntax to handle asynchronous code. It is available in the latest releases of Node and it can be transpiled using Babel to target the browser.&lt;/p&gt;

&lt;p&gt;However, as awesome as it may be, marking a function as async won't magically make your code more performant.  More often than not, I stumble against this type of code:&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;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saveUserInDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&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;Oh, is &lt;em&gt;that&lt;/em&gt; type of async function again.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens when you await a function.
&lt;/h3&gt;

&lt;p&gt;When using the keyword &lt;code&gt;await&lt;/code&gt;, Javascript will pause the function's execution and return the control to it's caller until the asynchronous operation is completed. In the previous example, our saveUser function will stay standby, waiting for the promise returned by the call to the method &lt;code&gt;saveUserInDatabase(userData)&lt;/code&gt; to regain the control and return the results.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdnudzojp8zjbiyk5cuuw.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdnudzojp8zjbiyk5cuuw.png" width="403" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now imagine that we make &lt;em&gt;every single function async&lt;/em&gt;. Every function would have to wait for every individual function to be resolved, then that function will get back the control, just to give it back to that function's caller. Under this circumstance the Node process will have to start/stop and save/recover every function's execution state. This actually makes the code less performant!&lt;/p&gt;

&lt;p&gt;Imagine if we have several layers in our system, each waiting for the other one to complete to temporally gain the control and give it back again. Your callstack might end up looking 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9owrs9akdefu8fqw8r17.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9owrs9akdefu8fqw8r17.png" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Advices for making a function async.
&lt;/h3&gt;

&lt;p&gt;Generally speaking, async functions are just a promise. They represent a future value that has not been computed yet (can also be seen as an ongoing event). It is a good practice to delay the Promise's computation as much as possible until the value is needed. I think that an async function is a good idea if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You need the value of another async function:&lt;/strong&gt; For example, you may want to wait at the database layer for a query to complete so that you can wrap the result and transform it into an entity of your domain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You need to perform extra steps after the completion of an async function:&lt;/strong&gt; For example, it would be okay to wait for the user to save in the database if we wanted to send him an email right after. We can return a promise that symbolizes the user email instead.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saveUserInDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// We need the user.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendUserEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// this.sendUserEmail is another async function.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You need to handle the exception:&lt;/strong&gt; Sometimes you want to run an async operation but you need to respond to an eventual failure at that layer's level. For example, we could await the database layer execution when creating an user if we have to delete the user profile picture on failure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It makes the code more expressive:&lt;/strong&gt; There may be a time where we need to make a tradeoff between performance and cleaner code :).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wrapping up.
&lt;/h3&gt;

&lt;p&gt;Async/Await is one of the best things ever reaching the Javascript world. It is a powerful and expressive way to express asynchronous operations. With all this greatness, overusing it can hurt performance, readability and creates complexity - a complexity that it's just not worth the effort sometimes. When creating functions, it is a good idea to &lt;strong&gt;give back the control to the function's caller as fast as possible&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>async</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
