<?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: Cristopher López Santana</title>
    <description>The latest articles on Forem by Cristopher López Santana (@ramclen).</description>
    <link>https://forem.com/ramclen</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%2F329482%2Fc27d849b-9c3b-4e22-bd2c-937b9e722a28.jpeg</url>
      <title>Forem: Cristopher López Santana</title>
      <link>https://forem.com/ramclen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ramclen"/>
    <language>en</language>
    <item>
      <title>Naming Matters: The Importance of Good Naming in Clean Code</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Mon, 03 Apr 2023 06:51:36 +0000</pubDate>
      <link>https://forem.com/ramclen/naming-matters-the-importance-of-good-naming-in-clean-code-73j</link>
      <guid>https://forem.com/ramclen/naming-matters-the-importance-of-good-naming-in-clean-code-73j</guid>
      <description>&lt;h2&gt;
  
  
  The Importance of Good Naming in Clean Code
&lt;/h2&gt;

&lt;p&gt;In software engineering, one of the most important aspects of writing clean code is good naming. Names matter because they help developers communicate their intent and reduce confusion, ultimately leading to better code quality and a more efficient development process.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Impact of Bad Naming
&lt;/h2&gt;

&lt;p&gt;Poor naming can create ambiguity and confusion, leading to wasted time and effort as developers struggle to understand what the code is doing. Just as in verbal communication, being clear and concise in code is essential to avoid misunderstandings and ensure that everyone is on the same page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Guidelines for Good Naming
&lt;/h2&gt;

&lt;p&gt;To create meaningful and understandable names for your code, it's important to follow some basic guidelines based on the type of element you are naming:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables: Use nouns or short phrases with adjectives, such as &lt;code&gt;userData&lt;/code&gt; or &lt;code&gt;isValid&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Functions/Methods: Use verbs or short phrases with adjectives, such as &lt;code&gt;sendData&lt;/code&gt; or &lt;code&gt;inputIsValid&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Classes: Use nouns or short phrases with nouns, such as &lt;code&gt;User&lt;/code&gt; or &lt;code&gt;RequestBody&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Casing Conventions
&lt;/h2&gt;

&lt;p&gt;Different programming languages and frameworks have different conventions for naming conventions, such as snake_case, camelCase, PascalCase, and Kebab-Case. It's important to choose a convention and stick to it for consistency across your codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Naming Variables
&lt;/h2&gt;

&lt;p&gt;When naming constants and properties, it's important to choose names that are descriptive and convey the type and purpose of the data being stored. &lt;/p&gt;

&lt;p&gt;Ask yourself questions like "What type of data is storing?" and "What exactly is storing?" to find good names. For example, a constant representing a customer might be named &lt;code&gt;customer&lt;/code&gt;, &lt;code&gt;firstName&lt;/code&gt;, &lt;code&gt;authenticatedUser&lt;/code&gt;, &lt;code&gt;sqlDatabase&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Using short phrases with adjectives can help make the purpose of the boolean variable more evident. Examples of well-named boolean variables include &lt;code&gt;isValid&lt;/code&gt;, &lt;code&gt;didAuthenticate&lt;/code&gt;, and &lt;code&gt;emailExists&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Naming Functions and Methods
&lt;/h2&gt;

&lt;p&gt;A well-named function or method can convey its purpose and usage, making it easier for other developers to understand how to use it. Here are some tips for naming functions and methods in a clean and consistent manner:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Verb Usage: Functions and methods are typically named using verbs, as they describe actions. Choose a verb that accurately describes the function's purpose, such as "calculate", "generate", "validate", or "convert". Using a consistent verb tense throughout the codebase can also help maintain consistency and clarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Descriptive Names: A function or method name should be descriptive of its purpose, making it easy for other developers to understand what the function does. Avoid using generic names like "doSomething" or "processData" that do not convey specific meaning. Instead, use descriptive names like "calculateTotalPrice" or "validateEmailAddress".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be Concise: While it's important to be descriptive, functions and methods should also be named in a concise manner. Avoid excessively long names or including unnecessary information. Use the shortest name possible that accurately conveys the function's purpose.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Naming Classes
&lt;/h2&gt;

&lt;p&gt;To improve the readability and maintainability of code, it's important to use good naming conventions. This is especially important for classes, as they are the building blocks of an application. Good class names should be clear, concise, and reflect the responsibilities of the class. &lt;/p&gt;

