<?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: Julian Schlickmann</title>
    <description>The latest articles on Forem by Julian Schlickmann (@schlickmann).</description>
    <link>https://forem.com/schlickmann</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%2F324765%2F85a25d0b-2bec-4262-b22b-6140c0b2e2cb.jpg</url>
      <title>Forem: Julian Schlickmann</title>
      <link>https://forem.com/schlickmann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/schlickmann"/>
    <language>en</language>
    <item>
      <title>Unlocking Your Future in Software Development: A Beginner's Guide</title>
      <dc:creator>Julian Schlickmann</dc:creator>
      <pubDate>Fri, 31 Mar 2023 20:47:51 +0000</pubDate>
      <link>https://forem.com/schlickmann/welcome-to-the-exciting-world-of-software-development-11ia</link>
      <guid>https://forem.com/schlickmann/welcome-to-the-exciting-world-of-software-development-11ia</guid>
      <description>&lt;p&gt;Welcome to the exciting world of software development! Whether you're a total beginner or have dabbled in coding before, starting a career in software development can be daunting. But fear not, with the right mindset, resources, and guidance, you can turn your passion for technology into a fulfilling and rewarding career.&lt;/p&gt;

&lt;p&gt;First things first, start by learning the basics of programming. Don't worry if you're not a math whiz or have never written a line of code before. You can find plenty of online resources that cater to different learning styles, from interactive platforms like Codecademy and Khan Academy to more traditional classroom settings like Udemy.&lt;/p&gt;

&lt;p&gt;Once you've got the basics down, it's time to choose your area of focus. Do you want to build websites and user interfaces? You might be interested in front-end development. Do you prefer working with databases and server-side technologies? Then back-end development might be more your thing. Or maybe you want to do a bit of everything and become a full-stack developer.&lt;/p&gt;

&lt;p&gt;Regardless of your area of focus, the key to success in software development is to build a portfolio. Create projects that showcase your skills and knowledge in software development. These can range from simple web apps to more complex systems. Share them on platforms like GitHub, LinkedIn, or your own website so potential employers or clients can see what you're capable of.&lt;/p&gt;

&lt;p&gt;Staying up-to-date with new technologies and frameworks is crucial in the software development industry. Follow tech blogs, attend conferences, and participate in online forums and communities. This will not only keep you informed but also help you network with other developers and professionals in the tech industry.&lt;/p&gt;

&lt;p&gt;Speaking of networking, building relationships with others in the industry can open up new opportunities, from finding your first job to getting mentorship and support from experienced developers. Attend meetups, conferences, or join online communities to meet other developers and learn from their experiences.&lt;/p&gt;

&lt;p&gt;Finally, remember that practice makes perfect. Keep honing your skills and building projects to gain more experience. Set goals for yourself and challenge yourself to learn new things. With hard work, dedication, and a willingness to learn, you can turn your passion for software development into a successful career. So go ahead and take that first step today!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>career</category>
    </item>
    <item>
      <title>Avoiding unnecessary network requests with Apollo Client</title>
      <dc:creator>Julian Schlickmann</dc:creator>
      <pubDate>Thu, 03 Jun 2021 00:06:18 +0000</pubDate>
      <link>https://forem.com/schlickmann/avoiding-unnecessary-network-requests-with-apollo-client-2l6h</link>
      <guid>https://forem.com/schlickmann/avoiding-unnecessary-network-requests-with-apollo-client-2l6h</guid>
      <description>&lt;p&gt;Hey, 👋 I'm Juliani and I work as a Front End Engineer at &lt;a href="https://www.thinkific.com/" rel="noopener noreferrer"&gt;Thinkific&lt;/a&gt;. Here at Thinkific, we've been using &lt;a href="https://graphql.org/" rel="noopener noreferrer"&gt;GraphQL&lt;/a&gt; to help us interact with our API and it's been amazing because it gives us the flexibility to request data as needed by our client applications. So, today I wanted to share a way to improve the &lt;strong&gt;performance&lt;/strong&gt; of applications as a whole &lt;strong&gt;reducing some network requests that maybe aren't necessary&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;Let's suppose we have an application that allows employers to create job posts and candidates can see those posts on a job board. In addition, the candidate can see a specific job post and all the ones related to a specific company.&lt;/p&gt;

