<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by João Marcus Fernandes on Medium]]></title>
        <description><![CDATA[Stories by João Marcus Fernandes on Medium]]></description>
        <link>https://medium.com/@joaomarcuslf?source=rss-9b9d2073f10f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TioOqQZg5kY8_lUeVzba_g.jpeg</url>
            <title>Stories by João Marcus Fernandes on Medium</title>
            <link>https://medium.com/@joaomarcuslf?source=rss-9b9d2073f10f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:38:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joaomarcuslf/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Structure 101: Part 4]]></title>
            <link>https://medium.com/arctouch/data-structure-101-part-4-57c19ec8b1d2?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/57c19ec8b1d2</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 23:30:54 GMT</pubDate>
            <atom:updated>2021-12-06T23:30:54.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9k1N79T_GkgzllstsBaog.jpeg" /></figure><p>This is the 4th post in a series about Data Structures.</p><p>In <a href="https://medium.com/arctouch/data-structure-101-part-03-64f179cfb683">Part 3</a> we learned about Lists, and that there are several ways to create a List of elements, and to manage how data is added or removed.</p><p>In this post, we are going to talk about <strong>trees</strong>, a special data structure. (You’re actually using a tree structure right now).</p><p>Trees are a non-linear data structure. Unlike the List which allocates a defined slot in memory, a Tree allocates along the way. The main element of a tree is a <strong>Node.</strong> Each node stores data as well as references to its next nodes (the children). The first node of a tree is called the <strong>Root</strong>, and the least elements are refered to as a <strong>Leaf</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKvB-t29ZezaJMKzvFkFYA.png" /><figcaption>Graphical example of a Tree</figcaption></figure><p>Usually in Data Structures, we represent tree upside-down, so the root is above everything. In the image above, A is the Root, B/C/D/F are Parents, and E/G/H/I/J are Leafs. B is Child of A. D is child of B, and so on.</p><p>This is a great Data Structure because you can create a relationship between nodes. For example, if we create a tree of integers, each node can have two children. To insert a new element, we follow this rule: if the value of the element is higher than the actual element, we insert it on the right side of the tree. If the value is lesser it will go to the left side of the tree.</p><p>For example, our first element is 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9wmWPygpqUTewW5ircP0g.png" /></figure><p>We want to add 5. Since 5 is less than 6, we add it on the left side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fu0A8PdBvZ7Zd_oNktVwMw.png" /></figure><p>Now, we want to add 8. Since 8 is greater than 6, we add it on the right side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7BVWVJo_wHTfl-1OVqMCg.png" /></figure><p>If we need to add 7, we check the root node 6 first.</p><p>It’s already full, so we move to the right side element which is 8. Since 7 is less than 8, it will be added on the left side of 8. Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHAgi66IQn7AfzTkt6jlQA.png" /></figure><p>When inserting data on a tree, we need to navigate each node using a type of algorithm called <strong>Recursion</strong>. I explained recursive algorithms in <a href="https://medium.com/arctouch/thinking-functional-now-with-example-and-cats-8b9c2478b9af"><strong>this post</strong></a>, but will summarize it explain it briefly again here.</p><p>Recursion is a method of solving a huge problem by splitting the solution into a small function and repeatedly calling itself through a list/tree until you reach the the last element. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/affbb8b28d376080415d58c0aaf8ca31/href">https://medium.com/media/affbb8b28d376080415d58c0aaf8ca31/href</a></iframe><p>This is a Binary Search tree that uses the Add method (which I&#39;ve explained before) and added the Search method and the Height method. Height is the number of floors that a tree have. This tree has a height of 4. All of these methods use recursion to call itself when the actual element isn’t the last one.</p><p>Binary search trees are optimized for search functions, since we only need to search on the side that we need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*OmRV7P0YluY2ToRj44jKGA.gif" /><figcaption>Visual representation of a Search in Binary Search Tree</figcaption></figure><p>I&#39;ve promised at the beginning of this post that I would explain how you are using trees right now. Well, you are using a web-browser or app to read this post. In either case, the way the elements are rendered on the screen is by applying a tree of elements. For example, the HTML structre:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quw_IjLFVxz4ven-0o533A.png" /></figure><p>In a basic HTML visualization whenever you use something like <strong>document.querySelector(&quot;div &gt; p&quot;)</strong> you are doing a search on the tree, but JavaScript creates an abstraction of that.</p><p>Cool, right? You know what would be even cooler?</p><p>If we built some Python code to be like HTML!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fa4886fd78d0b1a0ad26aa7e1726fbf/href">https://medium.com/media/3fa4886fd78d0b1a0ad26aa7e1726fbf/href</a></iframe><p>So trees are simple and beautiful, right? But trees can have problems if their Height is too great. On our first example of trees, you can see that if our first element is 1, almost all positive values are greater than one, so the tree will be huge on the right side, that is what we will call an unbalanced tree.</p><p>Unbalanced trees grow whenever we build a tree without a management algorithm. As the tree grows higher its gets harder to search it.</p><p>Remember FILO and FIFO of the last post? Those are management algorithms for List. Here’s a management algorithm for <strong>Balanced Trees.</strong></p><h3>Self-balancing binary search tree (SBBST)</h3><p>SBBST is hard to say, but simple to understand. This tree uses a balancing algorithm after the addition to try to make the tree smaller.</p><p>See this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9quY_Q12S-MEekxAl1-xQ.png" /></figure><p>The nodes 31 &gt; 33 &gt; 34 only have one child each. We can fix that by applying the AVL Tree algorithm,which rotates nodes either to left or right. In this case we can rotate 31 with 33, so 31 would be on the left side of 33, and 34 on the right side of 33. This is called left rotation and results in this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P78hGZm7KLvn9bgtjdZ81w.png" /></figure><p>Now you have a more balanced tree. AVL Trees is just one of the types of SBBST that exists. Here’s some more information about how they work.</p><ul><li><a href="https://www.geeksforgeeks.org/avl-tree-set-1-insertion/">AVL Trees</a></li><li><a href="https://www.geeksforgeeks.org/red-black-tree-set-1-introduction-2/?ref=lbp">Red-Black Trees</a></li></ul><h3>Conclusion</h3><p>On the next post, I introduce sorting algorithms as the final topic for this Data Structures series. Want to learn more? Please leave a comment.</p><p>Here at <a href="https://arctouch.com/">ArcTouch</a> we have a great team of software developers. If you’d like to join us, check out our <a href="https://arctouch.com/careers">career opportunities</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57c19ec8b1d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arctouch/data-structure-101-part-4-57c19ec8b1d2">Data Structure 101: Part 4</a> was originally published in <a href="https://medium.com/arctouch">ArcTouch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional Programming: With Examples and Lots of Cats ]]></title>
            <link>https://medium.com/arctouch/thinking-functional-now-with-example-and-cats-8b9c2478b9af?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b9c2478b9af</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[code-example]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Wed, 29 Sep 2021 20:00:00 GMT</pubDate>
            <atom:updated>2021-11-05T14:51:23.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_GlU1sJTcaK1-kuPGdABw.jpeg" /></figure><p>The idea of this post to help you better understand Functional Programming (FP) and how it can reduce side effects and take maximum advantage of our languages. This is based on a presentation I gave at TDC Transformation on August 25, 2021. Thank you to my colleagues at <a href="https://arctouch.com/">ArcTouch</a> for their support.</p><h3>The benefits of Functional Programming</h3><ul><li><strong>Side effects</strong> are avoided, and if needed, we can isolate them in wrappers.</li><li>Functional codes are <strong>predictable</strong>, which makes it easier to test all parts of your code.</li><li>They work great in <strong>concurrent systems, </strong>since FP systems are by definition a function. You can create a bunch of instances of the same system calling the same function.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQaFhUgQZuj2VGBdn9xy7g.jpeg" /><figcaption>Soon cat looking</figcaption></figure><h3>Pure Functions</h3><p>Pure functions are the base of FP, and they follow this rule:<br><strong>“Functions that given the same arguments have the same return”</strong></p><p>Pure functions don’t use data from external contexts, they just use their <br>arguments, following the closure like.</p><p><strong>Curiosity:</strong> lambda functions are anonymous functions passed to <br>blocks and other functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*KLvt3ohOF6l38xwcS3-vwA.jpeg" /></figure><h3>First Order Functions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*fIqFdo6lxIGITI5Bt5O2DQ.jpeg" /></figure><p>These are functions that take other functions as arguments, often used as “yield” blocks, or callback blocks.</p><p>Although simple, they are critical features to extend the capabilities of FP. With the use of this type of function, it is possible to write complex functions using several other smaller functions. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*-BdibVOglAj1zjh2Td4R5A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*XGcQw3FO3p2tsXpjH9mk9g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*UtloNsGiA69RFBy26MrSig.jpeg" /></figure><h3>Composition</h3><p>Composition is my favorite technique of Functional Programming.</p><p>Composition is the idea of stringing together function calls in such a way that when the composite function will execute in sequence, the others passing the return of one as an argument to the next:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ND99kxU_vSw7QLUEPbW_2w.png" /></figure><h3>Recursion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*iS9KMi64Fd2J6kHh31n1pg.jpeg" /></figure><p>Recursion is not an FP-only technique. It is part of the algorithms&#39; category that work with the concept of <strong>“Divide and conquer”</strong>.</p><p>The same function is called, reducing the number of elements it receives, to carry out a certain routine.</p><p>It is a very common technique to handle an element list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*AiTgfC767XUFWepHRrt13Q.jpeg" /></figure><p>For example, this is an array of items, each item may have children, and the children must be shown recursively.</p><p>With this example, we create a component that calls itself when the children are detected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*Z2lnVgB3USZj24FWX6SY6w.jpeg" /></figure><h3>Partial Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*kB3tb-7kFsuQC6B4PgdS0A.jpeg" /></figure><p>This is Functional Programming technique is also known as <strong>Currying</strong>.</p><p>It is not possible in all modern languages, but its idea can be applied even without native support.</p><p>Partial Application creates “curried” functions that can receive arguments at different times, which allows you to create helpers using different arguments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*27baZzzKBSz0wB4HnKQobQ.jpeg" /></figure><p>This is the buildUri function, but it is the lame way to do it, since all arguments must be present.</p><p>Now, the cool way using the FP approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*hXEtJFm8tP9bNq0mCMZd2g.jpeg" /></figure><p>If we use curry, we can create a function and then call it with just the path.</p><h3>Useful Functional Programming methods</h3><h4>Map</h4><p>Map is a widely used function for manipulating lists. You get a list and a callback, and inside the callback you return what you want, creating a new list with the callback returns.</p><h4>Filter</h4><p>Filter also takes a callback and a list, and returns a new filtered list based on the true/false callback return.</p><h4>Reduce</h4><p>Reduce is a very powerful feature. You can turn a list into literally anything you want, whether it’s a string, an object, a new list, the sky is the limit to reduce.</p><h3>Point-free</h3><p>Normally functional languages don’t use dot-like signatures, like <em>document.getElementById(app).innerHTML</em>.If JavaScript were a full functional language, like ClojureScript, this call could look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LuSXubUpgz2b4wO1UCiW1Q.png" /></figure><h3>Monads</h3><p>Monads are the way Functional Programming deals with Null values. Usually, it implements the Maybe, which wraps the value, and can only be accessed by the wrap instead of using point path.</p><p>Monads are more than just that, but that’s all you need to know for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*mmLyiA-2RCCx0xAcmRZJpg.jpeg" /><figcaption>Simple implementation for a Maybe.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*JypuO4LE3oqKouIjOVKGbw.jpeg" /><figcaption>Converting functions to use the Maybe example above.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*z6nNkhAYQu9hOvrsOcvR1w.jpeg" /><figcaption>The first example of this post, but now with Maybe.</figcaption></figure><h3>Fantasy-Land</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*8lyXp9YAc5pLZz_VNX72NQ.jpeg" /></figure><p>Fantasy Land is the <a href="https://github.com/fantasyland/fantasy-land">specification for Functional Programming</a>, and it uses many concepts from Algebra.</p><h3>Tail Call Optimization and Lazy evaluation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*10Xmse-DRp7R8OL31TFPlQ.jpeg" /></figure><p>Tail Call Optimization is a feature of functional languages, which given the predictability of recursive functions, maps, reduces, filters, and other methods that use lists that can be huge, the language’s own interpreter/compiler/VM predicts the next call results much faster.</p><p>When these calls are applied to very large lists, the same interpreter/compiler/VM optimizes processing to only apply functions when needed, greatly reducing memory usage.</p><h3>How to start Functional Programming today in JS?</h3><p>There are some libraries that implement the FP concepts, and the specifications for the Fantasy-land.</p><ul><li><a href="https://github.com/lodash/lodash/wiki/FP-Guide">Lodash/FP</a></li><li><a href="https://ramdajs.com/">RamdaJS</a></li><li><a href="https://github.com/sanctuary-js/sanctuary">SanctuaryJS</a></li></ul><h3>Wrapping up</h3><p>You are now ready to start exploring Function Programming. I recommend you start with the Lodash/FP and then use its helpers to improve your code.</p><p>Do you like Functionanl Programming? Come to ArcTouch and join our FP study group. We’ll hold a spot for you. Check out our <a href="https://arctouch.com/careers">career opportunities</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*cLAiqKZXjA8w9_cuJK8t0A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b9c2478b9af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arctouch/thinking-functional-now-with-example-and-cats-8b9c2478b9af">Functional Programming: With Examples and Lots of Cats 🐈</a> was originally published in <a href="https://medium.com/arctouch">ArcTouch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structure 101: Part 3]]></title>
            <link>https://medium.com/arctouch/data-structure-101-part-03-64f179cfb683?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/64f179cfb683</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Wed, 15 Sep 2021 14:28:49 GMT</pubDate>
            <atom:updated>2021-11-05T12:01:47.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxIWyeqZRNVf6Xd50d_WNw.jpeg" /></figure><p>This is the 3rd post in a series about Data Structures.</p><p>In <a href="https://medium.com/arctouch/data-structure-101-part-02-d26cb18defa6">Part 2</a> we learned how to evaluate Data Structures and algorithms.</p><p>In this post we will talk a bit about <strong>lists</strong>, which are one of the most used data structures. Then we will explore some algorithms to deal with them.</p><p>Lists (also called arrays, or slices) are a linear structure, an arrangement of data that can be accessed by a numerical index. Let’s see an example for that.</p><p>This is our list, let’s call it <strong>N</strong>, and <strong>N</strong>, is a list of strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*lw4qbZ1LhzA12dWPuTW7TQ.png" /><figcaption>List containing letters from A to H</figcaption></figure><p>If we want to access the ‘E’ value, we should access it by its index, which should look something like <strong>N[4]</strong>.</p><p>“Wait, why 4, and not 5 which is the position in the array?” you may ask.</p><p>This is something that came from low-level coding languages, like <strong>C</strong> for example. When we create a list in those languages, it allocates a linear slot in the memory, and points to the initial address of the allocated slot, like address <em>1024</em>. And to access the desired element, we use the index because the number that represents the index is added to the initial address of the list, and with that, they find the memory position where the list was prior allocated. In our example, if the<strong> </strong>first element of <strong>N</strong> is allocated in memory <em>1024</em>, to get the ‘E’ value, we should access <em>1024 + 4</em>. You can see an example below, look how N allocated spaces from <em>1024</em> to <em>1031</em>? The index starts from 0 and goes all the way up to the end of the allocated memory. This was used to optimize access to memory, and is very used for low-level languages until this day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*L-POhD7bjUazLjpRNMQDVw.png" /><figcaption>Example of how memory allocation works.</figcaption></figure><p>This is how lists work on behind the scenes. At the high level, you just need to remember that lists can be accessed by using index, they use a chunk of the memory to work, and they usually have methods to add items, filter by a condition, navigate/loop through it, and remove items.</p><p>Let’s see some examples in python.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1484f00e0d041a6f496bef3a2f84f2cb/href">https://medium.com/media/1484f00e0d041a6f496bef3a2f84f2cb/href</a></iframe><p>If you have read the prior posts you may remember we talked about Big O notation. And you can check that with the loop and/or filter you have to navigate through all the elements inside the list at least once. For that reason, those kinds of codes are categorized as <strong>O(n)</strong>, on the Big O notation. For the Big O, your code is categorized by its worst case, and the worst case in this scenario is to iterate through all element.</p><p>To optimize those kinds of routines, we have some extensions of the base list, which implements some of these rules:</p><ul><li>Rule of <strong>insertion</strong></li><li>Rule of <strong>deletion</strong></li><li>Rule of <strong>management</strong></li></ul><p>Let’s check some of those extensions below.</p><h4>FIFO (First In, First Out)</h4><p>Also called <strong>queue</strong>, it’s a structure that implements two rules: 1) To insert an element to the queue it must be added at the end of the list, and 2) To remove an element, you must remove the first element that entered the list.</p><p>As an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a66b72d9960b2391cdbc606b62fbb77/href">https://medium.com/media/6a66b72d9960b2391cdbc606b62fbb77/href</a></iframe><p>They are used a lot in applications that have to process data in the order that it was input, like a cart in an E-commerce app or a service queue.</p><h4>FILO (First In, Last Out)</h4><p>Also called <strong>stack</strong>, like the last example, it implements two rules: 1) To insert an element it must be added at the end of the list, and 2) To remove an element you must remove the last element that entered the list.</p><p>Let’s see an example below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0abd36ee3138e2b9570e738595a2d7f5/href">https://medium.com/media/0abd36ee3138e2b9570e738595a2d7f5/href</a></iframe><p>Stacks are typically used to deal with call stacks in coding languages.</p><h4>Sorted list: What is that?</h4><p>Sorted lists is one that implements a rule o management.</p><p>As the name suggests, to create a sorted list, we need to run a routine after the addition of an element. This routine sorts elements following some rule, like the element with bigger value will be the last in the list, or any order that has a consistent rule.This may seem to be something strange because it increases the time complexity of the add method. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9c1ec3986fdcdfe02aaf0651f170deb/href">https://medium.com/media/a9c1ec3986fdcdfe02aaf0651f170deb/href</a></iframe><p>The reason is to optimize the search method. On normal lists, to search an element you have to navigate though the role list as we saw on the previous examples. This is usually very slow. If we need to search more than add, this is a great solution. So, it’s worth it to increase the time complexity of the add method, in exchange to have less time complexity on searches.</p><p>Let’s see how the search can be optimized, by learning a great algorithm, the <strong>Binary Search.</strong></p><h4>Sorted list: How to search with Binary search?</h4><p>Binary search, is an optimized algorithm to search elements, and it only works for sorted structures. It works by dividing the list into to portions. You check the middle element of a portion and if the element is found then you return it. If not, you check if the element is bigger than the middle element. If so, you repeat the function by creating a portion on the right side of the middle element, and if it is smaller than the middle element, you look on the left side.</p><p>See the code below for an implementation example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01c82589c8114d5af03328cccc7f9798/href">https://medium.com/media/01c82589c8114d5af03328cccc7f9798/href</a></iframe><p>Here is a GIF comparison of how that’s work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*WQlXSV19C_VZlZkgQuduWw.gif" /></figure><p>Binary search is very optimized, reducing the steps to find an element a lot. If your system uses search more than it add elements, consider this algorithm.</p><h3>Conclusion</h3><p>In this post we covered lists and algorithms to add, remove and sort data.</p><p>On the next post, we will explore about trees and will learn how to do binary search inside trees, sort trees, and what are balanced trees.</p><p>Want to add something for the discussion? Please leave a comment.</p><p>Here at <a href="https://arctouch.com/">ArcTouch</a> we have a great team of software developers. If you’d like to join us, check out our <a href="https://arctouch.com/careers">career opportunities</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64f179cfb683" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arctouch/data-structure-101-part-03-64f179cfb683">Data Structure 101: Part 3</a> was originally published in <a href="https://medium.com/arctouch">ArcTouch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structure 101: Part 02]]></title>
            <link>https://medium.com/arctouch/data-structure-101-part-02-d26cb18defa6?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d26cb18defa6</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Tue, 13 Jul 2021 16:05:14 GMT</pubDate>
            <atom:updated>2021-10-05T22:19:36.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Structure 101: Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NkScgkQoJEXGPAY-Piiyg.jpeg" /></figure><p>This is the 2nd post in a series about Data Structures.</p><p>In <a href="https://medium.com/arctouch/data-structure-101-part-01-54c1daed073b">Part 1</a> we learned the importance of studying Data Structure. In this post we will learn how to evaluate Data Structures and algorithms.</p><h3>What is Cyclomatic Complexity?</h3><p>Cyclomatic Complexity (CC) is a metric used to calculate the &quot;time&quot; an algorithm takes to complete its interactions. The word time is in quotes because it isn&#39;t exactly the time in seconds, but the number of commands, function, modules, and conditions an algorithm will take to complete a linear path.</p><p>Try to imagine you want your code to get all links from a page, and then open a new tab with all the links you got. To simplify, here is the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27a46282697eaecddbbe4edb67d1a5c6/href">https://medium.com/media/27a46282697eaecddbbe4edb67d1a5c6/href</a></iframe><p>A control flow chart for this example is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IATC0SjQjYX3uwuZKpvjYw.jpeg" /><figcaption>Flow chart containing the logic described above</figcaption></figure><p>With this in mind, you can calculate the CC byfollowing this formula:<br><strong><em>M = E — N + 2P<br></em></strong>Where:<br>- E: Number of the edges in the chart<br>- N: Number of the nodes in the chart<br>- P: Number of connected components in the chart</p><p>In the flow chart above we have:<br>E = 5<br>N = 5<br>P = 1</p><p>So, M = 5 — 5 + 2 = 2;</p><p>You might be thinking, &quot;Okay, but what do I do with that number?&quot;</p><p>The result for <strong>M </strong>shows if your code needs to be prioritized for refactoring.</p><p><strong>≤4:</strong> is considered good<br><strong>≥5 &amp; ≤7:</strong> is considered medium<br><strong>≥8 &amp; ≤10:</strong> is considered high<br><strong>≥11:</strong> something is really wrong here</p><p>If you need to refactor, try creating the CC score for its routines first. It&#39;s helpful to know where to start, and know if you made progress. You can compare the before and after, and see the improvements made.</p><p>There are other metrics to measure complexity.</p><p>One of my favorites is <strong>Time complexity</strong>.</p><h3>What is Time Complexity?</h3><p>Time Complexity (TC) is somewhat more straightforward. As the name suggests, it uses time as the main metric, but it’s computer time, calculated by the number of operations performed by an individual algorithm. Since we have a lot of variability involved in an algorithm, going all the way from the input we receive to the conditions we have, we use three cases, <strong>the worst case</strong>,<strong> the best case</strong>,<strong> </strong>and<strong> the medium case</strong>.</p><p>Using the code shown before, let&#39;s try to figure out what those cases are by example. The concept for the best case is what input must be given to the algorithm to finish running and consuming the fewest amount of computational time. In the algorithm given above, the best case is to have no link because you will look for links in the DOM, and skip the <em>for loop</em>.</p><p>And the worst case? This would be a huge number of links so the code will take forever to complete (and probably crash the browser). And the medium case is somewhere between these extremes.</p><p>Time Complexity usually uses <a href="https://en.wikipedia.org/wiki/Big_O_notation">Big O notation</a>. The Big O notation uses <strong>N</strong> as the input, and for the Time Complexity, the worst-case is used to summarize an algorithm. For the example shown above, the category of the algorithm is O(n) because it will run for each element in the input. If you have any questions about Big O notation, leave a comment and I’ll respond.</p><p>In a future post I intend to give some more examples.</p><h3>Conclusion</h3><p>In this post we learned two essential concepts about Data Structures. If you have anything you want to see in future posts, please leave a comment.</p><p>Here at <a href="https://arctouch.com/">ArcTouch</a> we have a great team of software developers. If you’d like to join us, check out our <a href="https://arctouch.com/careers">career opportunities</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d26cb18defa6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arctouch/data-structure-101-part-02-d26cb18defa6">Data Structure 101: Part 02</a> was originally published in <a href="https://medium.com/arctouch">ArcTouch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Os 2 cenários problemáticos mais comuns no desenvolvimento de softwares.]]></title>
            <link>https://joaomarcuslf.medium.com/os-2-cen%C3%A1rios-problem%C3%A1ticos-mais-comuns-no-desenvolvimento-de-softwares-2040a5bcf3b2?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2040a5bcf3b2</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tdc]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Tue, 08 Jun 2021 16:28:56 GMT</pubDate>
            <atom:updated>2021-06-08T16:28:56.813Z</atom:updated>
            <content:encoded><![CDATA[<h3>Os 2 cenários problemáticos mais comuns no desenvolvimento de softwares. Será que você já passou por algum deles?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tNXhsCM4gHwc0UDG54VXg.jpeg" /></figure><p>Não é incomum encontrar pessoas desenvolvedoras em fóruns contando sobre falhas em projetos que participaram — desde softwares sendo desenvolvidos sem considerar a experiência do usuário até equipes ignorando problemas óbvios apenas para entregar o produto mais rápido. Se você for uma pessoa desenvolvedora, é até provável que você já tenha lidado com um desses erros por aí.</p><p>Dentre esses cenários, tem dois que eu considero mais graves, exatamente pelo impacto que eles podem gerar futuramente. <strong>E o pior</strong>: no geral, esse impacto gera custos desnecessários, que poderiam ter sido evitados se outra postura tivesse sido adotada.</p><h3>1º cenário: tratar o software como pastel</h3><p>Muitas empresas ainda enxergam a área de desenvolvimento de software como uma pastelaria: basta pedir o que deseja e, então, estará tudo pronto em pouquíssimo tempo. Infelizmente, não é bem assim que tudo funciona.</p><p>Algo muito comum, é o uso do conhecido “Go-horse”, onde as coisas são feitas bem rápidas, apesar de ser efetivo no início, esse modelo traz diversos impactos no futuro, e para isso nós temos diversas metodologias, e padrões que podem nos ajudar a enfrentar menos dores de cabeça.</p><p>Conseguir escolher as melhores opções de arquitetura, e padrões quando estamos com a mentalidade de fazer às pressas é altamente improvável. No geral, quando se segue o estilo “pastelaria”, o resultado acaba sendo um projeto feito em uma arquitetura inadequada, que desconsidera as necessidades a longo prazo. Sem contar os problemas e bugs que costumam ir aparecendo conforme o software é usado, devido à falta de tempo que foi disponibilizada para revisões e testes.</p><p>Realmente, fazer softwares às pressas pode até parecer vantajoso e econômico à primeira vista, mas os problemas sempre surgem com o tempo. Será que realmente vale a pena? Eu sou do grupo que acredita que não.</p><p>Se usar mais tempo e ter mais cuidado no desenvolvimento irá trazer bons frutos a longo prazo, então, para mim, esse é o melhor caminho — mesmo que dê mais trabalho e exija mais dedicação.</p><h3>2º cenário: criar um software extremamente rígido</h3><p>Também já ouvi muitos desenvolvedores e desenvolvedoras afirmando que um bom software deve ser firme como um prédio. Ou seja: deve ter uma arquitetura rígida e robusta para ser realmente considerado de qualidade. No entanto, seguir esse caminho sem ponderar anteriormente, pode resultar em uma série de questões a longo prazo. Alguns exemplos são:</p><ul><li>precisar reescrever softwares anualmente, porque, devido à sua inflexibilidade e inextensibilidade, o software não consegue contemplar as novas necessidades do cliente;</li><li>levar mais tempo para fazer mudanças geralmente simples, novamente devido à inflexibilidade do produto desenvolvido;</li><li>maiores custos de manutenção devido à robustez do software;</li></ul><p>Se clientes, realidades e necessidades mudam, não há sentido em insistir em uma arquitetura rígida para todos os softwares que você desenvolver. Em quase 100% dos casos é extremamente benéfico criar um produto flexível e extensível, mesmo que demande um pouco mais de dedicação.</p><p>Na minha opinião, a questão da rigidez pode ser especialmente resolvida com a aplicação de uma <strong>arquitetura de camadas</strong>, que também é chamada de triângulo invertido do front-end.</p><p><em>(Se você quiser saber como essa arquitetura funciona, eu e a </em><a href="https://leticiarabbit.medium.com/"><em>Leticia Coelho</em></a><em> falaremos mais sobre ela em nossa palestra na The Developer’s Conference, que acontecerá às 10:30, na quarta-feira (09/06). Você pode se inscrever </em><a href="https://promo.thedevelopersconference.com.br/tdcconnections-arctouch"><strong><em>aqui</em></strong></a><em> para acompanhar essa e outras palestras que acontecerão na trilha da ArcTouch ao longo desta semana).</em></p><p>E aí, você já cometeu algum dos erros que mencionados acima? Se sim, você precisou tomar alguma atitude para solucioná-los? Vamos trocar experiências aqui nos comentários!</p><p><em>* Esse artigo foi escrito em parceria com o </em><a href="https://leticiarabbit.medium.com/"><em>Leticia Coelho</em></a><em>, Engenheira de Software na ArcTouch.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2040a5bcf3b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structure 101: Part 1]]></title>
            <link>https://medium.com/arctouch/data-structure-101-part-01-54c1daed073b?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/54c1daed073b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Wed, 26 May 2021 13:51:42 GMT</pubDate>
            <atom:updated>2021-10-05T22:26:10.105Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Banner with someone writing in a notebook" src="https://cdn-images-1.medium.com/max/1024/1*i4O7ozrp-ScvjFdWo18jTA.jpeg" /></figure><p>I’ve wanted to write about Data Structure for a few years.</p><p>Why?</p><p>To most people with computer science knowledge, Data Structure is something boring that we are taught in school because we have to learn it. To me, Data Structure is a tool — one that is <strong>essential for project success</strong>.</p><p>These are the topics I will cover in this series of posts:</p><ul><li>The importance of Data Structure</li><li>What is Cyclomatic Complexity</li><li>Simple Data Structures</li><li>Complex Data Structures</li><li>Sorting Algorithms, and when are they required</li><li>Search Algorithms, and how it helps to learn how to search</li><li>Why some algorithms are better than others</li><li>How to refactor using Cyclomatic Complexity as a tool</li></ul><p>I’ll cover one or two topics per post. It’s easier for me to write, and probably easiser to understand. So, let&#39;s begin.</p><figure><img alt="Code editor picture" src="https://cdn-images-1.medium.com/max/1024/1*HdZtkV8O-VN9GjZotLQM2g.jpeg" /></figure><h3>What is the importance of Data Structure?</h3><p>We as software developers deal with some sort of data every day. Whether it’s a list of list of users delivered from some back-end API, or some registration data from a web form. We have to choose what <strong>types </strong>we will be using for each individually case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*l0JgfYlt1vNKT6hkrAbwZg.png" /></figure><p>As an example, imagine the client requested the phone number with a mask.</p><p>If you had chosen to use a <strong>number</strong> type for this field, you would have some issues on formatting the value. So, the data type you used is important for this scenario, right?</p><p>This is a somewhat &quot;zoomed in&quot; example, but you can scale it up to Rest APIs, which send lists of data. It isn&#39;t something unusual to have this example:</p><figure><img alt="Two api responses" src="https://cdn-images-1.medium.com/max/942/1*Ty2NkbQ6rC4It8eZFvbUOg.png" /></figure><p>You will often face this situation — the REST API have two endpoints, one for the events, and another for the users. To know which events belong to which user, you have to either query the events API with the user_id, or iterate in both array to link them.</p><p>I know this is a bad scenario, but for the scenarios&#39; sake keep this in mind. We could send the events as a field in the users, but this would become expensive for the request parse eventually. Alternatively, we could create the <strong>/users/:id </strong>where just when we are getting one user, we get the event associated to the user. Again this will cause our app to make several requests for each user.</p><p>While none of the solutions are completely bad or completely good, each has their pros and cons.</p><h3>Conclusion</h3><p>In <a href="https://medium.com/arctouch/data-structure-101-part-02-d26cb18defa6">part 2</a>, I talk about Cyclomatic Complexity, which is a crucial tool to understand why some codes are bad, and some are good.</p><p>I really hope you like this series idea and it helps you become a better engineer. I&#39;m not the <strong>expert </strong>in this topic, but I am enthusiastic about it.</p><p>If you have something new to add, please use the comment section, I really want to hear some more opinions about these topics.</p><p>Here at <a href="https://arctouch.com/">ArcTouch</a> we have a great team of software developers. If you’d like to join us, check out our <a href="https://arctouch.com/careers">career opportunities</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54c1daed073b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arctouch/data-structure-101-part-01-54c1daed073b">Data Structure 101: Part 1</a> was originally published in <a href="https://medium.com/arctouch">ArcTouch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refletindo sobre mulheres na computação e comunidades tóxicas]]></title>
            <link>https://code.likeagirl.io/refletindo-sobre-mulheres-na-computa%C3%A7%C3%A3o-e-comunidades-t%C3%B3xicas-85a7efaa435?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/85a7efaa435</guid>
            <category><![CDATA[codelikeagirlbr]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[mulheresemti]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[tecnologia]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Thu, 22 Jun 2017 17:10:28 GMT</pubDate>
            <atom:updated>2017-06-25T19:46:59.674Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5Ceuq3TTVezWGpyS1SxfQ.png" /></figure><p>Se você participa de algum canal no Telegram, Twitter, Facebook e outros, você talvez tenha visto sobre ataques a uma mulher e logo depois todo um grupo de apoio da comunidade de um membro do Telegram, se não, fica aqui o um Twitter falando sobre: <a href="https://twitter.com/jesstemporal/status/877658474519384064?s=09">https://twitter.com/jesstemporal/status/877658474519384064?s=09</a></p><h3>Antes, um recado:</h3><p>Se você entrou nesse post e tem o pensamento de que mulher não pertence a computação por qualquer impedimento que você acha que exista, peço que venha comigo e analise os seguintes pontos:</p><ul><li>Você utiliza alguma linguagem orientada a objeto? Parabéns, você utilizada uma linguagem que foi inspirada na Smalltalk, que adivinhe? Teve co-autoria de uma mulher <a href="https://pt.wikipedia.org/wiki/Adele_Goldberg">Adele Goldberg,</a> seu Java, C++, Ruby, tudo isso nasceu dessa linguagem.</li><li>Gosta de eletrônicos? Uma das maiores responsáveis pela popularização desses é <a href="https://www.adafruit.com/about">Limor “Ladyada” Fried</a> que fundou a loja AdaFruit e tem tornado cada vez mais acessível o movimento hacker sobre esses dispositivos.</li><li>E por falar da Ada, como não falar da primeira pessoa a escrever um algoritmo que foi processado por uma máquina? Nossa querida <strong>Ada Lovelace </strong>foi uma matemática que inspirou e inspira muitos até hoje, existe até uma linguagem em sua homenagem.</li></ul><p>Resumindo, o terreno que estamos foi construído por tantas mãos, e dentre elas existem muitas mulheres, eu citei três exemplos famosos, mas temos outros não famosos. Eu aprendi a programar com uma professora mulher, quando quis aprender Rails, aprendi no RailsGirls, conheço pessoas geniais que são mulheres e elas são tão capazes quanto qualquer um de nós. Avalie um pouco seu pensamento, ainda está em tempo de mudar, a mudança é um processo demorado de auto-correção contínua, mas no fim ela vale a pena.</p><h3>Sobre o caso:</h3><p>Tivemos resposta incríveis e uma ação da comunidade que foi muito bem orquestrada, parabenizo todos que participaram e principalmente aos que criadores do grupo novo. Aposto que essa iniciativa irá atrair muito todos que quiserem compartilhar conhecimentos de forma horizontal e sem agressões.</p><p>Sobre o causador de tudo temos algumas lições a tirar, ele não estava defendendo uma opinião política, o que ele fez foi pura e “simples” agressão, ele possui problemas sociais claros, a falta de empatia quando ele (e o próprio grupo que ele estava) não foram capazes de compreender que aquilo não era brincadeira e sim algo extremamente ofensivo. Apesar dele ter sido irredutível sobre os pensamentos dele (mesmo após todas as tentativas), nós torcemos que ele possa aprender com o que foi dito e venha se desculpar em público, se comprometendo a colaborar com uma comunidade inclusiva.</p><h3>Nota pessoal:</h3><p>Se você, assim como eu, não teve participação direta nesse caso, não expressou sua reação, não mostrou indignação, peço que, a partir de agora, passemos a nos posicionar sobre esse assunto. Nós temos que mostrar que existe uma comunidade não tóxica, temos que mostrar que é possível que haja diálogo, que haja aprendizado não vertical e sem ofensas, e que quando virmos casos como esse não sejamos mais um para a massa calada. Precisamos mudar nossas nossas atitudes, e será questão de tempo até muitas das comunidades tóxicas só conterem aqueles que as envenenam e os que querem aprender se “converterem” às comunidade voltadas ao aprendizado.</p><p>Acredito que muitos nesses grupos omitem suas opiniões não porque concordam, mas porque não sabem que existe outro caminho, exemplos como esse novo grupo criado são excelentes para esses casos, e demonstram a força que podemos ter.</p><p>Obrigado aos que leram, estou aberto a qualquer tipo de crítica pois eu mesmo estou no processo de reconhecer meus erros.</p><p>Referências:</p><ul><li>Esse post foi inspirado na ideia e na resposta do <a href="http://andregarzia.com/">André Garzia</a></li><li>RailsGirls — <a href="http://railsgirls.com/">http://railsgirls.com/</a></li><li>Mulheres na computação — <a href="https://mulheresnacomputacao.com/">https://mulheresnacomputacao.com/</a></li></ul><h4>Siga a tag <a href="https://medium.com/search/tags?q=codelikeagirlBR">codelikeagirlBR</a> para ver nossos posts! :D</h4><p>Quer escrever ou traduzir artigos em português para a Code Like A Girl? Se você já faz parte do time de escritoras(es) da Code Like A Girl basta enviar seu artigo diretamente para nossa publicação. Se você ainda não faz parte do nosso time, envie uma mensagem direta para a conta de twitter<a href="https://twitter.com/CodeLikeAGirlBr"> CodeLikeAGirlBr</a>. Nós avaliaremos seu artigo e ajudaremos a refiná-lo para publicação.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85a7efaa435" width="1" height="1" alt=""><hr><p><a href="https://code.likeagirl.io/refletindo-sobre-mulheres-na-computa%C3%A7%C3%A3o-e-comunidades-t%C3%B3xicas-85a7efaa435">Refletindo sobre mulheres na computação e comunidades tóxicas</a> was originally published in <a href="https://code.likeagirl.io/">Code Like A Girl</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testando JavaScript corretamente com Mocha + ES6 + Gulp]]></title>
            <link>https://joaomarcuslf.medium.com/testando-javascript-corretamente-com-mocha-es6-gulp-a29e9e4f25c1?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a29e9e4f25c1</guid>
            <category><![CDATA[mocha]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Sun, 25 Sep 2016 21:19:54 GMT</pubDate>
            <atom:updated>2016-09-25T21:19:54.142Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpQepLZroAap3HMDqT0lWA.jpeg" /></figure><p>Como desenvolvedor, muito provavelmente você já teve que escrever algum tipo de validador ou formatador, seja de cpf, data, ou qualquer que seja. Sabendo disso, você escreve seu formatador, feliz e contente, até que descobre alguma falha, ou algum caso de falha, você como todo bom desenvolvedor, escreve mais código que resolva isso, e esse ciclo permanece até o fim dos tempos, isso se durante o processo, você não precisar refatorar esse código. Pensando nisso, estou escrevendo um workflow para você escrever uma suite de testes para seu formatador com eficiência e sem medo de não conseguir os problemas que tinha resolvido antes.</p><p>Para isso, vamos utilizar babel, mocha, gulp. Se não quiser montar o ambiente do zero, você pode ver o repositório diretamente aqui: <a href="https://github.com/joaomarcuslf/ng-mocha-test">ng-mocha-test</a>.</p><p>Primeiro vamos configurar o ambiente, você pode passar por essa etapa rapidamente só copiando o código, porém tente entender o que cada etapa faz. Digite no seu terminal npm init, e vá preenchendo os campos da forma que você quiser, depois abra no seu editor de preferência e adicione as seguintes devDependencies:</p><pre>&quot;devDependencies&quot;: {<br>    &quot;babel-core&quot;: &quot;^6.14.0&quot;,<br>    &quot;babel-preset-es2015&quot;: &quot;^6.14.0&quot;,<br>    &quot;chai&quot;: &quot;^3.5.0&quot;,<br>    &quot;gulp&quot;: &quot;^3.9.1&quot;,<br>    &quot;gulp-babel&quot;: &quot;^6.1.2&quot;,<br>    &quot;gulp-mocha&quot;: &quot;^3.0.1&quot;,<br>    &quot;gulp-util&quot;: &quot;^3.0.7&quot;,<br>    &quot;mocha&quot;: &quot;^2.5.3&quot;,<br>  }</pre><p>Após isso dê npm install enquanto instala as dependências, vamos escrever nossas tasks no gulp e nossa configuração do babel, utilize a estrutura de pasta que quiser, porém nessa tutorial será utilizado a seguinte:</p><pre><br>ng-mocha-test/</pre><pre>|_app/<br>|__formatters/<br>|___cpfFormatter.babel.js<br>|_spec/<br>|__cpfFormatter.spec.babel.js</pre><h3>gulpfile.babel.js</h3><pre>&#39;use strict&#39;;</pre><pre>import gulp from &#39;gulp&#39;;<br>import gutil from &#39;gulp-util&#39;;<br>import babel from &#39;gulp-babel&#39;;<br>import mocha from &#39;gulp-mocha&#39;;</pre><pre>gulp.task(&#39;default&#39;, () =&gt; {<br>  gutil.log(&quot;Gulp is working fine&quot;);<br>});</pre><pre>gulp.task(&#39;test&#39;, () =&gt; {<br>  gutil.log(&quot;Running your specs files&quot;);<br>  return gulp<br>    .src(&#39;./spec/**/*.spec.babel.js&#39;)<br>    .pipe(babel())<br>    .pipe(mocha());<br>});</pre><h3>.babelrc</h3><pre>{<br>  &quot;presets&quot;: [&quot;es2015&quot;]<br>}</pre><p>Tente agora rodar gulp no terminal, o comando deve demorar mais do que o normal, já que ele irá carregar antes o babel.</p><p>Agora, vamos começar a escrever nosso formatador, ele será um formatador de cpf na qual receberá um input, e irá devolver o input formatador se for válido, ou o próprio input se não for um cpf válido.</p><p>Vamos primeiro escrever o teste, abra o cpfFormatter.spec.babel.js e vamos adicionar os primeiros testes.</p><pre>&quot;use strict&quot;;</pre><pre>import chai from &#39;chai&#39;;<br>const expect = chai.expect;<br>const should = chai.should;<br>const assert = chai.assert;</pre><pre>import cpfFormatter from &#39;../app/formatters/cpfFormatter.babel&#39;;</pre><pre>const cpf = new cpfFormatter();</pre><pre>describe(&quot;cpf formatter&quot;, () =&gt; {</pre><pre>  describe(&quot;formating&quot;, () =&gt; {<br>    it(&quot;should return format cpf correctly&quot;, () =&gt; {<br>      let result = cpf.format(&#39;1111111111&#39;);<br>      let expectedResult = &#39;111.111.111-11&#39;;</pre><pre>      expect(result).to.be.equal(expectedResult);<br>    });</pre><pre>    it(&quot;should return same cpf as input&quot;, () =&gt; {<br>      let result = cpf.format(&#39;11111111111&#39;);<br>      let expectedResult = &#39;111.111.111-11&#39;;</pre><pre>      expect(result).to.not.equal(expectedResult);<br>    });</pre><pre>    it(&quot;should return a empty string if input is undefined&quot;, () =&gt; {<br>      let result = cpf.format(undefined);<br>      let expectedResult = &#39;&#39;;</pre><pre>      expect(result).to.equal(expectedResult);<br>    });<br>  });<br>});</pre><p>Com nossa primeira suite escrita, podemos começar a escrever nosso validador, iremos utilizar o class, do ECMAScript 6. Abra o cpfFormatter.babel.js.</p><pre>&quot;use strict&quot;;</pre><pre>export default class cpf {<br>    format(input) {<br>        let output;</pre><pre>        // Insira os códigos abaixo desse comentário<br>        <br>        return output;<br>    }<br>}</pre><p>Vamos pensar agora como iremos fazer esse formatador baseado nos testes que temos até agora. Primeiro teste e o mais fácil de cumprir, é caso o input seja undefined, parece um caso raro, porém, pode te causar muito problema se acontecer, e não custa nada. Vamos adicionar um if para se for undefined:</p><pre>if(!input) {<br>    return &#39;&#39;;<br>}</pre><p>Rode o gulp test, e veja que agora a primeira case do seu formatador está funcionando. Vamos agora à segunda mais fácil, se o input não for um cpf válido. Para simplificar as coisas, vamos considerar um cpf válido aquele que tiver 11 dígitos. Então vamos lá:</p><pre>let inputChars = input.toString(); // Melhor garantir né?</pre><pre>if(inputChars.length === 11) {<br>    // Próxima sessão irá adicionar o código aqui<br>} else {<br>    output = input;<br>}</pre><p>Rode gulp test mais uma vez, e já estamos quase lá. Falta agora só formatar o cpf, iremos utilizar o método substr, que recebe os parâmetros a posição na string, e a quantidade de caracteres.</p><pre>output = inputChars.substr(0,3) + <br>    &quot;.&quot; +<br>    inputChars.substr(3,3) + <br>    &quot;.&quot; +<br>    inputChars.substr(6,3) + <br>    &quot;-&quot; +<br>    inputChars.substr(9,2);</pre><p>Pronto, nosso formatador está pronto com testes.</p><p>Agora que tudo está pronto, e você pode utilizar o que aprendeu aqui em outros projetos. Se você ainda assim quiser ver mais exemplos, dentro do repositório existe mais uma suite de teste. Se ainda assim você quiser mais exemplos, entre em contato comigo que posso explicar mais exemplos.</p><p>Obrigado por ter lido até aqui. Até a próxima!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a29e9e4f25c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How moving from Design to Back-end made me a better Front-end]]></title>
            <link>https://joaomarcuslf.medium.com/back-to-2011-my-mother-said-d87dee1847e6?source=rss-9b9d2073f10f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d87dee1847e6</guid>
            <category><![CDATA[design]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[thoughts]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[João Marcus Fernandes]]></dc:creator>
            <pubDate>Fri, 29 Jul 2016 04:25:50 GMT</pubDate>
            <atom:updated>2016-09-27T23:52:05.076Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vN1nPaTkbJAzxEaZCdRc3g.jpeg" /></figure><p>Back to <strong>2011</strong>, my mother said:</p><h4>&quot;You stay too much on internet, you should do some course&quot;.</h4><p>That’s when I first started on web as web designer. The era that Flash(RIP for Lord’s sake) was the new black. HTML and CSS was my very best-friend, and the real pain maker. JavaScript wasn’t mature enough, or <strong>I wasn’t mature enough to understand it’s powers</strong>.</p><p>Tired of all this thing, I began studying other languages, like Ruby, began learning REST concepts, Databases integration, and all the HTTP talk. Everything was fine, seeing the black window with white letters telling me that the system was fine, like I was on Matrix. My <em>Designer side</em> began to scream, louder and louder, until I’ve understood that Both sides, are opposite and at the same time friends, they are focused on different things, but have the same goal.</p><p>That was when I decided, <strong>&quot;I will become the integration of both, I will become front-end&quot;</strong>, that is almost poetry, but the truth is, being the front-end means, being the integration, being half-designer so you can understand new patterns and apply, like Responsive Design, and being half-developer so you can understand, maintain and integrate the client with the server.</p><p>To be a good front-end, you must understand that every stage has it&#39;s importance, even if you like design more than development, or the opposite. You may know that if there is no communication beween the extremes, there will be only chaos.</p><p>Hope this text help you with your team, hope it help you see that been front-end is delicate. If you are a Back-end or Designer, or any other area, that text is for you too, watch out of you are depreciating some stage, a divided team tends to lose every play.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d87dee1847e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>