&lt;p&gt;The name of a class should be a noun or noun phrase that describes the abstraction that the class represents Avoid abbreviations, acronyms or obscure words, as this can make the code harder to read and understand.&lt;/p&gt;

&lt;p&gt;The class should have a single responsibility and its name should accurately reflect that. Verbs should be avoided in class names, and there are different naming patterns that can be used, but consistency is key. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple Noun: This pattern uses a single noun to describe the class, for example, "Customer" or "Order".&lt;/li&gt;
&lt;li&gt;Abstract Noun: This pattern uses an abstract noun to describe the class, for example, "Account" or "Transaction".&lt;/li&gt;
&lt;li&gt;Adjective Noun: This pattern uses an adjective to describe the class, followed by a noun that describes the object or concept, for example, "ActiveUser" or "ExpiredLicense".&lt;/li&gt;
&lt;li&gt;Compound Words: This pattern uses compound words to describe the class, for example, "SalesReport" or "UserSettings".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common errors and pitfalls
&lt;/h2&gt;

&lt;p&gt;Even when following the best practices of clean code, there are still common pitfalls and errors that can occur. Here are some of the most frequent ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Avoid being too specific or redundant with your naming. For example, using "userList" instead of "userMap" can lead to confusion and waste time for the team. Similarly, using "allUsers" when you only need a subset of users can also create confusion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use names that are distinct enough to avoid confusion. Avoid using names that are too similar, like "getDailyData" and "getDayData", as it can be hard to tell which method to use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be consistent with your naming conventions. Use the same terms across your classes to make it easier to read and maintain your code. For example, if you use "get"/"fetch"/"retrieve" in one class, use it consistently across all classes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these guidelines, you can improve the readability, maintainability, and overall quality of your code, making it easier for you and your team to understand and work with.&lt;/p&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>cleancode</category>
      <category>bestpractices</category>
      <category>programming</category>
      <category>softwareengineer</category>
    </item>
    <item>
      <title>Starting with typescript</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Tue, 08 Mar 2022 10:03:28 +0000</pubDate>
      <link>https://forem.com/ramclen/starting-with-typescritp-2aj5</link>
      <guid>https://forem.com/ramclen/starting-with-typescritp-2aj5</guid>
      <description>&lt;p&gt;I am going share with you few things to try learn easy and fast how to use typescript in your projects. This is only an abstract about how to use typescript and basics things if you need more information about I recommend you to go to the official &lt;a href="https://www.typescriptlang.org/docs/handbook/intro.html"&gt;handbook&lt;/a&gt;. There you will find more and very good explain concepts and examples.&lt;/p&gt;

&lt;p&gt;But lets start.&lt;/p&gt;

&lt;h2&gt;
  
  
  The primitives
&lt;/h2&gt;

&lt;p&gt;So the primitives are the simplest units of data that Typescript give us to build the rest of our objects. Here the most used ones&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;boolean: it could contains True or False value.&lt;/li&gt;
&lt;li&gt;number: Well not too much to explain about this, a number.&lt;/li&gt;
&lt;li&gt;string: A concatenation of characters together, humans usually call it text.&lt;/li&gt;
&lt;li&gt;Array: You could store multiple values of same type by order.&lt;/li&gt;
&lt;li&gt;Enum: A friendly set of values.&lt;/li&gt;
&lt;li&gt;Any: If you hate typescript and love JS you will love this type (bad pattern alert). This type could be any of the rest of types&lt;/li&gt;
&lt;li&gt;Void: It means actually that, not really useful because only can store &lt;code&gt;undefined&lt;/code&gt; and &lt;code&gt;null&lt;/code&gt;. Used mostly as a return type on function that return nothing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;here an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Basic variable types&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isBoolean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&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="c1"&gt;// This is how you declare an array of numbers&lt;/span&gt;

&lt;span class="c1"&gt;// Enums&lt;/span&gt;
&lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;GREETING&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;HELLO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;GOOD_MORNING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Good Morning World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Function and void type&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;sayHi&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;GREETING&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HELLO&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Strange Types
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you just want to have a quick look to Typescript jump to next section.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;"Do we really need those types?" That the question could come to your mind when you see next types for first time, but in some scenarios are needed. Probably you will not use this types but if you find yourself in any of this scenario you will know what to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Undefined and Null
&lt;/h3&gt;