&lt;p&gt;To be able to accomplish that we will need to have three queries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one to &lt;strong&gt;fetch all the job posts&lt;/strong&gt; to be able to display them on the &lt;em&gt;main dashboard&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;another one to fetch a &lt;strong&gt;specific job's details&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;and last but not least the query to fetch the &lt;strong&gt;company information and its job posts&lt;/strong&gt;;&lt;/li&gt;
&lt;/ul&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%2Fkdytm0znranpy41f3pd5.gif" 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%2Fkdytm0znranpy41f3pd5.gif" alt="Job dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the queries, a mutation to create a job post is also required.&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%2F4al6q989x7kpobawy7xw.gif" 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%2F4al6q989x7kpobawy7xw.gif" alt="Adding a new job post"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a mutation to &lt;strong&gt;create&lt;/strong&gt; an entity is executed &lt;em&gt;it isn't added automatically to the cache&lt;/em&gt;, the same happens when we want to &lt;strong&gt;delete&lt;/strong&gt; an entity or &lt;strong&gt;edit multiple entities&lt;/strong&gt;, the cache isn't touched. Therefore, the UI doesn't reflect the change. So, one common approach I've seen is to use the &lt;code&gt;refetchQueries&lt;/code&gt; option to &lt;strong&gt;refetch&lt;/strong&gt; all the queries needed after the mutation has occurred 💔 ❌. That causes new network requests that could be avoided by cache manipulation.&lt;/p&gt;

&lt;p&gt;For the create post mutation it could be something like the following. However, I'd recommend using &lt;code&gt;useMutation&lt;/code&gt; to follow the most recent changes to the Apollo library.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&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="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;job&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createJobPostMutation&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;jobQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;:&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;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;job&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="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Apollo offers ways to manipulate the &lt;a href="https://www.apollographql.com/docs/react/caching/cache-interaction/" rel="noopener noreferrer"&gt;cache&lt;/a&gt;, which might be beneficial in reducing additional requests to the API. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can read and write data directly to the Apollo Client cache, without communicating with your GraphQL server. You can interact with data that you previously fetched from your server, and with data that are only available locally.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When using &lt;code&gt;writeQuery&lt;/code&gt;, &lt;code&gt;writeFragment&lt;/code&gt; or &lt;code&gt;cache.modify&lt;/code&gt; it triggers a refresh of all active queries that depend on modified fields and therefore we have the UI up-to-date 💚 ✅. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Any changes you make to cached data with &lt;code&gt;writeQuery&lt;/code&gt; and &lt;code&gt;writeFragment&lt;/code&gt; are not pushed to your &lt;em&gt;GraphQL server&lt;/em&gt;. If you reload your environment, these changes will disappear.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By reducing network requests we can improve our app's performance 📈. &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%2F2t1vkglu76pgtez850te.gif" 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%2F2t1vkglu76pgtez850te.gif" alt="That's all folks"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>react</category>
      <category>javascript</category>
      <category>performance</category>
    </item>
    <item>
      <title>Functional Programming — What I have learned</title>
      <dc:creator>Julian Schlickmann</dc:creator>
      <pubDate>Wed, 18 Mar 2020 03:26:33 +0000</pubDate>
      <link>https://forem.com/schlickmann/functional-programming-what-i-have-learned-1haf</link>
      <guid>https://forem.com/schlickmann/functional-programming-what-i-have-learned-1haf</guid>
      <description>&lt;p&gt;Lately, I have been reading lots of papers talking about &lt;strong&gt;Functional Programming (FP)&lt;/strong&gt;, then I decided to summarize what I have learned writing this article.&lt;/p&gt;

