<?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: Adrian Guillen</title>
    <description>The latest articles on Forem by Adrian Guillen (@adriangube).</description>
    <link>https://forem.com/adriangube</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%2F605312%2F59bbc52e-8e75-4203-9440-f5cf01bb7e43.png</url>
      <title>Forem: Adrian Guillen</title>
      <link>https://forem.com/adriangube</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/adriangube"/>
    <language>en</language>
    <item>
      <title>What is a typical day like as a developer? 🖥️😵‍💫☕</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Wed, 21 Aug 2024 16:33:54 +0000</pubDate>
      <link>https://forem.com/adriangube/how-is-a-day-in-a-developers-life-3oj8</link>
      <guid>https://forem.com/adriangube/how-is-a-day-in-a-developers-life-3oj8</guid>
      <description>&lt;p&gt;When someone starts learning programming and searches for information about how a developer lifestyle is, it’s easy to find a lot of &lt;strong&gt;contradictory messages&lt;/strong&gt; and some of them are really unhealthy. One of the most controversial topics is &lt;strong&gt;how a programmer spends his time&lt;/strong&gt;, and that’s why I’m writing this article, to bring some light and clarify how in my experience a developer spends his day.&lt;/p&gt;

&lt;p&gt;First of all, I will share a little about myself so you can have some context about my experience as a developer. I’ve been working as a frontend developer in Spain and Ireland for more than 7 years at the time of writing this article (August 2024). I worked in a medium size consultancy company for a year, around 4 years in a small consultancy company making projects for IBM and other companies of different sizes, then I've work for a year at Atrapalo who is an online travel agency and my last two jobs had been in Ireland working on a product company and my current one is an AI startup. As you can see I have experience in consultancy but also in product based companies, and startups and I worked in very different environments, projects and applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqachtegk9tx3cnwramu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqachtegk9tx3cnwramu.png" alt="Person working in a desktop setup" width="720" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How developers spend their time
&lt;/h2&gt;

&lt;p&gt;Is pretty common to hear in the IT community about developers who say that they spend &lt;strong&gt;hundreds of hours&lt;/strong&gt; per week developing, or working on side projects, contributing on Open Source projects, drinking coffee and writing thousands of lines of code. But what is the reality of an average developer? I say “average developer” because some of the people who share their content on social media &lt;strong&gt;aren’t showing the reality of their life&lt;/strong&gt;, but the parts they want to share, and usually the reality they show isn’t the one of an average developer as you or myself.&lt;/p&gt;

&lt;p&gt;Some people think that a developer is a machine that transforms ideas (and coffee) to code, but programmers do &lt;strong&gt;way more things other than programming&lt;/strong&gt;. For example, if you work in a medium or big company it is usual to follow an agile workflow, that means that the application or product that you are developing would be released to the client in different phases. If you work with agile &lt;strong&gt;it is common to have a meeting every day&lt;/strong&gt; with the developer team to share with your teammates what you did the day before, what are you going to do today and if you had some problems. And also it is common to make demonstration meetings with the client &lt;strong&gt;every few weeks&lt;/strong&gt; to show him the project progress.&lt;/p&gt;

&lt;p&gt;Whether developers work in an agile workflow or not, they will spend time in meetings &lt;strong&gt;every day&lt;/strong&gt; because in the real world, the team needs to prioritize tasks, share knowledge between them, or discuss the better way to solve a problem.&lt;/p&gt;

&lt;p&gt;Every day when a developer starts working, the first thing is to &lt;strong&gt;remember&lt;/strong&gt; the work done the day before, it may sound dumb, but a lot of time is spend this way, and if the problem is complex, the amount of time needed to start working will &lt;strong&gt;increase exponentially&lt;/strong&gt;. And after every meeting this process starts again, so if a developer has lots of meetings in a day it would be very difficult to be productive.&lt;/p&gt;

&lt;p&gt;When developers start working on a problem the first thing they do &lt;strong&gt;isn’t write code&lt;/strong&gt;, the first thing usually is &lt;strong&gt;analyze the problem&lt;/strong&gt;, and figure out the best way to solve it. If a programmer starts writing code without analyzing the problem, the code resulting will be in most cases &lt;strong&gt;poor&lt;/strong&gt;, so the most common scenario is spending some time thinking about different ways to solve it. Also it is common to ask for help or different opinions to another teammate, specially when you're facing challenging problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgrketmz29kuw8xarkfh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgrketmz29kuw8xarkfh.png" alt="Developer looking to his laptop" width="720" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The developers face new problems almost every day, so it is common that they need to learn new things constantly. They spend a lot of time googling, learning from tutorials, forums or documentation. A developer &lt;strong&gt;doesn’t need to know everything&lt;/strong&gt;, only where to find the information needed every time.&lt;/p&gt;

&lt;p&gt;Finally, when a developer isn’t in a meeting and knows what needs to be done and how to do it, the programmer will start writing code. As you can see, writing code isn’t the first thing a developer does every day in the morning when starts working.&lt;/p&gt;

&lt;h2&gt;
  
  
  How much time does a developer spend writing code?
&lt;/h2&gt;

&lt;p&gt;Is difficult to measure how much time a developer spends writing code, but if we are talking about an 8 hours workday, I assume that &lt;strong&gt;only 3–5 hours&lt;/strong&gt; will be spent writing code, but definitely no more than that. This is an approximation, it is impossible to measure the amount of time spent programming, and it depends a lot on the experience of the developer and the company that developer is working for.&lt;/p&gt;

&lt;p&gt;Is common to think that the more experienced the developer is the more time spent programming, &lt;strong&gt;but this is completely wrong&lt;/strong&gt;. In fact, the more skilled you are the more the team will need your help. Also you will spend more time &lt;strong&gt;helping other teammates&lt;/strong&gt; and taking part in meetings with clients or the product team &lt;strong&gt;instead of programming&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I hope that this article will help to break some myths about how a developer spent his time. What do you think about it? How do you spend your time? Do you think that you spend more than 3–5 hours writing code?&lt;/p&gt;

</description>
      <category>devlive</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>👀Understanding the JavaScript Call Stack: How Your Code Really Runs 🚀</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Mon, 19 Aug 2024 19:28:36 +0000</pubDate>
      <link>https://forem.com/adriangube/demystifying-the-javascript-call-stack-how-your-code-really-runs-9m</link>
      <guid>https://forem.com/adriangube/demystifying-the-javascript-call-stack-how-your-code-really-runs-9m</guid>
      <description>&lt;p&gt;How the &lt;strong&gt;JavaScript call stack&lt;/strong&gt; works is something that every frontend developer has asked at least once in his career, and in my opinion, it's not a question that has been answered in most places, and the answers are not always clear or easy to understand. That's why I've decided to cover the topic in this post. &lt;/p&gt;

&lt;p&gt;Let's start from the beginning. The JavaScript engine &lt;strong&gt;runs the code line by line synchronously&lt;/strong&gt;, and every time a function is executed, it creates an execution context (a &lt;strong&gt;space in memory&lt;/strong&gt; to store all the scoped properties that exist only inside that function) &lt;strong&gt;and adds the function to the call stack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;JavaScript only executes the code of the function that is on the &lt;strong&gt;top of the stack&lt;/strong&gt;, and when a function finalises and returns its value, the engine &lt;strong&gt;removes the function from the call stack&lt;/strong&gt; and starts working on the next one.&lt;/p&gt;

&lt;p&gt;When the &lt;strong&gt;call stack is empty&lt;/strong&gt;, the JavaScript engine &lt;strong&gt;continues running the code in the next global context&lt;/strong&gt;, or what is the same, continues executing the lines that are in &lt;strong&gt;the root of the JavaScript file&lt;/strong&gt; and don't belong to any function. &lt;/p&gt;

&lt;p&gt;Let's see some examples, line by line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&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;num2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sum&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="k"&gt;return&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num2&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;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 7&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This is a really simple code that defines 2 constants (num1 and num2) and then defines a function &lt;strong&gt;sum&lt;/strong&gt; that sums 2 numbers and returns the result of the sum. Finally, the constant &lt;em&gt;result&lt;/em&gt; is created, and the &lt;strong&gt;result of executing sum&lt;/strong&gt; with the arguments &lt;em&gt;num1&lt;/em&gt; and &lt;em&gt;num2&lt;/em&gt; is assigned to it. Then the value of the &lt;em&gt;result&lt;/em&gt; is printed on the console. &lt;/p&gt;

&lt;p&gt;If you think that the previous explanation is too simple or too complex and does not explain anything, &lt;strong&gt;please bear with me&lt;/strong&gt;, we are getting to the interesting stuff. &lt;/p&gt;