&lt;p&gt;It only can be their own value ( &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt; ). It looks are not pretty useful by their own, like void, but if you want to use &lt;code&gt;--strictNullChecks&lt;/code&gt; ( &lt;a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#--strictnullchecks"&gt;more info&lt;/a&gt; ) it would help you to specify when a variable or type could be undefined or null.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unknown:
&lt;/h3&gt;

&lt;p&gt;It exactly means that, a type that is unknown. When you receive a value from a function that you do not know what type is, we use the unknown type.&lt;/p&gt;

&lt;p&gt;The main difference with any is that any let you use random attributes that the object could have. Using any property with unknown will throw a error.&lt;/p&gt;

&lt;p&gt;if you want to know more about it &lt;a href="https://mariusschulz.com/blog/the-unknown-type-in-typescript"&gt;here&lt;/a&gt; is a deeper explanation and distinction from the any type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Never:
&lt;/h3&gt;

&lt;p&gt;It is a type for something that never happen or should not exists. it is used in functions that returns exceptions or one that never returns like a infinity loop.&lt;/p&gt;

&lt;p&gt;Here few examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;buildError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;infiniteLoop&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Difference between string/number/boolean/object and String/Number/Boolean/Object
&lt;/h3&gt;

&lt;p&gt;If you are here just trying to learn and do not care much about what is what. As a rule of thumb you should try to avoid using uppercase ones.&lt;/p&gt;

&lt;p&gt;If you are like me, you will probably want to know a bit more, so it is an easy explanation to have both ones. Typescript is a language that has been built over Javascript so it needs compatibility with types or objects that already exists.&lt;/p&gt;

&lt;p&gt;You probably remember that we have things like this in Javascript:&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;var&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;My new string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;nmbr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So thats it is actually what represent that upper case types on Typescript. It is usually a bad pattern use them to create new types on Typescript. So you should avoid them as much as possible.&lt;/p&gt;

&lt;p&gt;Go &lt;a href="https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#number-string-boolean-symbol-and-object"&gt;here&lt;/a&gt; if you want to know more about this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classes, interfaces, types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Classes:
So classes are the same one that was introduced in javascript ES6. The good point of TS is that let you create your own types of objects. Here a basic example
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Glump&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Interface is like the structure of a class, it do not implement how things work, only define the API that a objects or class are going to have. Here is an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Animal&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&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;here an example of a class implementing the interface Animal and a function that returns that interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Human&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;Animal&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gluh&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Bird&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;Animal&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Parrot&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;glip&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bornAnimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;Animal&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BIRD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HUMAN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So Interfaces let us use objects without knowing exactly how it is implemented or his entire API, only understanding the part that is exposed by the interface.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Types: It is really similar to an interface, they are used to define the structure of an object but it has some difference, for now lets show how to use it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Animal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&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 you want to know more about differences about interfaces and types &lt;a href="https://medium.com/@martin_hotell/interface-vs-type-alias-in-typescript-2-7-2a8f1777af4c"&gt;here is a good post about it&lt;/a&gt;. To keep it simple lets say that its usually used to define literal object and for more compact definitions, for example to define states and props in React with Typescript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modifiers : private, public, protected
&lt;/h2&gt;

&lt;p&gt;The modifiers define how a property of an object can be access. So lets show with examples an short explanations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;public: It can be used by everyone, it is part of the public API of an object.&lt;/li&gt;
&lt;li&gt;protected: Only classes that extend that object can use this property.&lt;/li&gt;
&lt;li&gt;private: It is only usable inside the object, not accessible from outside of object not even from subclasses.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AndroidPhone&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;phoneNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nx"&gt;uiCustomization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;osCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;GreatAndroidFirmwareCode&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;XiaomiPhone&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;AndroidPhone&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mi A1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;uiCustomization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MIUI (Name of system interface of Xiomi)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;osCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;DoingGreatReWriteOfCode&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// this is not allowed&lt;/span&gt;

  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;phoneNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phoneNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;phoneNumber&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;johnPhone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AndroidPhone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;XiaomiPhone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3082&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;johnPhone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phoneNumber&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;johnPhone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;uiCustomization&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// this is not allowed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Found a typo?
&lt;/h2&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>developers</category>
    </item>
    <item>
      <title>React - JSX and Lifecycle</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Sun, 19 Jul 2020 11:29:16 +0000</pubDate>
      <link>https://forem.com/ramclen/react-jsx-and-lifecycle-1b84</link>
      <guid>https://forem.com/ramclen/react-jsx-and-lifecycle-1b84</guid>
      <description>&lt;p&gt;I would like to talk about typical things coming with ReactJS that you could miss when learning React. If you are in the process, this is going to help you to understand better JSX and Lifecycle. So let's start!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is JSX?
&lt;/h2&gt;

&lt;p&gt;JSX is the language that React offers to embed UI logic and render interfaces. JSX is really similar to HTML but is not the same. It runs inside of Javascript, for that reason I am going to give few tips to boost your knowledge about JSX and differentiate to html:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Properties and attributes names use camelCase instead of kebab-case found on HTML

&lt;ul&gt;
&lt;li&gt;Example: tab-index =&amp;gt; tabIndex&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;It Changes reserved words in js for a substitute

&lt;ul&gt;
&lt;li&gt;Example: class =&amp;gt; className&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;It always need a closed tag and it could be one line tag

&lt;ul&gt;
&lt;li&gt;example: &lt;code&gt;&amp;lt;input &amp;gt;&lt;/code&gt; =&amp;gt; &lt;code&gt;&amp;lt;input /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;example: &lt;code&gt;&amp;lt;div&amp;gt; &amp;lt;/div&amp;gt;&lt;/code&gt; =&amp;gt; &lt;code&gt;&amp;lt;div /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Style is a Javascript object:

&lt;ul&gt;
&lt;li&gt;example: &lt;code&gt;&amp;lt;div style:{ {backgroundColor: 'blue'} }&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Do not think that JSX is transformed to HTML directly, JSX is syntactic sugar for react element creation. This React Element is whose deal, following your instruction, to transform that into HTML. &lt;a href="https://reactjs.org/docs/jsx-in-depth.html" rel="noopener noreferrer"&gt;Here&lt;/a&gt; you will find more info about this topic in React official documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why should we use it?
&lt;/h2&gt;

&lt;p&gt;There are a lot of reasons why you should use JSX, the first one and more important is because you are using React and you probably do not want to be creating elements like in the link from React documentation shown in the previous section.&lt;/p&gt;

&lt;p&gt;But, if this is a point where you are thinking about using React or not let me try to convince you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You will have more typo errors (helping you to find errors on UI)&lt;/li&gt;
&lt;li&gt;It will give you the opportunity to create complex UI interfaces with a lot less code and less headaches&lt;/li&gt;
&lt;li&gt;It is secure, JSX prevent injection attack because React DOM escapes any values embedded in JSX before rendering them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you are going to create an application/web page these points are really helpful. It reduces complexity and improves your productivity and the security of your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Lifecycle on React?
&lt;/h2&gt;

&lt;p&gt;Lifecycles are the different stages that our component pass during his life in the DOM. The life of our component pass through three main phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mounting&lt;/li&gt;
&lt;li&gt;Updating&lt;/li&gt;
&lt;li&gt;Unmounting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When our component is passing a specific phase it will call the correct function. In those functions, we could tell to the components to behave in a specific way (Download data, prepare the state, release resources...)&lt;/p&gt;

&lt;h2&gt;
  
  
  Cool, but what are those methods?
&lt;/h2&gt;

&lt;p&gt;Ok, to keep it simple let me show you the more used methods&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Building&lt;/strong&gt; our component before showed in the application.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;constructor()&lt;/code&gt; Yep, famous constructor method, that method is to focus on state and properties set up. The reason behind this is that we want to show our component as soon as possible. Also, this is actually the only place where you are going to be able to assign &lt;code&gt;this.state&lt;/code&gt;. Another thing to have in mind is that you must always call &lt;code&gt;super()&lt;/code&gt; to send properties to React Component parent class.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Showing&lt;/strong&gt; or render our component.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt; here is where we are going to focus on tell to react how our component is going to looks like, for that purpose we use JSX.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Component &lt;strong&gt;is Mounted&lt;/strong&gt; in the DOM.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentDidMount()&lt;/code&gt; This is a perfect method to execute code that require more processing (for example running requests) and it is going to be needed only at the beginning of the component lifecycle.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Component &lt;strong&gt;is Updated&lt;/strong&gt;. It means that the state or props has changed.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentDidUpdate(previousProps, previousState)&lt;/code&gt; So this method is used when we are concern about how our component is evolving and we want to react differently depending of how our state or props are changing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Unmounting&lt;/strong&gt; our component. This happens when our component is removed from the DOM.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentWillUnmount():&lt;/code&gt; this method is useful when we want to clear or free some resources.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Here is a graph to understand better the order and in which phase is every method:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Framclen%2Fdocumenting-dev%2Fmaster%2Fblog-posts%2FDeeper-knowledge-about-react-jsx-and-lifecycle%2Fassets%2Flifecycle.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%2Fraw.githubusercontent.com%2Framclen%2Fdocumenting-dev%2Fmaster%2Fblog-posts%2FDeeper-knowledge-about-react-jsx-and-lifecycle%2Fassets%2Flifecycle.png" alt="lifecycle graph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev" rel="noopener noreferrer"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Learning about git!</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Mon, 11 May 2020 21:19:54 +0000</pubDate>
      <link>https://forem.com/ramclen/learning-about-git-68d</link>
      <guid>https://forem.com/ramclen/learning-about-git-68d</guid>
      <description>&lt;p&gt;In this post, I will try to give you some concepts to help you to start learning about git. Git is known by almost all programmers or even all of them. It manages all the changes made to your files and projects in an easy way.&lt;/p&gt;

&lt;p&gt;I love to see git like a save state on a video game, if I fail in next boss I will restart from my previous state and I will give another try with a different strategy.&lt;/p&gt;

&lt;p&gt;So let us begin!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is git?
&lt;/h2&gt;

&lt;p&gt;Git is a Version Control System. It means that git is going to help you to store and manage all the changes that you make to your file or project through the time. To do this, git works with repositories, and you have to commit those changes. Git runs on your local machine so you don’t need to have an internet connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to start using git
&lt;/h2&gt;

&lt;p&gt;First of all, you need to install Git on your local computer. You can download it from &lt;a href="https://git-scm.com/"&gt;its website.&lt;/a&gt;&lt;br&gt;
When you have already installed Git, you have to get into your Project folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;cd &lt;/span&gt;projectFolder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;or you can create an empty directory for your project using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;mkdir &lt;/span&gt;projectFolder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and then, run the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This command will initialize a Git repository in this directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a repository?
&lt;/h2&gt;

&lt;p&gt;A repository contains all the history of changes. It contains all the files managed by git. There are three principal local states related to files managed by git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working directory&lt;/li&gt;
&lt;li&gt;Staging area&lt;/li&gt;
&lt;li&gt;Git repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Working directory is the directory in our computer which holds all our application files and folders.&lt;br&gt;
Git repository contains all the changes that we save in git, that are finalized and uploaded by a commit.&lt;br&gt;
The staging area is in between, is a holding area, a kind of queue when we are waiting for the changes for the next commit.&lt;/p&gt;
&lt;h2&gt;
  
  
  So, how can I add the changes that I’ve made to the staging area?
&lt;/h2&gt;

&lt;p&gt;Simply, using the next command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git add myFile.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can use this command followed by the name of the file that you want to add to this area or you can use a folder path that allows us to add all the files at the same time. This is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We haven't committed our changes yet. In this area, you can move the files in and out without modify the git repository and review all the changes you have made before committing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Committing changes
&lt;/h2&gt;

&lt;p&gt;Once we have our files in the staging area we can save them in our git repo. We'll have to use another command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When we make a commit, we are going to save the changes in all files that were in the staging area.&lt;br&gt;
Commit messages are messages that we add to our commits to describe which kind of changes you have done. These messages have to be simples.&lt;/p&gt;
&lt;h2&gt;
  
  
  How could I know the state of my repository?
&lt;/h2&gt;

&lt;p&gt;Using the next command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git status
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Shows the status in both the working directory and staging area. It helps us to see in which state are the files you have modified so we can handle them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can I see all the commits I have made?
&lt;/h2&gt;

&lt;p&gt;Yes! There is a command that outputs the history of changes. We have to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This returns to us very important information about our commit history, like the ID of the commits, the author, the date and where is the head.&lt;br&gt;
It maybe looks a little confusing if you have multiples commits, but there are a few options that you can use to have a better vision of this log. My favorite one is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  git log &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--decorate&lt;/span&gt; &lt;span class="nt"&gt;--oneline&lt;/span&gt; &lt;span class="nt"&gt;--graph&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This one, in particular, draws a graphical representation in one line and it's very visual. Try it yourself!&lt;/p&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What is React and why is it useful?</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Tue, 14 Apr 2020 14:23:46 +0000</pubDate>
      <link>https://forem.com/ramclen/why-react-is-useful-2faj</link>
      <guid>https://forem.com/ramclen/why-react-is-useful-2faj</guid>
      <description>&lt;h2&gt;
  
  
  Here we go again, what is react?
&lt;/h2&gt;

&lt;p&gt;React is a powerful javascript library that helps us to create web applications. React focuses on how the appearance looks like and react to user interactions and creations of, what we call &lt;strong&gt;components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The library was released on 2013 but it has been under development since 2011 by Jordan Walke a software engineer from Facebook.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are components in React?
&lt;/h2&gt;

&lt;p&gt;A Component is a concept that developers use to isolate a part of the UI and encapsulate similar features to make easy to reuse and maintain. Components must be independent of the rest of the application.&lt;/p&gt;

&lt;p&gt;At the end, a component is a piece of HTML and JS code that show and interact with the user. So a button is a component but you can also have a component that is a compilation of components. You can have components inside other components also, creating them one by one and bounding them together.&lt;/p&gt;

&lt;p&gt;So, for example, a button could be a component itself, but you can add this small component with a input and create a new component.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an application?
&lt;/h2&gt;

&lt;p&gt;An application is a software that is created to final users. Yes, I know, it sounds ambiguous but it is what we have. So your android/iOS applications are that, applications, pieces of software made with a great UI/UX to everyone know how to use it (well... the good ones).&lt;/p&gt;

&lt;p&gt;When we use React is to create Web Applications, applications are great because they run anywhere and it does not need to be store. Web applications have good points but also few bad ones. For example, they have reduced access to the operating system, performance issues, etc.&lt;/p&gt;

&lt;p&gt;But good news, React have React Native, it reduces this kind of problems and lets us create great applications for mobiles using the same brilliant library.&lt;/p&gt;

&lt;h2&gt;
  
  
  State and Lifecycle? What they are?
&lt;/h2&gt;

&lt;p&gt;State is a javascript object that contains the data relative to an object. We use them because we can update the state from a component to rerender it.&lt;/p&gt;

&lt;p&gt;We update the state object using the &lt;code&gt;setState()&lt;/code&gt; function. We have to initialize state when we create a component. React state is only valid in class based components.&lt;/p&gt;

&lt;p&gt;Every React based component has what we call lifecycle methods. It is like a series of events (or functions) that are going to be called automatically by React at certain points during this lifecycle.&lt;/p&gt;

&lt;p&gt;It has three phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Mounting: Puts elements into the DOM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;constructor()&lt;/code&gt;. This methods is called before anything else.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt; method it’s always required. Makes the content visible on the screen.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;componentDidMount()&lt;/code&gt;. It’s called after the components will shows up. Good place to do data loading.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Updating: A component is updated when the state or props is changed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentDidUpdate()&lt;/code&gt;: Even if you are on the updating phase, render will be call to show the content on screen when change is produced.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unmounting: Stop showing components on screen.&lt;br&gt;&lt;br&gt;
&lt;code&gt;componentWillUnmount():&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  You always complicate things a lot, why I need it?
&lt;/h2&gt;

&lt;p&gt;By using React, we can create Web applications with reusable components, and change data without reloading the page. So we can create large web applications easily.&lt;/p&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Redux</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Wed, 12 Feb 2020 17:55:43 +0000</pubDate>
      <link>https://forem.com/ramclen/understanding-redux-36fk</link>
      <guid>https://forem.com/ramclen/understanding-redux-36fk</guid>
      <description>&lt;p&gt;First, this post is not to learn redux, it is to clarify few key concepts. So its about resolving doubts more than trying to explain Redux. I would recommend &lt;a href="https://redux.js.org/basics"&gt;Redux documentation&lt;/a&gt; if you are trying to find a resource to start learning redux.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is redux?
&lt;/h2&gt;

&lt;p&gt;I will try to keep simple. Redux is a small library to store the central state and make it predictable. For that purpose it use functional programming paradigm concepts.&lt;/p&gt;

&lt;p&gt;It keeps control of how you manipulate the state giving you three basics concepts for it, &lt;code&gt;Actions&lt;/code&gt;, &lt;code&gt;Reducers&lt;/code&gt; and &lt;code&gt;Store&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Redux just let you follow a unidirectional data flow state modifications, and it starts by &lt;code&gt;Actions&lt;/code&gt;. &lt;code&gt;Actions&lt;/code&gt; send the data to the correct &lt;code&gt;Reducer&lt;/code&gt; and &lt;code&gt;Reducers&lt;/code&gt; modify the state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wait wait... actions? reducers? state?
&lt;/h2&gt;

&lt;p&gt;Ok, I will try to give you few keys to understand this concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://redux.js.org/basics/actions"&gt;Actions&lt;/a&gt; are basically the definition of the change that you are going to make in the state. They are the responsible to take and pass the information to the proper reducer. For that actions, return a plain javascript object. The only value needed by redux is &lt;code&gt;Type&lt;/code&gt;, the rest of them are up to you. Type is used by Redux to identify the correct reducer.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example of a plain object returned by an Action&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SET_USER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SET_USER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SET_USER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;id&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;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;BONUS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a good practice define our action types because they are going to be used around our application.&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://redux.js.org/basics/reducers"&gt;Reducers&lt;/a&gt;, here is where we said to redux how the state is going to be changed. Reducers receive the information obtained by actions and return the new state. Redux give us one restriction here and it is that Reducers have to be &lt;code&gt;Pure Functions&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://redux.js.org/basics/store"&gt;Store&lt;/a&gt; is the object that keep control over the state. So if you need, update the sate, listen changes, etc. the state is your guy. It is a singleton, that means that we only have one in our application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pu... Pure Functions?
&lt;/h2&gt;

&lt;p&gt;Pure functions is a term that comes from functional programming. This term means that a function should do not produce any external side effect (Change or read global values, make API calls, write or read files, etc).&lt;/p&gt;

&lt;p&gt;That means that pure functions are &lt;a href="https://en.wikipedia.org/wiki/Deterministic_system"&gt;deterministic&lt;/a&gt;. In other words, you can know the output from specific inputs. This is key when you want to keep something like your application state under control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ehm, What is functional programming?
&lt;/h2&gt;

&lt;p&gt;This may take more time to explain it, but I will give you few things to understand a bit what we are talking about.&lt;/p&gt;

&lt;p&gt;Functional programming is a paradigm that avoid changing state and mutable data. It create solutions treating the software as compound of mathematical functions (or pure functions).&lt;/p&gt;

&lt;p&gt;So if you compare with Object Oriented is probably really different. If you would like to know more about Functional Programming &lt;a href="https://medium.com/javascript-scene/master-the-javascript-interview-what-is-functional-programming-7f218c68b3a0"&gt;here&lt;/a&gt; is a place to start.&lt;/p&gt;

&lt;h2&gt;
  
  
  I feel its too much, Do we really need it?
&lt;/h2&gt;

&lt;p&gt;It depends...&lt;/p&gt;

&lt;p&gt;If you are creating a really small app the answer is no, but if you are creating a big application and you have a central changeable state this is probably the solution to your problems.&lt;/p&gt;

&lt;p&gt;Another thumb rule is giving by Dan Abramov:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;I would like to amend this: don't use Redux until you have problems with vanilla React.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So, basically, if you are reading about redux and it does not help with your headaches, it is probably because it is not the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  I do not like it, Do you have something better?
&lt;/h2&gt;

&lt;p&gt;I do not know if they are better, but I have few options that you could check. Probably depending of your needs you will find them more helpful in your situation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://mobx.js.org/README.html#getting-started"&gt;Mobx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/reflux/refluxjs"&gt;RefluxJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://relay.dev/"&gt;Relay&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Middleware on redux</title>
      <dc:creator>Cristopher López Santana</dc:creator>
      <pubDate>Sun, 09 Feb 2020 19:22:46 +0000</pubDate>
      <link>https://forem.com/ramclen/understanding-middlewares-on-redux-19l2</link>
      <guid>https://forem.com/ramclen/understanding-middlewares-on-redux-19l2</guid>
      <description>&lt;p&gt;If you are starting to learn Redux, middlewares could be a pain know what it is and why we need them... So I am going to try to give you few keys (and links) to help you in your learning process.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a middleware?
&lt;/h2&gt;

&lt;p&gt;A middleware is usually called "Software glue". It is usually a piece of software that it is in the middle of two softwares, and it makes easy the communication between them.&lt;/p&gt;

&lt;p&gt;A middleware become popular with the beginning of Operating systems architecture. It made easy the way that engineers get/set data to operating system.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://redux.js.org/advanced/middleware/"&gt;redux documentation&lt;/a&gt; says:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Provides a third-party extension point between dispatching an action, and the moment it reaches the reducer.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So it is basically a piece of code between actions and reducers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why we need them?
&lt;/h2&gt;

&lt;p&gt;Yes, I was thinking the same, why we have to complicate things that much? But hold on, it have good a reasons.&lt;/p&gt;

&lt;p&gt;Actually, It is technically possible do it without middlewares. But, as a rule of thumb is a bad idea and you could mess things.&lt;/p&gt;

&lt;p&gt;Redux try control access to state and reduce any problems. For that purpose they try to give you few guidelines. They usually are aimed to reduce complexity and organize everything by single responsibility. The things that clarify me this were:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;It made easy the process to create new kind of actions. The big thing here is we are going to probably send the dispatch to our new action. That have two disadvantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Made the method signature complex and a bit difficult to read.&lt;/li&gt;
&lt;li&gt;Now we have two different ways to call actions.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We encapsulate this complexity from our UI Components. In that way every action is executed in the same way. If we change that actions in the future, and it does not need any middleware, Components does not need any change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Middleware are composable in a chain.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Basically, This is a SOLID solution.&lt;/p&gt;

&lt;p&gt;If you want to know more, Stackoverflow &lt;a href="https://stackoverflow.com/questions/34570758/why-do-we-need-middleware-for-async-flow-in-redux"&gt;has a great thread&lt;/a&gt; talking about this doubts:&lt;/p&gt;

&lt;h2&gt;
  
  
  Cool but, Where is this exactly in Redux?
&lt;/h2&gt;

&lt;p&gt;The architecture inside redux looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GpU64nIB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/ramclen/documenting-dev/master/blog-posts/middleware-on-redux/tps://raw.githubusercontent.com/ramclen/documenting-dev/master/blog-posts/middleware-on-redux/assets/middleware-redux-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GpU64nIB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/ramclen/documenting-dev/master/blog-posts/middleware-on-redux/tps://raw.githubusercontent.com/ramclen/documenting-dev/master/blog-posts/middleware-on-redux/assets/middleware-redux-architecture.png" alt="middleware architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ehm but, How it works?
&lt;/h2&gt;

&lt;p&gt;So easy, thinking on Thunk Redux, when you dispatch one of yours new ThunkActions, is going through redux environment, but not directly to reducers. It first pass through middlewares and there, Thunk detect this action as a ThunkAction because it takes only one argument, a Redux store.&lt;/p&gt;

&lt;p&gt;After that, it will execute your "normal" actions in the order that they have been resolved. But this action will go finally to our reducers (But they could also pass through any other middleware)&lt;/p&gt;

&lt;p&gt;I think &lt;a href="https://medium.com/flutterpub/flutter-redux-thunk-27c2f2b80a3b"&gt;this post&lt;/a&gt; explain better.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I create my own middleware?
&lt;/h2&gt;

&lt;p&gt;As we saw on what its a middleware and where it is, it is a piece of code between actions and reducers.&lt;/p&gt;

&lt;p&gt;Here a small example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;awesomeMiddleware&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MY_ACTION&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`My awesome middleware is working!`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;otherAction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&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;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;applyMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;awesomeMiddleware&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The code is not really good, but it works for what we are trying to show. The power of middlewares. Probably the only thing for what you need a little more explanation is about Next &lt;a href="https://medium.com/netscape/creating-custom-middleware-in-react-redux-961570459ecb"&gt;(If you need more)&lt;/a&gt; . Next is a function that the middleware call when it finish with the assigned task. This sends the action to our reducer or another middleware.&lt;/p&gt;




&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ramclen/documenting-dev"&gt;my github repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>middleware</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
