<?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 Ervi Aguilera on Medium]]></title>
        <description><![CDATA[Stories by Ervi Aguilera on Medium]]></description>
        <link>https://medium.com/@ervi.aguilera?source=rss-a99b8a9120b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_Tf8yS_xgS7SjfZzIK7pLA.jpeg</url>
            <title>Stories by Ervi Aguilera on Medium</title>
            <link>https://medium.com/@ervi.aguilera?source=rss-a99b8a9120b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:37:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ervi.aguilera/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[JavaScript basic concepts we always tend to forget right in the middle of the interview]]></title>
            <link>https://medium.com/@ervi.aguilera/javascript-basic-concepts-we-always-tend-to-forget-right-in-the-middle-of-the-interview-ce8e065576a7?source=rss-a99b8a9120b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce8e065576a7</guid>
            <category><![CDATA[tech-interview]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-interview]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <dc:creator><![CDATA[Ervi Aguilera]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 13:27:14 GMT</pubDate>
            <atom:updated>2024-11-09T13:27:14.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2UdhpWD8-kMjgJea.png" /><figcaption>From: <a href="https://dev.to/harshkc/a-swiss-army-knife-blog-for-js-variables-var-or-let-or-const-1cd1">https://dev.to/harshkc/a-swiss-army-knife-blog-for-js-variables-var-or-let-or-const-1cd1</a></figcaption></figure><p>Let’s face it, starting to work with JavaScript is very straight forward, it’s easy to learn how to make it work, it doesn’t ask for much, you can forget about data types and classes if you will, <em>not saying that you should</em>.</p><p>We tend to go through the career without even thinking how it really works! around 8 years ago I applied for a job as a Web UI Developer, I was convinced that I new JavaScript for the simple reason that I had been working with it since I graduated from college 4 years before that, oh boy, I was so wrong!!!</p><p>In that tech interview I felt like I didn’t know anything about coding, concepts like scope, hoisting, this, closure, were so strange to me. I did get that job, I think the guy that interviewed me could see some potential in me, and here I am, almost 9 years later, working with the same company that I’m so grateful about.</p><p>Now, I’m on the other side, I am the one interviewing candidates and trying to see their potential, but, I see now, that most of the people applying don’t really know how JavaScript works, <em>I knew I wasn’t the only one</em>.</p><p>So, I want to help you, because I truly want you to get the job you want and I want you to show your potential in that tech interview. So, let’s start:</p><h3>What is Scope?</h3><p>Well, the scope is the scope, the very same word tells you its definition, the scope is the context in were a variable can ‘live and work’, that’s it.</p><p>Seems simple right? it actually is, the variables live in the context they’re declared:</p><ul><li>If you create a variable outside any function then it lives in the <strong>global scope</strong>, <em>it’s a global variable</em>.</li><li>If the variable is declared inside a function, then it lives in the <strong>function scope</strong>, <em>it’s a local variable</em>.</li><li>If the variable is declared inside a brackets block, then it lives in the <strong>block scope</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*vBzyzCNxMKa-VeRvSbTc1A.png" /><figcaption>Global Scope, Function Scope, Block Scope</figcaption></figure><p>The scope also states for what is the reach of a variable and where can be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2jfRmcLjy-XCXU_uNAQYQ.png" /></figure><p>Along with scope, there’s also a great concept which, if you manage to understand it, it will help you improve your code at the moment and it’s going to save you a lot of headaches.</p><h3>What is Hoisting?</h3><p>Hoisting is a fairly “new” concept, It was introduced since es6 back in 2015 <em>(9 years?!! oh my, OK not so new I guess…), </em>and it’s actually a way of naming some JavaScript execution contexts.</p><p>It’s not rare to find JavaScript being defined as an interpreted language, and it is, and it’s not, It’s actually a <strong><em>just-in-time</em></strong> compiled language, this means it gets compiled while executing.</p><p>It’s here in this moment, where our little friend Hoisting appears, when the compilation and execution are working together.</p><p>When the code it’s being compiled all variable declarations and functions are allocated in memory, this means, they get assigned a space in memory, without taking in count their assignment nor content, <strong><em>it just want the name at this point</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*M7zZXTlNu_YbhEULGApvzQ.gif" /><figcaption>Let’s sort this out</figcaption></figure><p>Then, when the execution takes place the code gets reread line by line and whenever a declaration is found, the name that was previously saved in memory gets a value, and that’s the reason why you’d get an <strong><em>undefined</em></strong> if you use a <strong><em>variable</em></strong> before it’s declared and assigned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*PNoruBqcOpSVGgT9m09Wdg.gif" /><figcaption>aha! there it is.</figcaption></figure><p>So, I’m sure you’d have heard the hoisting definition that says “<em>hoisting is when the variable declarations are moved to the top of the code</em>”, and, let’s say it’s an easy way of looking at it, but in reality <strong><em>your vars are never actually moved from where they were declared in code.</em></strong></p><p>Now, if all that is true, why is it that when I try to use my <strong><em>const</em></strong> and <strong><em>let</em></strong> variables before their declarations I get an error? Well, lets dive a bit into it.</p><h3>The difference between Const, Let and Var</h3><p>This is a must in all UI interviews, the difference between those 3 is the hoisting and the scope. I’ve already told you about <strong><em>var</em></strong>, now let me tell you about <strong><em>const</em></strong> and <strong><em>let</em></strong>.</p><p><strong><em>Const</em></strong> and <strong><em>Let</em></strong> were introduced as a standard in es6 back in 2015, so the same time as hoisting, these two types of variables came to the UI devs to help us with all the problems we had with Var, being Var global-scoped, we could find all kind of issues when, by mistake, the vars got reassigned out of its original intended scope.</p><p>They are block-scoped, this means they exist in the block were they’re declared, you could use them inside a block, a function, a class but that’s it, they won’t go to the global scope, <em>unless your global scope is just that class</em>. So let’s see them work with a simple example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*T6MzPRn2eQ9yT0z3SsSddA.png" /><figcaption>A big nope</figcaption></figure><p>Here we have different types of variables, using the different scopes. As you can see we we try to access a <strong><em>const</em></strong> before it’s initialization we get an error. This means this variable doesn’t exist yet so we have to wait a bit. Let’s remove this <em>console.log</em> and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*aMZp4l6dFvK-yGtx0BZfkQ.png" /><figcaption>No way Jose!!!</figcaption></figure><p>Here we have another example, we have now a <strong><em>block scope</em></strong> <strong><em>let</em></strong> that we can use inside the block, but we can’t use outside of it, this means that this variable only exists inside the block scope, kinda shy right? let’s continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*VQXa1we_JIfP3_THFh0Itg.png" /><figcaption>Now we’re talking</figcaption></figure><p>Great, we fixed all the errors and now we can see what we did, as you can see we could use <strong><em>let variable</em></strong> <strong><em>functionLet</em></strong> inside a block, because this is still part of the block scope, also we could modify our <strong><em>global scope var a</em></strong> inside of the class!</p><p>This last bit it’s why we need to be careful with global scope variables, because we could make a really big mess, don’t worry too much, we have ways to control this, have you heard about something called <strong><em>immutability</em></strong>? that’s a fun one, but we’ll talk about that on the next article, this one already is way too long.</p><p>Tell me, what funny stories you have with these ones?</p><p>Happy coding everyone! and remember, <em>life is what happens while you’re debugging and trying to solve the bug you can’t find.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce8e065576a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TDD or BDD… What’s your flavor?]]></title>
            <link>https://medium.com/globant/tdd-or-bdd-whats-your-flavor-8be8d0a1b202?source=rss-a99b8a9120b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8be8d0a1b202</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ervi Aguilera]]></dc:creator>
            <pubDate>Thu, 17 Feb 2022 19:20:31 GMT</pubDate>
            <atom:updated>2022-04-06T13:52:54.183Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Ab7g5jOB_5D6jqDPDJjvw.png" /><figcaption>Let’s test first! Taken from: <a href="https://brandnewbox.com/notes/2020/01/test-driven-development/">https://brandnewbox.com/notes/2020/01/test-driven-development</a></figcaption></figure><p>Very recently I was asked to give a series of talks about Unit Testing at work, I must say, I’m not an expert by any means, but throughout my career I have done my share of unit testing, so I guess I’ve learned a thing or two.</p><p>While researching for these talks,<em> just to be sure that what I was telling was true</em>, I realized Jasmine is a BDD framework, which makes total sense if you’ve worked with it. So, it made me think, not many people know about development methodologies, this <strong>definitively</strong> had to be one of the subjects I had to talk about.</p><h3>Let’s start with the basics, what is a software development methodology?</h3><p>A methodology per se, is a series of previously established steps to follow in order to achieve a goal or objective, then, a software development methodology is about the steps and techniques to approach the development of a software.</p><p>There are several methodologies you could follow when developing a project, currently the most known would be TDD <em>Test-Driven Development</em>.</p><h3>What is Test-Driven Development?</h3><p>Simply said, it’s development based on tests, it’s a cycle where a test is built to fail and, according to the results, a function is built to make the test succeed, then a new test is made to fail and the cycle starts again.</p><p>Write test -&gt; Fail -&gt; Code -&gt; Success -&gt; repeat until everything is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uCrJjYw6xKTQHz6l0y-kww.png" /><figcaption>It’s just a cycle. From: <a href="https://www.kamui.co.uk/2018/07/01/test-driven-development-tdd-a-practical-example/">https://www.kamui.co.uk/2018/07/01/test-driven-development-tdd-a-practical-example/</a></figcaption></figure><p>Another methodology, a bit similar, is BDD Behavior-Driven Development, development based on an expected behavior, clear? Not so much? Let’s see.</p><h3>What is Behavior-Driven Development?</h3><p>BDD is an approach where the objective is to fulfill a group of acceptance criteria. Here, the tests are built to verify predefined, discussed and accepted criteria the project must comply.</p><p>It’s a cycle where a test is built to fail and, according to the results, code is built to make the test succeed, then a new test is made to fail and the cycle starts ag… uh?</p><p><em>WAIT! isn’t that the same as TDD?</em> well… kind of(?)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*BXB6ivD0m8EZMsy5.jpg" /><figcaption>Confused?</figcaption></figure><h3>It’s all about what you want to test.</h3><p>You see, the main difference between these two approaches is the test goal and how we get to know what that goal is, and that’s it, just that, seriously.</p><p>The criteria on which the BDD tests need to be based, should reflect the expected functionality from the end users perspective, so we need a <strong>whole</strong> team, this means Stakeholders, Project Manager, Technical Leader, Business Analyst, Designers, Developers, QA team, yes, all the team.</p><p>In practice this could translate to:</p><ul><li>As an end user I would like to see an app that calculates different basic operations for two given values.</li><li>The app should display buttons for numbers from 0-9; and each button should trigger the display of given number when clicked.</li><li>The app should display buttons for operators +,-,*,/; and each button should trigger the display of given operator when clicked.</li><li>The app should comply to the next UX guidelines: …</li><li>And so on…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*xiW0s2vztTJKY-Y7GE2kXw.png" /><figcaption>We all have ideas. Taken from: <a href="https://itsadeliverything.com/specification-by-example-versus-behaviour-driven-development">https://itsadeliverything.com/specification-by-example-versus-behaviour-driven-development</a></figcaption></figure><p>Sure, you very much could define acceptance criteria without the Dev and QA team, but from my perspective, I’d never underestimate the insight a Jr Dev might give, the best ideas can come from places you least expect them to come, remember ratatouille?</p><p>On the other side TDD doesn’t necessarily need a whole team, one Dev could be more than enough, why? because with TDD the goal is to test isolated pieces of code, and make sure they work as they’re supposed to work. Putting this into code it would mean:</p><ul><li>I need a function that should sum two values.</li><li>I need a function that should multiply by two values.</li><li>And so on…</li></ul><h3>Are they mutually exclusive?</h3><p>Absolutely not, you could test that your whole code actually fulfills the user story acceptance criteria, while at the same time, test that the different sections of the code fulfill their own different purposes.</p><h3>So, Which one is better?</h3><p>Good question, these two approaches while similar in steps, are intended for different objectives. So, as one of my favorite mentors always says “It depends”, BDD could be considered as the evolution of TDD, I personally like to see it as a complement for TDD.</p><p>Where BDD could take more time to start while the acceptance criteria are defined and for the same reason it becomes more complicated, TDD is more a hands on approach, so it’s generally faster and easier when done well.</p><p>TDD helps you to test your code but, because it is isolated code, you might not get to test the interaction with the rest of the code, whereas with BDD you can be sure your whole code delivers what the client is expecting to get, because you’re testing the different parts of your code interacting with each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*tXmpo0E31YSXThc-pAhkNQ.png" /><figcaption>We’ve all been there.</figcaption></figure><p>Personally, I like to use both, BDD for the whole user story, TDD to define my functions and classes, is that too weird?</p><p>So, tell me, TDD or BDD, what’s your flavor?</p><p>Happy coding everyone! see you next time and remember, <em>life is what passes while you’re debugging and trying to solve the bug you can’t find.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8be8d0a1b202" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/tdd-or-bdd-whats-your-flavor-8be8d0a1b202">TDD or BDD… What’s your flavor?</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Testing, a necessary evil?]]></title>
            <link>https://medium.com/globant/unit-testing-a-necessary-evil-9630322240e4?source=rss-a99b8a9120b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9630322240e4</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Ervi Aguilera]]></dc:creator>
            <pubDate>Wed, 02 Feb 2022 17:47:02 GMT</pubDate>
            <atom:updated>2022-04-06T13:52:45.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*kDvkZFmmsMxC1E9f.png" /><figcaption>Oh boy</figcaption></figure><p>Imagine yourself happily coding, in your own world, sending pull requests to the team for review, when a dreadful phrase comes up from the technical lead <strong>“We need to do Unit Testing”</strong>. Oh the pain, the anger and fear, <strong>“Is it really necessary?”</strong> you ask, just to get answered by a simple yes.</p><p>I think we’ve all been there in some time of our professional lives, being asked about doing the coverage of the code you just did and tested several times locally before commit, You’re pretty sure it’s bulletproof. I just can hear my QA friends laughing in the back of my head.</p><p>With time I’ve learned to like and respect this testing side of coding, I’ve seen the benefits of it in my own code over time. I must admit, I hated it too, going over and over again just to make some silly tests pass, trust me, with time you’re going to at least learn to respect them too, or not, that’s your call.</p><h3><strong>So why should we test our code?</strong></h3><p>I have to write code to test the code I just wrote? seems a bit redundant if you ask me, right? well yes, but no.</p><p>You see, making sure your code is well designed not only gives you an assurance, it actually reduces the amount of times the QA team could be sending back your user story because of some bug, to me that’s a big win; and let’s be honest, It’s pretty cool when the leads tell you ‘nice code’ after you submit a pull request.</p><p>A well designed code should be the standard, error management, strong typing, etc. These are things a well built unit test can help you achieve.</p><h3>When is a good time to do unit testing?</h3><p>Ideally before the testing phase, you can do unit testing before coding, while coding or after the project is finished, just hopefully before it goes to production, please.</p><h3>Let’s get a bit technical, what is the structure of a unit test?</h3><p>You’re going to find several testing frameworks, they all have one thing in common <em>(Or at least the ones I know)</em>, They all follow the AAA pattern, not that AAA, It’s the <strong>A</strong>rrange, <strong>A</strong>ct, <strong>A</strong>ssert pattern.</p><p>This pattern simply put says, each step results in the input for the next one, <em>assert(act(arrange())).</em></p><p><strong>Arrange</strong>: Sets up the input or configuration you need for the unit you’re testing.</p><p><strong>Act</strong>: As it says, execute the unit.</p><p><strong>Assert</strong>: Verify that the result you got is the one you were expecting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*KvKnIworeXDct5sUluZo1Q.png" /><figcaption>Arrange, Act, Assert</figcaption></figure><h3>What cases should be tested?</h3><p>At least the happy path, but to really be a pro, you should test not only that, but the sad path too, send some crazy parameters to your function and see what happens, what is it returning? is the returned result the one you were expecting? Is it failing? why? Do you have conditionals in the function, promises, observables, callbacks? are you testing all the paths your function has?</p><p>It’s not about just the coverage percentage, remember, you want to make sure your code is bulletproof and, fingers crossed, QAproof.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ozEfjrlzviN5Fi1xJpqLUQ.png" /><figcaption>Something seems to be missing here</figcaption></figure><h3>Unit tests are about code design</h3><p>Most of the time a failing test or a code that’s getting really hard to test, are signs that the code is poorly designed and needs improvement.</p><p>A well defined function shouldn’t be so hard to test after all the needed configurations are set, well defined parameters should help you send the correct values to succeed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*R32rYKkYpqEHjlOujyjbmg.png" /><figcaption>If we’re not validating parameters types the function will fail and so the test</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*0HaBU85HZXfjFQe0b9vfBQ.png" /><figcaption>If we do, then we should be ‘forced’ to send the right values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*kJQyLwPOIIUebnslgQlQxw.png" /><figcaption>Much better</figcaption></figure><p>This is a very simple example, but imagine having to test a callback hell or heavily nested conditionals, not so simple now, huh?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlqM4KNQ5IhnFNISPjXHmQ.png" /><figcaption>No, thank you, nope.</figcaption></figure><h3>So, Which framework to use?</h3><p>As they say, it depends, there are several frameworks available nowadays that can help you succeed with your testing, which one should you use? I couldn’t pin one down for you. All depends on how is your project structured, what UI frameworks you’re using, what language, libraries, components, architecture, etc, etc, etc.</p><p>The most popular out there would be Jest, Jasmine and Mocha. Jest is a very complete framework for testing usually implemented in React and in small projects, Jasmine also comes with a full content and is usually found in Angular projects since it’s already installed with Angular CLI, if you have a complex project maybe Jasmine would be the best for you; Mocha with Chai helps you a lot when testing the UI, let’s say you have a project with polymer components, that’s your guy.</p><p>At the end of the day it all depends on your project and your preferences, they all have pros and cons but something they have in common is that they will help you test, a lot easier, your code.</p><h3>In conclusion, should you test your code?</h3><p>My answer is yes, always, even if it’s boring, even if it takes you a bit more time, the benefits are something to take in count. Unit testing helps you code better, design better, have a better architecture, and you can be sure your code will do the task it is supposed to do.</p><p>So don’t be afraid of a few tests, if you find something to improve, why not? just improve it. We are in this world to learn and enjoy, remember <em>life is what happens while you’re debugging and trying to solve the bug you can’t find.</em></p><p>Happy coding everyone! and see you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9630322240e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/unit-testing-a-necessary-evil-9630322240e4">Unit Testing, a necessary evil?</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>