&lt;p&gt;Before throwing a bunch of concepts here, do you know what is functional programming? It is a software development paradigm that is becoming more and more well-known among developers. The idea is coding simply and cleanly avoiding side effects using the power of functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Wikipedia defines Functional Programming as
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;… a programming paradigm — a style of building the structure and elements of computer programs — that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data — &lt;a href="https://en.wikipedia.org/wiki/Functional_programming" rel="noopener noreferrer"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most of the papers I have read address the following subjects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pure Functions;&lt;/li&gt;
&lt;li&gt;Immutability;&lt;/li&gt;
&lt;li&gt;Referential Transparency;&lt;/li&gt;
&lt;li&gt;Functions as first-class entities;&lt;/li&gt;
&lt;li&gt;Higher-Order Functions (HOF);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I believe it is important to understand the concepts mentioned before because you might be using FP and you do not even know. To comprehend them is essential to improve the quality of your code. So, let’s go to the concepts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pure Functions
&lt;/h2&gt;

&lt;p&gt;You might be asking yourself what are &lt;strong&gt;pure functions?&lt;/strong&gt; how do you create or to determine whether a function is pure or not?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pure functions always return the same results when given the same inputs. Consequently, they have no side effects. Pure functions allow referential transparency, which means you can replace a function call with its resulting value. — &lt;a href="https://www.keycdn.com/blog/functional-programming" rel="noopener noreferrer"&gt;Cody Arsenault&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, based on the reference above we can define a pure function as something deterministic. I have written a simple example below.&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%2Fi%2Fhvxr8zriql1ql3za3h06.gif" 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%2Fi%2Fhvxr8zriql1ql3za3h06.gif" alt="Impure Function" width="600" height="339"&gt;&lt;/a&gt;&lt;/p&gt;
Impure Function



&lt;p&gt;Could we consider it a pure function? We cannot consider it one example of pure function due to the global variable used and not passed as a parameter. However, we can fix it by passing the global variable as a parameter, but I rather write it as below.&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%2Fi%2Fp47xp8l6r90spffu212v.gif" 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%2Fi%2Fp47xp8l6r90spffu212v.gif" alt="Pure Function" width="600" height="339"&gt;&lt;/a&gt;&lt;/p&gt;
Pure Function



&lt;p&gt;Some examples of impure functions are the ones that &lt;strong&gt;read external files, generate random numbers&lt;/strong&gt;. It is due to the output that may be different even calling these functions passing the same parameters.&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="c1"&gt;// It generates a value given a minimum and a maximum value&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getRandomArbitrary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;max&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;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&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="nx"&gt;max&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;getRandomArbitrary&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;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;getRandomArbitrary&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;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fi%2Fu6ftfxyof4s1t4ytx06j.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%2Fi%2Fu6ftfxyof4s1t4ytx06j.png" alt="Random" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that being said we can conclude that using pure functions concept the code becomes easier to test and we do not need to mock anything.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Given a parameter &lt;strong&gt;w&lt;/strong&gt; → expect the function to return value &lt;strong&gt;x&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Given a parameter &lt;strong&gt;y&lt;/strong&gt; → expect the function to return value &lt;strong&gt;z&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Immutability
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  The ability to remain the same over time under all circumstances
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Data is immutable when its state cannot change after its creation. You cannot change an immutable object. You must create a new object with the new value instead. The following example is a common situation where people could refactor their code to follow the immutability principles.&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%2Fi%2Fmkl7jma2n3uxfgq08520.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%2Fi%2Fmkl7jma2n3uxfgq08520.png" alt="Mutable total variable" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;
Mutable total variable



&lt;p&gt;&lt;strong&gt;Recursion&lt;/strong&gt; is a great way to avoid mutability in iterations. Rewriting the code above we could have something like below.&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%2Fi%2Fttvg8g2zsty4d79imt6z.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%2Fi%2Fttvg8g2zsty4d79imt6z.png" alt="Immutable data" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;
Immutable data