&lt;p&gt;Let's see what the JavaScript engine is doing, &lt;strong&gt;line by line&lt;/strong&gt;. In the first line, the engine creates a label &lt;em&gt;num1&lt;/em&gt; and stores &lt;strong&gt;in memory&lt;/strong&gt; the value &lt;em&gt;2&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second line does the same for label &lt;em&gt;num2&lt;/em&gt;. It creates a label &lt;em&gt;num2&lt;/em&gt; and stores in memory the value &lt;em&gt;5&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this means is that whenever someone inside the &lt;strong&gt;global scope&lt;/strong&gt; requires the value of &lt;em&gt;num2&lt;/em&gt; the engine is going to &lt;strong&gt;change the label and put the value &lt;em&gt;5&lt;/em&gt; instead&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Let's continue with the next line. The next line is the &lt;strong&gt;function&lt;/strong&gt; &lt;em&gt;sum&lt;/em&gt;. What do you think the engine is going to do? Do you think it is going to execute the function or add it to the call stack? &lt;strong&gt;Nope!&lt;/strong&gt; What the engine is going to do is &lt;strong&gt;store a new label&lt;/strong&gt; named &lt;em&gt;sum&lt;/em&gt; and &lt;strong&gt;store the code inside the brackets in memory&lt;/strong&gt;. Or what is the same, It's going to store the &lt;strong&gt;function definition&lt;/strong&gt; and assign it to the &lt;em&gt;sum&lt;/em&gt; label.&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;function&lt;/span&gt; &lt;span class="nf"&gt;sum&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="k"&gt;return&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if we could &lt;strong&gt;visually see the memory&lt;/strong&gt; of the code that we've run so far, we would see something like this: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;num1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;num2&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sum&lt;/td&gt;
&lt;td&gt;function definition&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The next line is a &lt;strong&gt;really&lt;/strong&gt; interesting one. When the JavaScript engine reaches the next line, it creates the label &lt;em&gt;result&lt;/em&gt;, but at this point, &lt;strong&gt;it doesn't yet know what value needs to be assigned to the label&lt;/strong&gt; because &lt;strong&gt;the value is the result of executing a function&lt;/strong&gt;, so first, it needs to execute the function, do whatever the function needs to do, and &lt;strong&gt;get the result from the return value&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the engine &lt;strong&gt;adds the function to the call stack&lt;/strong&gt; and also creates a &lt;strong&gt;new execution context&lt;/strong&gt;, which is a new &lt;strong&gt;space in memory&lt;/strong&gt; were JavaScript can store the value of the args and every other property that is inside of the function without colliding with the global context. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sum&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;First of all, the engine creates in memory the labels &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt; which are the names given to the parameters, and it assigns the value of the arguments &lt;em&gt;2&lt;/em&gt; and &lt;em&gt;5&lt;/em&gt; respectively. &lt;/p&gt;

&lt;p&gt;If we could see the memory at this specific moment, we would see something like this: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;return&lt;/td&gt;
&lt;td&gt;2 + 5 = 7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In this case, the function is really simple and only returns the value of the &lt;em&gt;sum&lt;/em&gt; between &lt;em&gt;a&lt;/em&gt; and &lt;em&gt;b&lt;/em&gt;, so the engine &lt;strong&gt;substitutes the parameters with the values of the arguments&lt;/strong&gt; and returns the value to the global execution context. Finally, &lt;strong&gt;the function is removed from the call stack&lt;/strong&gt;, and only the global context remains. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At this point, the result of the function is assigned to the label &lt;em&gt;result&lt;/em&gt; and we can print the value on console with the console log. &lt;/p&gt;

&lt;p&gt;Let's take a look at how the global memory looks now: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;num1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;num2&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sum&lt;/td&gt;
&lt;td&gt;function definition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;result&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Did you noticed? the label &lt;em&gt;result&lt;/em&gt; has a value of &lt;em&gt;7&lt;/em&gt;? and also &lt;em&gt;sum&lt;/em&gt; still has the function definition inside. &lt;/p&gt;

&lt;p&gt;Let's take a look at the next 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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&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;num2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sum&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="k"&gt;return&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;num2&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;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 7&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sumThreeNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;z&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;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;z&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;result2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sumThreeNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&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="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;result2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 12&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The main difference is that now we have a new &lt;em&gt;sumThreeNumbers&lt;/em&gt; function and we are creating a new &lt;em&gt;result2&lt;/em&gt; constant and assigning the value of running the function &lt;em&gt;sumThreeNumbers&lt;/em&gt; with the arguments, &lt;em&gt;4&lt;/em&gt;, &lt;em&gt;6&lt;/em&gt; and &lt;em&gt;2&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Let's take a look at &lt;strong&gt;how the call stack works when we run nested functions&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;If we jump to the line when we define the constant &lt;em&gt;result2&lt;/em&gt; the global memory would look something like this: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;num1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;num2&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sum&lt;/td&gt;
&lt;td&gt;function definition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;result&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sumThreeNumbers&lt;/td&gt;
&lt;td&gt;function definition&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Just as on the previous example, the JavaScript engine &lt;strong&gt;doesn't know what value to assign&lt;/strong&gt; to the label &lt;em&gt;result2&lt;/em&gt;, to get the value,  &lt;strong&gt;first needs to execute the function&lt;/strong&gt; &lt;em&gt;sumThreeNumbers&lt;/em&gt; with the arguments. The function is &lt;strong&gt;added to the call stack&lt;/strong&gt;, and a new execution context is created. The execution context would look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;x&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;y&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;z&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So the first thing that JavaScript does is create the parameter labels and assign the value provided by the arguments. &lt;/p&gt;

&lt;p&gt;Now let's take a look at our call stack&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sumThreeNumbers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As you can see, the call stack only has the &lt;em&gt;sumThreeNumbers&lt;/em&gt; item (apart from the global context that is always present). &lt;/p&gt;

&lt;p&gt;To be able to get the result value, &lt;strong&gt;the function sum needs to be executed&lt;/strong&gt; first, so the engine will &lt;strong&gt;add the function to the call stack&lt;/strong&gt; and create a new execution context for the sum function. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sum&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sumThreeNumbers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As the sum function is on &lt;strong&gt;top of the call stack&lt;/strong&gt;, Javascript needs to &lt;strong&gt;run &lt;em&gt;sum&lt;/em&gt; first to be able to continue running &lt;em&gt;sumThreeNumbers&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;This is how it's going to look the execution context for the function sum: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;return&lt;/td&gt;
&lt;td&gt;4 + 6 = 10&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As you know, it will return _10 _and it will be removed from the call stack&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sumThreeNumbers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The JavaScript is going to continue executing the &lt;em&gt;sumThreeNumbers&lt;/em&gt; and the execution context will look like this: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label name&lt;/th&gt;
&lt;th&gt;Value in memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;x&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;y&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;z&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;return&lt;/td&gt;
&lt;td&gt;10 + 2 = 12&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It will return the value &lt;em&gt;12&lt;/em&gt; and be removed from the call stack. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call stack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then the value &lt;em&gt;12&lt;/em&gt; will be assigned to the property &lt;em&gt;result2&lt;/em&gt; and the value &lt;em&gt;12&lt;/em&gt; will be displayed in the console.&lt;/p&gt;

&lt;p&gt;I hope this post has help you to understand &lt;strong&gt;how the JavaScript call stack works&lt;/strong&gt;, if so please leave a comment and a like. I see you in the next one! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>coding</category>
    </item>
    <item>
      <title>❌ How to Cancel Fetch Requests in JavaScript 🚀</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Sun, 30 Jun 2024 12:47:49 +0000</pubDate>
      <link>https://forem.com/adriangube/how-to-cancel-fetch-requests-in-javascript-4ggd</link>
      <guid>https://forem.com/adriangube/how-to-cancel-fetch-requests-in-javascript-4ggd</guid>
      <description>&lt;p&gt;Ever wanted to &lt;strong&gt;cancel a fetch request in JavaScript?&lt;/strong&gt; Discover how the **AbortController **makes it easy to manage and stop async operations. Check out this quick guide to master it in just a few steps!&lt;/p&gt;

&lt;p&gt;First, you might wonder when you would need to cancel a fetch request. Here are an examples:&lt;/p&gt;

&lt;p&gt;When &lt;strong&gt;filtering a list of elements&lt;/strong&gt; in &lt;strong&gt;JavaScript&lt;/strong&gt;, the data often comes from an &lt;strong&gt;API&lt;/strong&gt;. It’s common to add filtering, pagination, and other features to display the list correctly. However, &lt;strong&gt;JavaScript&lt;/strong&gt; does &lt;strong&gt;not guarantee&lt;/strong&gt; that fetch requests will be resolved in the &lt;strong&gt;order&lt;/strong&gt; they were made.&lt;/p&gt;

&lt;p&gt;For instance, if a user applies filters &lt;strong&gt;quickly&lt;/strong&gt;, you might make requests A, B, and C in that order. Ideally, you want to display the results of the latest request (C) last. However, due to the fact that the browser and server work &lt;strong&gt;asynchronously&lt;/strong&gt;, requests might resolve &lt;strong&gt;out of order&lt;/strong&gt;. Request C could be resolved first, followed by A and B, leading to &lt;strong&gt;incorrect data being displayed to the user&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In such situations, &lt;strong&gt;AbortController **helps by allowing you to **cancel requests A and B&lt;/strong&gt;, ensuring only the latest request (C) is active. This way, the user sees the &lt;strong&gt;expected results&lt;/strong&gt;.&lt;br&gt;
I’m going to show you &lt;strong&gt;step by step&lt;/strong&gt; an example about how to use &lt;strong&gt;AbortController&lt;/strong&gt; to handle this kind of situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;, create an &lt;strong&gt;AbortController instance&lt;/strong&gt;. Retrieve the signal from the controller, which will be used to control the fetch request.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd77zvsoyjfnbxg3ub23.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd77zvsoyjfnbxg3ub23.png" alt="Step 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, use the &lt;strong&gt;signal&lt;/strong&gt; in the fetch &lt;strong&gt;request options&lt;/strong&gt;. Handle the response by logging the data. If an error occurs, check if it's an **AbortError **to know if the request was cancelled using the AbortController. If not, you can handle the error as usual. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkm292dch2vm30xf3bcf.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkm292dch2vm30xf3bcf.png" alt="Step 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, when you need to &lt;strong&gt;cancel the fetch request&lt;/strong&gt;, because for example, a user is selecting a new filter you can use &lt;strong&gt;controller.abort&lt;/strong&gt; to cancel the previous request. I’m using a setTimeout in this example for simplicity. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwf2tgo0blkozsqwk7fn.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwf2tgo0blkozsqwk7fn.png" alt="Step 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the complete code example.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbklb37ti4o8uewwnopd.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbklb37ti4o8uewwnopd.png" alt="Complete Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’ve found this short tutorial helpful, please like this post and share it with your colleagues and friends.  Have you previously used the AbortController? Share your thoughts in the comments below!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>✈️ Moving Abroad: My Journey as a Frontend Developer in a New Country 🌎</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Mon, 24 Jun 2024 21:10:20 +0000</pubDate>
      <link>https://forem.com/adriangube/my-experience-moving-to-another-country-as-a-developer-3895</link>
      <guid>https://forem.com/adriangube/my-experience-moving-to-another-country-as-a-developer-3895</guid>
      <description>&lt;p&gt;In the next few lines, I will share my personal experience of moving from Barcelona to Dublin while working as a developer. It has been a very interesting experience with more than a few challenges, and finally, almost 2 years later, I’m ready to share my experience.&lt;/p&gt;

&lt;p&gt;Everything started as all big changes do, with a mix of excitement, fear, and a lot of planning. It was a very planned decision, as my wife and I had spent countless hours talking about leaving Spain to try a different country. We knew that our future country needed to be in Europe, as none of us wanted to be too far from our family, and we knew that we wanted to live in a country where their main language was English. That left only two potential options: the UK and Ireland. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfsvabt73l9j75skaw1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfsvabt73l9j75skaw1x.png" alt="Designed by Freepik" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before Brexit, we both liked the idea of moving to Scotland, as we’ve been there on vacation a few times, and we really liked the lifestyle and people, and my wife was especially in love with Edinburgh. However, Brexit changed everything. As you may know, after Brexit, you need to get a visa to stay in the UK. Besides, the COVID situation was pretty recent (it was 2022), so we felt like trying to move to the UK was too risky for us. The only option left was Ireland. &lt;/p&gt;

&lt;p&gt;I knew that Ireland had the headquarters of the biggest tech companies in the world, such as Google, Amazon, Apple, Microsoft, and many more, so for me, Ireland was an option that really excited me from a career point of view. There was only one tiny problem. I had never visited the country, and apart from knowing that it could be good for my career, I had no idea about it. My wife, on the contrary, had visited Ireland on one occasion, and she really liked the lifestyle and the culture, as it’s relatively similar to Scotland, with green landmarks, a lot of castles and monuments, and a lot of nature around, which is something that we both value a lot.&lt;/p&gt;

&lt;p&gt;After investigating the country from very different points of view (economics, politics, culture, history, cost of living, salaries, work market, etc.), I found it pretty appealing, especially since we were living in Spain, which was facing economic problems, and the work market was pretty slow with a huge unemployment rate (it still has one of the higher unemployment rates in Europe). &lt;/p&gt;

&lt;p&gt;Ireland was not perfect, though. After some investigation, I found that Ireland was facing a severe housing crisis, and the cost of living has been skyrocketing since the start of the war in Ukraine. I was not scared, though, as Spain was facing the same issues, and to be fair, I think most of the problems that I found online were the same in most parts of Europe.&lt;/p&gt;

&lt;p&gt;So, once the decision about the country was made, there was a tiny, small detail to solve. We only wanted to move to Ireland once I found a job while still living in Spain, as we thought it would be too risky to leave our stable jobs in Spain to live in a different country without having a job or having any contact that could help us in case things didn’t go as planned as they usually do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking for a job in Ireland from Spain
&lt;/h2&gt;

&lt;p&gt;First of all, I would like to share a little bit about my background. In 2022, I had a little more than 5 years of experience, and I was working in Spain for an online travel agency called Atrapalo as a senior frontend developer, working with technologies such as Next.js, React, and Typescript and following clean architectures such as domain-driven design. In summary, I like to think that I have a really good CV, as I’ve always tried to work for companies that make me grow in my career and offer me opportunities to learn the latest technologies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftudu21l9b10olimwvxt1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftudu21l9b10olimwvxt1.png" alt="Designed by Freepik" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that in mind, I started translating all my LinkedIn and CVs from Spanish to English, and I started applying to different job positions. &lt;/p&gt;

&lt;p&gt;I also started speaking in English with my wife daily to practice, as I was not 100% fluent, especially when speaking. By then, my English was good enough to read (a few months prior to making the final decision to move, I started reading books only in English), and I was able to understand 80% of a conversation, but when I tried to speak, I felt really awkward, and I got extremely nervous. After a month of speaking daily and exclusively in English with my wife, I improved enough to feel relatively comfortable having phone interviews without choking.&lt;/p&gt;

&lt;p&gt;After a month of sending CV’s and having some phone interviews with recruiters, I reached the final stage with 2 companies. I got an offer from one of them, which I decided to accept. The offer was good enough, but in the lower range for someone with my skillset. And there was no relocation package and no fancy perks. However, for me, the most important part was the opportunity that this job offered me. We were moving to Ireland.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing to move to Ireland
&lt;/h2&gt;

&lt;p&gt;When I received the offer, I told the company that I needed six weeks to be ready. Two of these weeks were to finish the relationship with my current employer (as it’s common in Spain), two weeks to make the proper arrangements to move, and 2 weeks to establish ourselves in Ireland.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk62eyahdcg6qy7l0i08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk62eyahdcg6qy7l0i08.png" alt="Designed by Freepik" width="720" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This seems like enough time, but there was so much that needed to be done. First of all, we tried to sell all the things that were worth selling. We gifted or threw away the rest. We also got our passports in place (it’s not really needed because we were moving inside Europe, but it’s always a good idea to have the passports ready just in case). We also started looking for temporary accommodation in Ireland, as it was impossible to rent anything while living in Spain due to the housing crisis and the fact that we had a Spanish phone number, and for some reason, maybe because of the high demand, no landlord was willing to call us back, so we finally ended up renting for 3 weeks an apartment in the centre of Dublin, as my position was fully remote within Ireland and we wanted to be close to the public transport, and it’s always easy to move around if you’re in a city.&lt;/p&gt;

&lt;p&gt;The last few days, apart from doing the usual preparations, we decided to spend as much time as possible with family and friends, and in no time it was the night prior to our flight to Ireland.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first few weeks in Ireland
&lt;/h2&gt;

&lt;p&gt;As soon as we reached the Dublin airport, my wife and I had one and only one obsession: to find long-term accommodation in Dublin. We did our investigation online, and it was really hard to find any place to rent in the city, and we only had the booking for 3 weeks, so the clock was ticking. &lt;/p&gt;

&lt;p&gt;We got some prepaid Irish phone numbers, and we started applying to every accommodation that was published on several online portals. We had notifications active, and every time we got one, we stopped doing whatever we were doing at the moment to send an application. &lt;/p&gt;

&lt;p&gt;The only two requisites that were non-negotiable for us were that it needed to have two rooms (one to sleep in and another so I could work), and we didn’t want to share the place with other people. It was one of the most stressful moments of my life. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flb0685lmlfomi7ph380n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flb0685lmlfomi7ph380n.png" alt="Been stressed" width="640" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During these few days, we also tried to open a bank account in Ireland because it’s always easy to do some paperwork if you have a local bank account, and also because my new employer asked me for a bank account with an Irish IBAN. However, for some reason, it was impossible to open a bank account without permanent residency. There was some workaround that we tried with an online bank account (nowadays Revolut offers an Irish IBAN), but in the end it didn’t work for us, and my employer offered me to use Wise instead of a conventional bank.&lt;/p&gt;

&lt;p&gt;After a week in Dublin, we had the opportunity to visit a few apartments, but we were not selected by the landlords, or it was not what we were expecting from the place. It’s impressive what some state agents can do with nice lighting and Photoshop.&lt;/p&gt;

&lt;p&gt;We were pretty anxious by then, but some evening we received a call from the state agent that managed the first house that we went to see in Dublin (a nice and small 2-bed terrace house from the 70’s) saying that the landlady was offering to rent the house to us. It was quite expensive, in the upper bracket of our budget, but we decided to accept it as it had been hell to find anything that fit our expectations and was in living conditions.&lt;/p&gt;

&lt;p&gt;A week later, still living in the temporary apartment, I started my new position as a senior frontend developer, and two weeks later we moved to our new home.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working as a developer in a different country
&lt;/h2&gt;

&lt;p&gt;As I mentioned before, I worked fully remotely in my new position. This was not new for me because, even before the pandemic, I used to work hybrid, going to the office only 2 days per week, and after the pandemic, I had plenty of time to get used to working from home most of the time. &lt;/p&gt;