&lt;p&gt;The &lt;strong&gt;sum&lt;/strong&gt; function receives the &lt;strong&gt;product&lt;/strong&gt; array and calls itself until we get an empty array. For each iteration, we will add the product &lt;strong&gt;price&lt;/strong&gt; to the &lt;strong&gt;total&lt;/strong&gt;. In the end, we have the summation of prices and also immutable variables.&lt;/p&gt;




&lt;h2&gt;
  
  
  Referential Transparency
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Referential transparency&lt;/strong&gt; is the concept of having the same output, whenever we use the same input. For example, having the following pure function.&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;cube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calling it &lt;strong&gt;three times&lt;/strong&gt; passing the number &lt;strong&gt;four&lt;/strong&gt; we always will get &lt;strong&gt;64&lt;/strong&gt; as the result. So, we could replace &lt;strong&gt;cube(4)&lt;/strong&gt; with 64. Therefore, we could affirm that &lt;strong&gt;referential transparency&lt;/strong&gt; is the result of writing a &lt;strong&gt;pure function&lt;/strong&gt; that has &lt;strong&gt;immutable data&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Functions as first-class entities
&lt;/h2&gt;

&lt;p&gt;The idea behind functions as first-class entities is that we should be treating a function as a value and using it as data. When we adopt this point of view we can start to &lt;strong&gt;refer to it from constants and variables&lt;/strong&gt;, also &lt;strong&gt;pass it as a parameter to other functions&lt;/strong&gt; and even &lt;strong&gt;return it as a result of other functions&lt;/strong&gt;. Getting back to our recursion example, we could have two new functions, &lt;strong&gt;totalAfterTaxes&lt;/strong&gt; and &lt;strong&gt;applyDiscount5&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%2Fi%2F2ly86s89f9x230ut7vsu.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%2Fi%2F2ly86s89f9x230ut7vsu.png" alt="Functions as first-class entities" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;
Functions as first-class entities



&lt;p&gt;As you can see we are consuming functions as an argument. We are creating a chain of execution that removes the necessity of creating variables to store the results to pass into the other functions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Higher-Order Functions (HOF)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  The definition of a higher-order function is a function that either takes one or more functions as arguments or returns a function as its result.
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Those new functions implemented above are an example of higher-order functions. If you are familiar with JavaScript you may have heard about &lt;strong&gt;filter&lt;/strong&gt; and &lt;strong&gt;map&lt;/strong&gt; functions. They are a common example of higher-order functions. Let’s take a look at some examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filter
&lt;/h3&gt;

&lt;p&gt;Let’s suppose we want all products under $2. We can use the filter function to evaluate another function and if the result is &lt;strong&gt;true&lt;/strong&gt; store item into a new array.&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%2Fi%2Fpgqmmvqryptura7vi4n3.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%2Fi%2Fpgqmmvqryptura7vi4n3.png" alt="Filter" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;
Filter Function



&lt;h3&gt;
  
  
  Map
&lt;/h3&gt;

&lt;p&gt;The map method can &lt;strong&gt;transform&lt;/strong&gt; a collection by &lt;strong&gt;applying a function&lt;/strong&gt; to all its elements and &lt;strong&gt;build a new collection&lt;/strong&gt; from the &lt;strong&gt;returned values&lt;/strong&gt;. If we would like to double the price of those products we could do something like the example below.&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%2Fi%2Fihbt0kihsvju7ctc9dry.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%2Fi%2Fihbt0kihsvju7ctc9dry.png" alt="Map" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;
Map Function






&lt;h2&gt;
  
  
  My conclusion
&lt;/h2&gt;

&lt;p&gt;After reading many papers and writing this article I think the Functional Programming (FP) paradigm a great way to coding high testable and bug-free applications. I hope to pass to you a little bit about my understanding of FP.&lt;/p&gt;

&lt;p&gt;Note: This was my first article in English, so I am sorry for any grammatical error 😅&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
    </item>
  </channel>
</rss>