&lt;p&gt;One of the biggest differences that I discovered about my colleagues is that everyone is really polite with each other. It's not that in Spain people are rude or anything like that, but Spanish as a language is more direct, and it’s common to use commanding sentences. In Ireland, however, people are more polite and use more indirect ways of asking for things. That’s something that I eventually got used to, but in the beginning, it took me some time to start talking this way. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafn916zaxsko9gesa9ox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafn916zaxsko9gesa9ox.png" alt="People working" width="640" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another difference that I noticed was that people respect the working hours, and except on exceptional occasions, I was never asked to work overtime. On the contrary, in Spain, it is pretty common to work as a developer for nine or even ten hours per day, depending on the company. And no, in case you’re asking yourself about it, nobody pays you for the overtime hours. &lt;/p&gt;

&lt;p&gt;Other than that, the kind of job and the project that I worked on were pretty similar to my previous experiences. The main difference was that in Ireland we had less stress in general and the timing was more realistic, but that could perfectly be because I got lucky with the companies that I’ve been working for so far. &lt;/p&gt;

&lt;h2&gt;
  
  
  Being in emergency tax and getting the PPSN
&lt;/h2&gt;

&lt;p&gt;Something to consider when moving to Ireland is that to be able to pay taxes, you need to have a PPS number. And when you first arrive in the country, you obviously don’t have one. You cannot require one without employment and permanent residency in Ireland. &lt;/p&gt;

&lt;p&gt;If you don’t have this number, you will be subject to the emergency tax. This basically means they are going to tax all your salary at 40%, which is the maximum rate. There is no way to prevent this from happening, so in the first few months that it takes to request the PPS number, you will only get a little more than half of your salary. After that, you can request to get your money back, and I must say that the revenue is really fast, giving you back what is yours.&lt;/p&gt;

&lt;h2&gt;
  
  
  Weather
&lt;/h2&gt;

&lt;p&gt;Some people imagine Ireland as this grey country, always rainy and windy. And they are not wrong; there is some truth in that. It rains a lot, but I must say that we don’t experience heavy rain too frequently; most of the time, it is very light rain. To be honest, I really like the humid days when there is a very subtle rain outside and I’m working, warm, and cosy at home. The summer is mild, and the days are longer and way sunnier, which I really appreciate compared to Spain, where the summer is like living in hell at 35 degrees Celsius.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkmdljtuurri1pgjek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkmdljtuurri1pgjek.png" alt="Rain" width="640" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, during winter we don’t have much sunlight, and I take vitamin D supplements as I used to be a little bit low on morale, which never happened to me before living in Spain.&lt;/p&gt;

&lt;p&gt;In general, I like the weather here, but it’s a very personal thing, and I know that there are a lot of people, especially those living in warm countries, who find it really difficult to live in Ireland because of the weather.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Almost two years later, we are still living in the same 2-bed terrace house. I’m working for a different employer for almost double my initial salary in Ireland, and we are about to buy a house in the country. So much has happened since then, but everything started with the desire to improve in life and not be complacent in our comfort zone. I have not regretted it even once.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>career</category>
      <category>careerdevelopment</category>
    </item>
    <item>
      <title>Cómo es un día en la vida de un programador</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Sun, 14 Nov 2021 13:14:48 +0000</pubDate>
      <link>https://forem.com/adriangube/como-es-un-dia-en-la-vida-de-un-programador-1nj2</link>
      <guid>https://forem.com/adriangube/como-es-un-dia-en-la-vida-de-un-programador-1nj2</guid>
      <description>&lt;p&gt;Cuando alguien empieza a aprender programación y busca información sobre cómo es la vida de un programador, es fácil encontrar mucha &lt;strong&gt;información contradictoria&lt;/strong&gt; y en algunos casos incluso perjudicial. Uno de los temas más controvertidos es &lt;strong&gt;cómo invierte su tiempo un programador&lt;/strong&gt; y por eso mismo estoy escribiendo este artículo, para tratar de aportar un poco de luz y aclarar, según &lt;strong&gt;mi experiencia&lt;/strong&gt;, como es un día en la vida de un programador.&lt;/p&gt;

&lt;p&gt;En primer lugar me gustaría compartir un poco de mi trayectoria profesional para que tengas contexto sobre quien soy y cual es mi experiencia. En el momento de escribir este artículo (Noviembre de 2021) llevo trabajando como desarrollador frontend en España unos 5 años. Trabajé 1 año en una consultora mediana, 3 años en una consultora pequeña que hacía grandes proyectos para IBM entre otras empresas, y actualmente trabajo en Atrápalo, que es una agencia de viajes que tiene presencia en España y parte de latinoamérica. Como puedes ver tengo experiencia en consultoría pero también he trabajado en empresas de producto y a lo largo de los años he trabajado en todo tipo de proyectos, equipos de trabajo, y aplicaciones.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t9x33z21hwh04xfho87.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0t9x33z21hwh04xfho87.JPG" alt="me programming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cómo invierten su tiempo los programadores
&lt;/h2&gt;

&lt;p&gt;En la comunidad IT es muy común escuchar sobre desarrolladores que dicen que invierten &lt;strong&gt;cientos de horas&lt;/strong&gt; a la semana programando, trabajando en side projects, contribuyendo en software libre, bebiendo café y escribiendo miles de horas de código. ¿Pero en qué invierte su tiempo un desarrollador promedio? Fíjate que he dicho "desarrollador promedio" porque en muchas ocasiones las personas que comparten contenido &lt;strong&gt;no muestran la realidad de su vida&lt;/strong&gt;, sino simplemente el trozo que les interesa compartir y lo que muestran no suele ser lo que un desarrollador promedio suele hacer.&lt;/p&gt;

&lt;p&gt;Hay quien piensa que un programador es una máquina de transformar ideas (y café) en código, pero los programadores hacen &lt;strong&gt;bastantes más cosas&lt;/strong&gt; aparte de escribir código. Por ejemplo los desarrolladores que trabajan en empresas medianas o grandes acostumbran a utilizar  metodologías ágiles, esto significa que la aplicación o producto que están desarrollando se desarrolla en diferentes fases en vez de entregar el proyecto de golpe al final del desarrollo. En este tipo de entornos los desarrolladores acostumbran a hacer &lt;strong&gt;reuniones diarias&lt;/strong&gt; para hablar sobre lo que hicieron el día anterior, que harán durante el día de hoy y si se encontraron con algún bloqueo al realizar su tarea. En este tipo de entornos es muy común hacer reuniones de demostración con el cliente de forma &lt;strong&gt;periódica&lt;/strong&gt; para que pueda ir viendo la evolución del proyecto. &lt;br&gt;
Además tanto si trabajan en un entorno ágil como si no lo hacen, los desarrolladores invierten tiempo en reuniones &lt;strong&gt;todos los días&lt;/strong&gt;. Los motivos más comunes suelen ser priorizar tareas dentro del equipo, decidir cómo se afrontará una tarea especialmente complicada, compartir conocimiento y ayudar a otros miembros de equipo que tienen algún problema. &lt;/p&gt;

&lt;p&gt;Por otro lado, cada día cuando un programador empieza a trabajar, una de las primeras cosas que hace es &lt;strong&gt;recordar&lt;/strong&gt; en que estuvo trabajando el día anterior. Esto puede parecer una tontería, pero se invierte bastante tiempo del día en &lt;strong&gt;recuperar el contexto&lt;/strong&gt; de lo que se estaba haciendo, especialmente si la tarea era muy complicada, o es la primera vez que el programador se enfrenta a ella. Tal y como hemos visto en el párrafo anterior, los desarrolladores acostumbran a tener &lt;strong&gt;varias reuniones cada día&lt;/strong&gt;, lo que supone que después de cada reunión también se tiene que &lt;strong&gt;invertir&lt;/strong&gt; algo de tiempo en recordar que se estaba haciendo antes de poder empezar a programar. Por lo tanto, si un programador tiene muchas reuniones en un mismo día, será &lt;strong&gt;muy difícil&lt;/strong&gt; que sea productivo porque deberá invertir tiempo constantemente en recuperar el hilo de lo que estaba haciendo anteriormente. &lt;/p&gt;

&lt;p&gt;Cuando un desarrollador empieza a programar lo primero que hace &lt;strong&gt;no es escribir código&lt;/strong&gt;, lo primero que se suele hacer es &lt;strong&gt;analizar el problema&lt;/strong&gt; que se está intentando resolver para encontrar &lt;strong&gt;la mejor solución posible&lt;/strong&gt;. Si un programador empieza a escribir código sin analizar primero el problema, lo más probable es que el código que genere sea &lt;strong&gt;de poca calidad&lt;/strong&gt;, así que la fase de análisis es muy importante. En este punto también es muy común preguntar a compañeros más experimentados para buscar y debatir cual es la mejor solución.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F064iulc2a5t2434tk1t6.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F064iulc2a5t2434tk1t6.JPG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Los desarrolladores se enfrentan cada día a &lt;em&gt;nuevos retos&lt;/em&gt;, así que es muy común que durante su jornada sea necesario que busquen información constantemente. La mayoría de desarrolladores invierten tiempo buscando en google, aprendiendo de tutoriales, foros, o en la propia documentación. Un desarrollador &lt;strong&gt;no necesita saberlo todo&lt;/strong&gt;, simplemente necesita saber &lt;strong&gt;donde&lt;/strong&gt; encontrar la información necesaria en cada caso. &lt;/p&gt;

&lt;p&gt;Finalmente, cuando un desarrollador no está participando en reuniones, ya sabe como continuar con la tarea que estaba realizando, y ya tiene claro cómo va a resolver el problema, &lt;strong&gt;sólo entonces&lt;/strong&gt;, se pone a escribir código. Así que como puedes ver, escribir líneas de código no es la primera cosa que un programador hace por la mañana cuando empieza a trabajar. &lt;/p&gt;

&lt;h2&gt;
  
  
  Cuánto tiempo invierte un programador escribiendo código
&lt;/h2&gt;

&lt;p&gt;Es difícil medir cuánto tiempo pasa un desarrollador programando, pero si hablamos de una jornada laboral de 8 horas, calculo que de promedio se pasan unas &lt;strong&gt;3 - 5 horas máximo&lt;/strong&gt; escribiendo código. Evidentemente esto es una aproximación basada en mi experiencia personal, ya que es imposible calcular con exactitud el tiempo promedio que un programador pasa escribiendo código, además depende mucho del sector, la experiencia del programador y la empresa en la que trabaje.&lt;br&gt;
Es común pensar que contra más experiencia tiene un desarrollador más tiempo pasa programando, pero esto &lt;strong&gt;no suele ser cierto&lt;/strong&gt;. De hecho, contra más experimentado y hábil sea el programador &lt;strong&gt;menos líneas de código escribirá&lt;/strong&gt; porque invertirá más tiempo &lt;strong&gt;ayudando a otros&lt;/strong&gt; miembros del equipo, asistiendo a reuniones con clientes o analizando problemas de gran complejidad. &lt;/p&gt;

&lt;p&gt;Espero que este artículo ayude a romper algunos mitos sobre cómo los programadores invertimos nuestro tiempo. ¿Qué opinas al respecto? ¿Pasas más de 3 - 5 horas programando? &lt;/p&gt;

</description>
      <category>devlive</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Cómo estructurar un proyecto de React</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Sun, 07 Nov 2021 15:51:45 +0000</pubDate>
      <link>https://forem.com/adriangube/como-estructurar-un-proyecto-de-react-4b77</link>
      <guid>https://forem.com/adriangube/como-estructurar-un-proyecto-de-react-4b77</guid>
      <description>&lt;p&gt;En los anteriores artículos de esta serie de &lt;strong&gt;fundamentos de React&lt;/strong&gt; &lt;a href="https://dev.to/adriangube/como-crear-tu-primer-proyecto-de-react-113h"&gt;expliqué&lt;/a&gt; las tres mejores formas de crear un proyecto de React y también &lt;a href="https://dev.to/adriangube/que-hay-en-un-proyecto-de-react-creado-con-create-react-app-3b8a"&gt;analicé&lt;/a&gt; minuciosamente cada uno de los archivos y carpetas en un proyecto de React generado con Create React App. &lt;/p&gt;

&lt;p&gt;Ahora que ya sabemos cómo crear un proyecto y qué elementos contiene, el siguiente paso es empezar a programar nuestra propia app. En este artículo se va a explicar &lt;strong&gt;qué estrategias seguir paso a paso para empezar a programar una aplicación sencilla&lt;/strong&gt;. También dejaré a vuestra disposición el link a un &lt;a href="https://github.com/adriangube/article-cra" rel="noopener noreferrer"&gt;repositorio de github&lt;/a&gt; que he creado para la ocasión, donde se puede ver el resultado del proyecto que he usado como referencia en este artículo. &lt;/p&gt;

&lt;p&gt;Antes de entrar en detalle sobre la estructura de proyecto que propongo, me gustaría aclarar que me he basado en una &lt;strong&gt;estructura simplificada de Domain Driven Design&lt;/strong&gt;, que sea fácilmente escalable y que permita adaptarse con algunos ajustes a casi cualquier proyecto, sin embargo con el objetivo de &lt;strong&gt;simplificar el contenido de este post&lt;/strong&gt;, no explico en detalle qué es el DDD ni en qué conceptos se basa este tipo de arquitectura. En futuros artículos pretendo cubrir en profundidad sobre DDD entre otros temas. &lt;/p&gt;

&lt;p&gt;En este post vamos a trabajar principalmente dentro de la carpeta src, ya que es donde reside el código fuente de nuestra aplicación. En este artículo no se va a explicar qué hace cada uno de los archivos y directorios que existen inicialmente puesto que eso ya se cubrió en el artículo &lt;a href="https://dev.to/adriangube/que-hay-en-un-proyecto-de-react-creado-con-create-react-app-3b8a"&gt;anterior&lt;/a&gt;. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs76xjtl9phh2vg18k8lm.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs76xjtl9phh2vg18k8lm.png" alt="projecto inicial"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lo primero que me gusta hacer cuando creo un nuevo proyecto de React es crear una &lt;strong&gt;estructura básica de carpetas&lt;/strong&gt; que me permita tener el código &lt;strong&gt;organizado&lt;/strong&gt; para que sea &lt;strong&gt;fácil encontrar lo que estoy buscando&lt;/strong&gt; en cada momento una vez el proyecto va creciendo. &lt;/p&gt;

&lt;p&gt;Si no se genera una &lt;strong&gt;buena estructura&lt;/strong&gt; desde un principio, es posible que con el paso del tiempo el proyecto &lt;strong&gt;vaya creciendo en tamaño&lt;/strong&gt;, creándose componentes nuevos, archivos con lógica de negocio y utilidades y poco a poco, de forma casi imperceptible, &lt;strong&gt;será más difícil añadir mejoras y corregir bugs&lt;/strong&gt;, porque el proyecto que inicialmente eran unos pocos componentes, &lt;strong&gt;se ha convertido en un monstruo&lt;/strong&gt; con cientos archivos en los que nunca se encuentra a la primera lo que se busca.  &lt;/p&gt;

&lt;p&gt;Para &lt;strong&gt;evitar que esto ocurra&lt;/strong&gt;, me gusta hacer una &lt;strong&gt;estructura inicial de carpetas&lt;/strong&gt; muy básica que me &lt;strong&gt;permita ir ampliando conforme el proyecto se hace más grande&lt;/strong&gt; y que se adapte tanto a proyectos pequeños, medianos o (con un poco de trabajo) a proyectos grandes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Estructura de carpetas básica
&lt;/h2&gt;

&lt;p&gt;La estructura básica de proyecto que propongo es la siguiente:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpq2hossnfi2tviskoup.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpq2hossnfi2tviskoup.png" alt="basic structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En primer lugar, he creado la carpeta &lt;strong&gt;components&lt;/strong&gt; que será la encargada de contener los componentes React de nuestra aplicación. En este caso, como el proyecto parte de cero, tan solo tenemos el componente App, pero en el futuro, conforme vayamos ampliando el proyecto y creando más componentes, este será el directorio en el que irán contenidos.&lt;/p&gt;

&lt;p&gt;El segundo directorio que he creado es el &lt;strong&gt;domain&lt;/strong&gt; que es el directorio encargado de &lt;strong&gt;contener la lógica de negocio&lt;/strong&gt; de la aplicación. La lógica de negocio es toda aquella que es única del funcionamiento &lt;strong&gt;concreto de nuestro proyecto&lt;/strong&gt;, y que &lt;strong&gt;no depende de ningún framework&lt;/strong&gt; ni librería. Por ejemplo, si estamos creando una aplicación de calculadora, la función "suma", "resta"... forman parte de la lógica de negocio de nuestra aplicación.&lt;/p&gt;

&lt;p&gt;Es posible que te estés preguntando si tiene sentido crear este directorio desde un punto tan temprano del desarrollo, si el proyecto ahora mismo no es más que apenas un par de componentes sin lógica ninguna. La respuesta a esta pregunta es un rotundo &lt;strong&gt;"sí, es necesario",&lt;/strong&gt; el motivo es bien simple, &lt;strong&gt;si no creas este directorio desde el principio&lt;/strong&gt;, es fácil ir añadiendo esta lógica dentro de los componentes, lo que provocará que &lt;strong&gt;la lógica dependa de la librería de componentes que estés usando&lt;/strong&gt;, en este caso React. Por lo tanto, &lt;strong&gt;la lógica de negocio será más difícil de testear&lt;/strong&gt; y &lt;strong&gt;de reutilizar&lt;/strong&gt;. Si no tienes claro qué es la lógica de negocio, y porque es importante que no esté relacionada con React, no te preocupes, escribiré futuros artículos hablando sobre el tema. &lt;/p&gt;

&lt;p&gt;Por último he creado el directorio &lt;strong&gt;pages&lt;/strong&gt;, que será el encargado de &lt;strong&gt;contener las diferentes páginas de nuestra aplicación&lt;/strong&gt; en caso de que nuestra app tenga routing. &lt;strong&gt;Si nuestra aplicación&lt;/strong&gt; &lt;strong&gt;no tiene routing, es posible que no necesitemos este directorio,&lt;/strong&gt; en ese  caso es totalmente válido dejar el &lt;strong&gt;index.css y el index.js en la raíz del directorio src&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Como nuestro proyecto no va a tener rutas no vamos a utilizar el directorio pages, sin embargo es recomendable que en caso de tener una aplicación con routing lo utilices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Refinando la estructura de carpetas
&lt;/h2&gt;

&lt;p&gt;Esta estructura de carpetas que se ha propuesto es muy básica y se puede mejorar un poco más. Para ello lo primero que recomiendo es &lt;strong&gt;crear una carpeta por cada componente&lt;/strong&gt;, de forma que &lt;strong&gt;contenga todos los archivos de javascript, css y test&lt;/strong&gt; de ese componente. Por ejemplo he creado el directorio App que contiene lo siguiente:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85hxk3v8tsym8wrodgoa.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85hxk3v8tsym8wrodgoa.png" alt="component example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;De la misma forma, dentro de &lt;strong&gt;pages&lt;/strong&gt; es recomendable crear &lt;strong&gt;un directorio por cada página&lt;/strong&gt; de nuestra aplicación, en los que se &lt;strong&gt;incluirán los archivos de javascript, css y test&lt;/strong&gt;.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0zeheinl3k0m1wktmo3.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0zeheinl3k0m1wktmo3.png" alt="page example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;El directorio &lt;strong&gt;domain&lt;/strong&gt; es ligeramente diferente, porque al contener archivos con lógica de negocio, &lt;strong&gt;no tiene sentido crear una carpeta por cada archivo&lt;/strong&gt;, puesto que cada archivo ya contendrá las funciones, clases y métodos relacionados con una funcionalidad o grupo de funcionalidades. Por lo tanto &lt;strong&gt;la clasificación de archivos y carpetas debe estar relacionado a los diferentes elementos de dominio&lt;/strong&gt;. Un elemento de dominio es una &lt;strong&gt;entidad&lt;/strong&gt; que puede ser del mundo real o del dominio de la aplicación. &lt;/p&gt;

&lt;p&gt;Por ejemplo, si tenemos una aplicación de gestión de usuarios, un elemento de dominio es "usuario", y si en esta aplicación se gestionan roles de usuario, otro elemento de dominio podría ser "roles de usuario". En este caso hipotético crearíamos la carpeta &lt;strong&gt;usuario&lt;/strong&gt; dentro del &lt;strong&gt;domain&lt;/strong&gt; y dentro de esta carpeta crearíamos los diferentes archivos de lógica relacionados con el usuario. De la misma forma crearíamos la carpeta roles-de-usuario y dentro de esta escribiríamos los archivos relacionados con los roles. &lt;/p&gt;

&lt;p&gt;Si pese a estos ejemplos no ves claro que son los elementos de dominio en futuros artículos explicaré en profundidad qué son y cómo utilizarlos en tus proyectos. &lt;/p&gt;

&lt;h2&gt;
  
  
  Siguientes pasos a seguir
&lt;/h2&gt;

&lt;p&gt;La estructura de proyecto que he propuesto es válida para un proyecto muy sencillo, y a la que empieces a crear varios componentes, hacer llamadas al backend, etc &lt;strong&gt;deberás crear nuevos archivos y carpetas&lt;/strong&gt;. Una buena forma de continuar evolucionando tu proyecto es generar los directorios &lt;strong&gt;application e infrastructure&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;En el directorio &lt;strong&gt;application&lt;/strong&gt; puedes incluir los &lt;strong&gt;casos de uso&lt;/strong&gt; de tu aplicación, por ejemplo llamadas api rest, las actions para actualizar tus reducers, y los selectores que te permiten escuchar los cambios en el estado de tu aplicación. &lt;/p&gt;

&lt;p&gt;En el directorio &lt;strong&gt;infrastructure&lt;/strong&gt; puedes incluir clases o funciones que hagan &lt;strong&gt;abstracciones&lt;/strong&gt; de librerías de fetching, de forma que tu proyecto no esté acoplado a librerías de terceros, etc&lt;/p&gt;

&lt;p&gt;Si no tienes claro qué es el acoplamiento, ni porqué es necesario trabajar con abstracciones en futuros artículos cubriré con detenimiento estos conceptos. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Otros directorios&lt;/strong&gt; que se pueden añadir según se vayan necesitando son los directorios &lt;strong&gt;static, theme y config.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;El directorio &lt;strong&gt;static&lt;/strong&gt; es un directorio &lt;strong&gt;opcional&lt;/strong&gt;, que no está en todos los proyectos ya que hay proyectos en los que no es necesario, pero los proyectos que lo utilizan suele incluir todos los archivos estáticos que necesitan estar dentro del directorio src pero que no contienen código fuente, como por ejemplo &lt;strong&gt;imágenes o fuentes.&lt;/strong&gt; En el caso de nuestra aplicación podríamos crear el directorio static y poner dentro el archivo &lt;strong&gt;logo.svg&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;En el directorio &lt;strong&gt;config&lt;/strong&gt; es un directorio &lt;strong&gt;opcional,&lt;/strong&gt; en el que incluiremos todos los archivos de &lt;strong&gt;configuración de librerías&lt;/strong&gt;. En nuestra aplicación incluiríamos los archivos &lt;strong&gt;reportWebVitals.sj y setupTest.js&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Por último hay &lt;strong&gt;aplicaciones&lt;/strong&gt; &lt;strong&gt;grandes&lt;/strong&gt; que contienen muchos estilos css, y algunos de estos &lt;strong&gt;estilos son generales y compartidos&lt;/strong&gt; a lo largo de toda la aplicación. Para incluir estos archivos es común crear el directorio &lt;strong&gt;theme&lt;/strong&gt;, en el que se incluyen &lt;strong&gt;archivos con variables de css&lt;/strong&gt;, la configuración de las fuentes, variables de media queries etc. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6g4i3gjn08c5q8p2wbr.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6g4i3gjn08c5q8p2wbr.png" alt="next steps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Por último me gustaría animarte a que cometas errores, ya que una de las mejores formas de aprender qué estructura de proyecto funciona mejor para ti es equivocarte y aprender de tus errores. &lt;/p&gt;

&lt;p&gt;Foto de la cabecera por Antonio Batinić from Pexels&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Qué hay en un proyecto de React creado con Create React App</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Mon, 01 Nov 2021 16:11:29 +0000</pubDate>
      <link>https://forem.com/adriangube/que-hay-en-un-proyecto-de-react-creado-con-create-react-app-3b8a</link>
      <guid>https://forem.com/adriangube/que-hay-en-un-proyecto-de-react-creado-con-create-react-app-3b8a</guid>
      <description>&lt;p&gt;En mi anterior &lt;a href="https://dev.to/adriangube/como-crear-tu-primer-proyecto-de-react-113h"&gt;articulo&lt;/a&gt; expliqué las diferentes formas que existen para crear un proyecto de React, siendo &lt;a href="https://reactjs.org/docs/create-a-new-react-app.html" rel="noopener noreferrer"&gt;Create React App&lt;/a&gt; la mejor opción casi para cualquier tipo de aplicación web. &lt;/p&gt;

&lt;p&gt;En este articulo se creará un nuevo proyecto con Create React App y se explicará en profundidad, archivo por archivo, que es lo que genera por nosotros esta increíble herramienta. &lt;/p&gt;

&lt;p&gt;En primer lugar, necesitamos tener instalado &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node y npm&lt;/a&gt; en nuestra maquina y abrir un terminal de comandos. Si no tienes Node y npm instalados te recomiendo que sigas los pasos desde la web de Node y continúes cuando lo tengas correctamente instalado. &lt;/p&gt;

&lt;p&gt;Para crear un proyecto de React con Create React App tan solo es necesario en la terminal navegar al directorio donde queremos crear nuestro proyecto y escribir uno a uno los siguientes comandos:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;npx create-react-app my-app
cd my-app 
npm start
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;El primer comando es el que crea todo el proyecto, deberías cambiar &lt;em&gt;my-app&lt;/em&gt; por el nombre de tu proyecto. Este comando puede tardar unos cuantos minutos en terminar, esto es completamente normal ya que necesita crear todos los archivos y carpetas, así como instalar todas las dependencias iniciales para que el proyecto pueda funcionar correctamente.&lt;/p&gt;

&lt;p&gt;El segundo comando sirve para acceder desde la terminal al directorio del proyecto que ha creado Create React App. &lt;/p&gt;

&lt;p&gt;El ultimo comando sirve para arrancar el proyecto con un servidor local al que puedes acceder desde cualquier navegador, escribiendo en la ruta la dirección &lt;strong&gt;localhost:3000&lt;/strong&gt;. Una vez tienes arrancado el proyecto con &lt;strong&gt;npm start&lt;/strong&gt;, cualquier cambio que realices dentro del proyecto se verá reflejado en el navegador, prácticamente en tiempo real. &lt;/p&gt;

&lt;p&gt;A continuación, para poder trabajar en el proyecto es necesario que utilices algún editor de código, o IDE, como por ejemplo Visual Studio Code, que es una herramienta Open Source, gratuita, de las más utilizada dentro del sector profesional. Si te interesa como configurar y personalizar Visual Studio Code, en futuros artículos explicaré como configurarlo y cuales son las mejores extensiones para desarrolladores React. &lt;/p&gt;

&lt;p&gt;Para la ocasión, he creado un proyecto llamado &lt;strong&gt;article-cra&lt;/strong&gt; y este es el resultado de lo que ha generado Create React App:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjywgfdtr6iloh78ora7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjywgfdtr6iloh78ora7w.png" alt="Archivos generados por Create React App" width="404" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A continuación voy a explicar para que sirven cada uno de los archivos y carpetas que ha generado por nosotros Create React App.&lt;/p&gt;

&lt;h2&gt;
  
  
  Directorio node_modules
&lt;/h2&gt;

&lt;p&gt;El primer directorio que vemos en el proyecto es la carpeta &lt;strong&gt;node_modules&lt;/strong&gt;. Esta carpeta incluye todas las dependencias de nuestro proyecto, es decir, que se encuentran todas las librerías, utilidades, frameworks, etc que utiliza nuestro proyecto. Por ejemplo, la librería de React es una dependencia de nuestra app, y por lo tanto, &lt;strong&gt;el código fuente de React&lt;/strong&gt; se encuentra dentro de la carpeta &lt;strong&gt;node_modules&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Directorio public
&lt;/h2&gt;

&lt;p&gt;El siguiente directorio que se puede apreciar es el &lt;strong&gt;public&lt;/strong&gt;. Dentro de este directorio se encuentran todos los &lt;strong&gt;archivos estáticos&lt;/strong&gt;, es decir, que no necesitan ser compilados, ni forman parte del código fuente de nuestra aplicación. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tcb6xyzde2nvocwslwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tcb6xyzde2nvocwslwe.png" alt="Image description" width="404" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En este directorio se encuentra el &lt;strong&gt;favicon.ico&lt;/strong&gt;, que es el archivo de imagen que permite que aparezca el logo de React en la pestaña del navegador. Si cambiamos este icono por un icono diferente y refrescamos el navegador, deberíamos de ver el nuevo icono en el browser. &lt;/p&gt;

&lt;p&gt;El &lt;strong&gt;index.html&lt;/strong&gt; es el archivo de html principal de nuestro proyecto, y será el archivo que servirá nuestro servidor web cuando publiquemos en un servidor nuestra aplicación. &lt;br&gt;
Como mención especial, en este archivo se encuentra el div que utiliza react para inyectar el código de toda la aplicación react. Esto lo explicaré mejor en post sucesivos.&lt;/p&gt;

&lt;p&gt;Los archivos &lt;strong&gt;logo192.png&lt;/strong&gt; y &lt;strong&gt;logo512.png&lt;/strong&gt; son archivos de imagen que sirven por si queremos convertir nuestra aplicación en una Progressive Web App.  Las aplicaciones PWA se pueden instalar en dispositivos Android, IOS, Windows y Mac OS, permitiendo utilizar la aplicación como si la tuviésemos instalada en nuestro dispositivo. La imagen que aparecería en nuestro listado de aplicaciones es uno de estos dos logos. Hay 2 imágenes porque dependiendo del tamaño y resolución de la pantalla del dispositivo utilizará una imagen u otra.&lt;/p&gt;

&lt;p&gt;El siguiente archivo es el &lt;strong&gt;manifest.json&lt;/strong&gt;, que es un archivo que aporta información al navegador sobre el nombre de la aplicación, los iconos que debe utilizar en función del tamaño de pantalla y también el color principal y secundario de la app, etc. &lt;/p&gt;

&lt;p&gt;Por último tenemos el archivo &lt;strong&gt;robots.txt&lt;/strong&gt; que sirve para que una vez que la aplicación está desplegada en un servidor, los buscadores como Google puedan indexar la aplicación para que aparezca en los resultados de la búsqueda. Sin este archivo nunca aparecería tu aplicación en Google a no ser que escribas toda su URL. &lt;/p&gt;

&lt;h2&gt;
  
  
  Archivos en la raíz del proyecto
&lt;/h2&gt;

&lt;p&gt;A continuación voy a explicar los archivos que están en la raíz del proyecto.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkk3xabant3xkklyhdg0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkk3xabant3xkklyhdg0.png" alt="Image description" width="403" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;La mayoría de las aplicaciones profesionales se suben a algún repositorio de &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;git&lt;/a&gt;, como por ejemplo &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;Github&lt;/a&gt; o &lt;a href="https://about.gitlab.com/" rel="noopener noreferrer"&gt;Gitlab&lt;/a&gt;. Sin embargo hay archivos que no es aconsejable subir a los repositorios porque contienen tokens de seguridad, archivos o directorios autogenerados, como el &lt;strong&gt;node_modules&lt;/strong&gt; o la carpeta &lt;strong&gt;build&lt;/strong&gt; o &lt;strong&gt;dist&lt;/strong&gt; donde se almacena el código del proyecto para producción etc. La forma de incluir excepciones sobre los archivos y carpetas que se van a subir al repositorio de git se realizan en el archivo &lt;strong&gt;.gitignore&lt;/strong&gt;. Es este archivo se pueden incluir carpetas enteras, extensiones de archivos, etc. Todo lo que se incluya en este directorio será ignorado al realizar una subida al repositorio. &lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;package.json&lt;/strong&gt; es un archivo muy importante en todos los proyectos hechos en Javascript, ya que define el nombre del proyecto, el numero de versión, define las dependencias y dependencias de desarrollo, y también los scripts disponibles. Por ejemplo el script para arrancar el proyecto npm start, está definido en este archivo, así como también el script para hacer el build de producción. &lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;package-lock.json&lt;/strong&gt; sirve para guardar un registro de la ultima versión de todas las dependencias de tu proyecto, de forma que la próxima vez que instales dependencias en un proyecto se utilicen las mismas que anteriormente te funcionaron. Esto evita que la aplicación deje de funcionar porque una dependencia se ha actualizado y entra en conflicto en la nueva versión con alguna otra dependencia de tu proyecto. Si no existiese este archivo no tendríamos forma de instalar siempre las mismas versiones de nuestras dependencias en un proyecto y se producirían muchos conflictos entre dependencias.&lt;/p&gt;

&lt;p&gt;Por último tenemos el archivo &lt;strong&gt;README.md&lt;/strong&gt; que sirve para &lt;strong&gt;documentar tu proyecto&lt;/strong&gt;, informar a posibles usuarios como arrancar el proyecto, hacer build de producción y en definitiva exponer cualquier información relevante sobre el proyecto. El archivo &lt;strong&gt;README.md&lt;/strong&gt; es el archivo que se muestra por defecto cuando accedes a un repositorio de git, y también es el archivo que se muestra cuando se publica una librería a npm o cualquier gestor de paquetes de npm personalizado.&lt;/p&gt;

&lt;h2&gt;
  
  
  Directorio src
&lt;/h2&gt;

&lt;p&gt;El directorio &lt;strong&gt;src&lt;/strong&gt; es donde se encuentra &lt;strong&gt;el código fuente&lt;/strong&gt; de la aplicación, y por tanto es directorio donde se pasa la mayor parte del tiempo programando.&lt;br&gt;
Cuando se crea un proyecto con Create React App se genera un proyecto de muestra con unos archivos que en la mayoría de los casos se borrarán para empezar a construir el proyecto con los archivos y carpetas que necesites.  Sin embargo para poder borrar todo su contenido &lt;strong&gt;es importante conocer que hace cada archivo&lt;/strong&gt; para poder sustituirlo por el que te interese en cada caso. &lt;br&gt;
A continuación voy a explicarte uno a uno para que sirven los archivos que hay dentro de la carpeta &lt;strong&gt;src&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnwnojaxr4wxc0kwxwce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnwnojaxr4wxc0kwxwce.png" alt="Image description" width="400" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;El primer archivo es el &lt;strong&gt;App.css&lt;/strong&gt;, dentro de este archivo se encuentran los estilos CSS del componente principal &lt;strong&gt;App.js&lt;/strong&gt; . En un proyecto real, lo más recomendable es tener múltiples archivos CSS, posiblemente uno por cada componente.&lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;App.js&lt;/strong&gt; es uno de los archivos más importantes de la aplicación, puesto que &lt;strong&gt;es el primer componente que cargará React&lt;/strong&gt; y por lo tanto es el componente que contiene toda tu aplicación de react. Esto implica que cuando vayas creando nuevos componentes en tus proyectos, todos acabaran dentro del componente &lt;strong&gt;App.js&lt;/strong&gt; de una forma u otra.  &lt;/p&gt;

&lt;p&gt;En todas las aplicaciones profesionales se escriben (o deberían escribir ) &lt;strong&gt;test automáticos&lt;/strong&gt; para validar que la aplicación está libre de errores (bugs) y estar seguro y confiado que no vas a subir código con errores en un entorno de producción. Por este motivo Create React App genera el archivo &lt;strong&gt;App.test.js&lt;/strong&gt;, que es un archivo donde se genera un test de muestra para la aplicación. Al igual que con los archivos CSS, en un proyecto real, habrá más de un archivo de test, posiblemente uno por cada componente. &lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;index.css&lt;/strong&gt; recoge los &lt;strong&gt;estilos generales&lt;/strong&gt; de la aplicación. En el &lt;strong&gt;App.css&lt;/strong&gt; solo se encuentran los estilos del componente &lt;strong&gt;App.js&lt;/strong&gt;, pero si se quisieran tener estilos compartidos a lo largo de toda la aplicación, una manera de compartirlos seria mediante el &lt;strong&gt;index.css&lt;/strong&gt;, ya que los estilos que se incluyan aquí dentro se compartirán en toda la aplicación. &lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;index.js&lt;/strong&gt; es otro archivo de vital importancia, puesto que es el punto de entrada a la aplicación React, es decir que &lt;strong&gt;es el primer archivo que se va a cargar&lt;/strong&gt;, y a partir de este, se cargarán el resto de los archivos de la carpeta src. Dentro del &lt;strong&gt;index.js&lt;/strong&gt; se carga el componente &lt;strong&gt;App.js&lt;/strong&gt; y se le dice a React en que elemento del html de la aplicación lo tiene que pintar.  Este es por lo tanto un archivo que siempre tiene que estar en todas nuestras aplicaciones de react. En futuros artículos explicaré en más profundidad como funciona este archivo. &lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;logo.svg&lt;/strong&gt; se utiliza dentro del &lt;strong&gt;App.js&lt;/strong&gt; para pintar el &lt;strong&gt;logo de react&lt;/strong&gt;. Una vez modifiques o elimines el componente App.js puedes &lt;strong&gt;eliminar sin miedo&lt;/strong&gt; este archivo porque no tiene ninguna otra función.&lt;/p&gt;

&lt;p&gt;El archivo &lt;strong&gt;reportWebVitals.js&lt;/strong&gt; se llama desde el &lt;strong&gt;index.js&lt;/strong&gt; y sirve para &lt;strong&gt;medir el performance&lt;/strong&gt; de la aplicación. No es imprescindible, pero es recomendable tenerlo. &lt;/p&gt;

&lt;p&gt;Por ultimo el archivo &lt;strong&gt;setupTest.js&lt;/strong&gt; sirve para importar la librería de testing por defecto de Javascript. &lt;/p&gt;

&lt;p&gt;Como se ha visto en este articulo, Create React App genera muchos archivos y carpetas por nosotros, y nos da un proyecto listo para que podamos empezar a construir nuestra propia aplicación de React. En el próximo articulo explicaré como a partir de un proyecto hecho con Create React App podemos empezar a construir nuestro proyecto de React. &lt;/p&gt;

&lt;p&gt;¿Os ha quedado alguna duda respecto a algún archivo? ¿Tenéis alguna duda o sugerencia?&lt;br&gt;
Si es así dejadme un comentario abajo y lo responderé.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Cómo crear tu primer proyecto de React</title>
      <dc:creator>Adrian Guillen</dc:creator>
      <pubDate>Mon, 25 Oct 2021 06:31:53 +0000</pubDate>
      <link>https://forem.com/adriangube/como-crear-tu-primer-proyecto-de-react-113h</link>
      <guid>https://forem.com/adriangube/como-crear-tu-primer-proyecto-de-react-113h</guid>
      <description>&lt;p&gt;Una de las primeras dudas que surgen cuando empezamos a trabajar con una librería o framework para el frontend es sin duda &lt;strong&gt;cómo empezar un proyecto nuevo&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Lo primero que debemos tener en cuenta es que para poder trabajar con React o cualquier otro framework como Angular, Vue, Svelte, etc primero necesitaremos tener &lt;strong&gt;nuestro equipo configurado con &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node y npm&lt;/a&gt;&lt;/strong&gt;. Una vez tenemos el entorno listo, ahora sí, ya estamos listos para empezar.&lt;/p&gt;

&lt;p&gt;Para crear un nuevo proyecto de React, tenemos 3 alternativas:&lt;/p&gt;

&lt;p&gt;1 - Crear un proyecto desde 0. &lt;br&gt;
2 – Utilizar un proyecto existente como plantilla. &lt;br&gt;
3- Utilizar alguna herramienta que genere el proyecto por ti. &lt;/p&gt;
&lt;h2&gt;
  
  
  1 Crear un proyecto desde 0
&lt;/h2&gt;

&lt;p&gt;La primera opción es quizá la &lt;strong&gt;más básica y costosa&lt;/strong&gt;, ya que si creas un proyecto manualmente desde cero, deberás &lt;strong&gt;crear todos los directorios y archivos que necesites&lt;/strong&gt;, pero también deberás configurar las diferentes herramientas necesarias para compilar el código, realizar test, hacer linting del código y generar el código para producción entre otras cosas. &lt;br&gt;
No te preocupes si alguno de los términos que he utilizado más arriba no te suenan, tengo pensado explicar todos estos conceptos en post sucesivos. &lt;/p&gt;

&lt;p&gt;En resumen, crear un proyecto desde cero, te permite &lt;strong&gt;personalizar&lt;/strong&gt; mejor que incluyes y que no incluyes en el proyecto, pero &lt;strong&gt;requiere mucho trabajo y conocimientos&lt;/strong&gt; previos. Yo recomendaría esta primera opción para gente con experiencia y/o que quiera aprender a configurar desde cero un proyecto.&lt;/p&gt;
&lt;h2&gt;
  
  
  2 Utilizar un proyecto existente como plantilla
&lt;/h2&gt;

&lt;p&gt;La segunda opción es quizá una solución más sencilla que la anterior, ya que en Github existen &lt;strong&gt;repositorios de plantillas&lt;/strong&gt; que explican paso a paso como utilizar la plantilla. Lo más habitual suele ser que debas &lt;strong&gt;clonar el repositorio&lt;/strong&gt;, para lo cual solo necesitas tener una cuenta gratuita de Github.  Una vez clonado el repositorio deberás seguir los pasos que aparezcan en el Readme y &lt;strong&gt;en apenas 5 minutos&lt;/strong&gt; ya tendrás un proyecto de React arrancado y funcionando.&lt;/p&gt;

&lt;p&gt;Una de las plantillas más utilizadas con este propósito es &lt;a href="https://github.com/react-boilerplate/react-boilerplate" rel="noopener noreferrer"&gt;React-boilerplate&lt;/a&gt; ,ya que es una plantilla de React para aplicaciones de uso general. Si buscas una plantilla más especifica existen otros templates de proyectos React para casi cualquier tipo de aplicación. &lt;/p&gt;

&lt;p&gt;En conclusión, es una opción mucho más sencilla de crear un proyecto React, ya que en apenas 5 minutos se tiene un proyecto perfectamente configurado y funcionando sobre el que empezar a trabajar, aunque &lt;strong&gt;no tienes tanto control&lt;/strong&gt; sobre el tipo de librerías y herramientas incorpora la plantilla.&lt;/p&gt;
&lt;h2&gt;
  
  
  3 Utilizar alguna herramienta que genere el proyecto por ti
&lt;/h2&gt;

&lt;p&gt;Las dos opciones mencionadas están muy bien, pero ¿no seria mejor si pudieses utilizar alguna herramienta a la que le digas algo del estilo “genérame un proyecto React, perfectamente configurado, y que tenga X e Y configuraciones” y &lt;strong&gt;automáticamente&lt;/strong&gt; haga todo el trabajo por ti? &lt;/p&gt;

&lt;p&gt;Pues exactamente eso es &lt;a href="https://create-react-app.dev/" rel="noopener noreferrer"&gt;Create React App&lt;/a&gt; , es un cliente (CLI a partir de ahora), que te permite &lt;strong&gt;crear un proyecto de React customizado&lt;/strong&gt;, pudiendo elegir entre diferentes opciones de configuración para que elijas la que se adapte mejor al proyecto que deseas empezar. Esta opción es sin duda &lt;strong&gt;la favorita de la mayor parte de la comunidad&lt;/strong&gt;, porque genera de forma sencilla el proyecto, y tiene detrás una gran comunidad que actualiza el CLI constantemente por lo que siempre que quieras crear un proyecto nuevo de React, estará actualizado a la ultima versión de la librería.&lt;/p&gt;

&lt;p&gt;¿Y como se utiliza Create React App?  Pues es muy sencillo, tan solo necesitas tener &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node&lt;/a&gt;  y npm instalados en tu maquina, abrir una terminal y lanzar los siguientes comandos, &lt;strong&gt;uno a uno&lt;/strong&gt;, en el directorio donde quieres crear el proyecto:&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;npx&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;
&lt;span class="nx"&gt;cd&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;
&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;El primer comando crea el proyecto de React con el nombre “my-app” (deberías cambiar el “my-app” por el nombre de tu proyecto),  el segundo comando sirve para cambiar del directorio actual al directorio del proyecto, y por ultimo, el tercer comando arranca el proyecto de React para que puedas empezar a trabajar con él y ver los resultados en tu navegador. &lt;/p&gt;

&lt;p&gt;Hay que tener en cuenta que los 3 comandos anteriores están pensados para dispositivos MAC OS o Linux, para Windows el segundo comando cambia un poco:&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;npx&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;
&lt;span class="nx"&gt;dir&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;
&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;En conclusión, Create React App es sin duda &lt;strong&gt;la mejor herramienta&lt;/strong&gt; para crear tu primer proyecto de React por la simplicidad que tiene y por la posibilidad de customizar la configuración de tu proyecto. &lt;/p&gt;

&lt;p&gt;En próximos artículos explicaré en profundidad la estructura de archivos y carpetas que genera Create React App, y como empezar a desarrollar a partir de ellas. &lt;/p&gt;

&lt;p&gt;Por último preguntar ¿que utilizáis para crear nuevos proyectos de React?  ¿Utilizáis alguna herramienta que no haya mencionado? Dejadme vuestras opiniones en los comentarios.&lt;/p&gt;

</description>
      <category>react</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
