<?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 Ivan Gonzalez on Medium]]></title>
        <description><![CDATA[Stories by Ivan Gonzalez on Medium]]></description>
        <link>https://medium.com/@igonzalez_46712?source=rss-8d4967915111------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BNOUII_1N3qBiAoQ.</url>
            <title>Stories by Ivan Gonzalez on Medium</title>
            <link>https://medium.com/@igonzalez_46712?source=rss-8d4967915111------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:48:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@igonzalez_46712/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[A Code Refactor]]></title>
            <link>https://medium.com/entelo/a-code-refactor-39479f08215f?source=rss-8d4967915111------2</link>
            <guid isPermaLink="false">https://medium.com/p/39479f08215f</guid>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ivan Gonzalez]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 20:53:19 GMT</pubDate>
            <atom:updated>2018-04-17T20:53:19.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLr0_xZYdqCOe3isfwR52Q.jpeg" /></figure><p>I was recently tasked with adding the ability to change an owner id on a template on creation and, subsequently, to add the ability to modify the id after creation as well. I worked on the task and was able to get the functionality that I wanted. But after submitting it for code review, I was lucky to have a colleague point out some places where the code could be refactored to make it easier to understand and to make it more maintainable. On my first stab at the task, I started off in the controller which included a method to create a template. Originally, the <strong>create_campaign_template</strong> method took just an id as an argument I modified it to also take a object which when present would be the user who would become the new owner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*lJDWpO_wu-MhXF9lVrB6Vg.png" /></figure><p>The user that was passed in to the create_campaign_template method was looked up by the controller using an email string that was passed in from the client, if no user was found the value was defaulted to nil. That method would go ahead and delegate the work to the Creator object. There I would check to see if a User object had been passed in, if it had I went and checked that it had certain authorizations, then if those conditions were met I would go ahead and reassign.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*bLc1oZTxnPJ6A8eCw2fN3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*2cfQH-xBv4pvX93f4lW-wA.png" /></figure><p>At this point the code worked and it did what we wanted it to do, but I had broken the single responsibility principle. The Creator object now not only had the task of preparing an object for creation, but it also had to check if the object needed to be reassigned and then went ahead and did the reassignment. It also violated the Open/Closed principle by adding a new concept that the object did not need to know about thereby making it more difficult to extend. These were good indicators that another object could be abstracted from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*Py4C_pihQRXxielryoSwNw.png" /></figure><p>So I created a new Assigner object that removes some of the unnecessary responsibilities from the Creator. In the Assigner object I go ahead and make the assignee email string perform the user lookup, which was previously done by the controller. The Assigner also goes ahead and checks for the conditions that indicate that it is ok to reassign and because they are made in the context of the assignment they are communicated more clearly. After the first go through, the Assigner was in charge of wrangling data to look the way it needed it to look, checked to make sure the reassignment was possible, and did the reassignment. This felt like a bit too much responsibility. So I decided to go ahead and extract an Assign object out of the Assigner; the Assign object would simply perform one clear operation and that would be to assign stuff.</p><p>After going through the refactor the objects in the code maintain <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility</a>, follow the<a href="https://en.wikipedia.org/wiki/Open/closed_principle"> Open/Closed principle</a>, and are also <a href="https://en.wikipedia.org/wiki/Liskov_substitution_principle">Liskov Substitutable</a>. I mentioned an example of single responsibility earlier when I talked about the Creator object originally being in charge of the reassignment. This is important because an object with a single responsibility is easier to debug; when we start giving it more responsibility we give it more room for error. After the refactor, the Objects that were previously there and ones that were created during the rewrite are open for extension but closed for modification. This is accomplished by keeping their scope narrow, they only know what they need to know and only perform one task. This means that it needs no modification but, if later on, new checks needed to be performed during assignment they could easily be added on in an intuitive location.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39479f08215f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/a-code-refactor-39479f08215f">A Code Refactor</a> was originally published in <a href="https://medium.com/entelo">Entelo Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CypressIO: a Reason For Cautious Optimism in the World of Testing]]></title>
            <link>https://medium.com/entelo/cypressio-a-reason-for-cautious-optimism-in-the-world-of-testing-d503911fd5c6?source=rss-8d4967915111------2</link>
            <guid isPermaLink="false">https://medium.com/p/d503911fd5c6</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ivan Gonzalez]]></dc:creator>
            <pubDate>Wed, 28 Feb 2018 23:25:40 GMT</pubDate>
            <atom:updated>2018-03-01T00:33:49.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vAWustrzoB7bGspk_Po16A.jpeg" /></figure><p>My first experience with Integration testing came in a project that used Selenium. I was pretty impressed by what Selenium could do — watching it execute my tests on browser was pretty exciting. However, as I got further into the project I started having issues that made creating and maintaining tests frustrating. A couple of sources of frustration for me were the flaky tests, the long debugging process, and the sloppy and untrustworthy work arounds. Recently at Entelo, I was introduced to Cypress.io and it has been pretty eye opening. After writing my first couple of tests, I believe that Cypress addresses my major gripes about Selenium and that helps distinguish it from Selenium.</p><p>The differences between Selenium and Cypress can begin to be seen at the architectural level. Selenium exists outside the browser and executes commands remotely across the network. This means that the script running the tests can never be in the same run loop as the events that are being triggered in the browser, leading to flakiness and other common issues that Selenium users usually gripe about.</p><p>In contrast, Cypress “is the exact opposite”. It executes inside the same run loop as your application giving you more useful information as the tests run. This is possible because Cypress employees a NodeJS server process that it uses to handle events that are coming from outside the browser and is in constant communication with this process to synchronize and to help each other perform tasks. Cypress also does work on the network layer by reading and modifying web traffic dynamically in order to prevent outside code from disrupting the test automation process. Also, since Cypress is installed locally it can leverage the operating system to perform tasks like taking screenshots and recording video. Cypress claims that these architectural distinctions help it produce more consistent results and, in my very limited experience, I can say that it feels true.</p><p>One of the biggest issues with Selenium was that the debugging process was tedious, it would often take a couple of guesses to figure out what was causing a test to fail. Cypress, however, is much more user friendly in this regard and not by accident. Cypress includes a myriad of detailed error messages that describe what led your test failure. This reduces friction and makes it easier for developers to add it to their workflow rather than thinking of these tests as an after thought. On top of the error messages, Cypress provides access to the Chrome Dev tools which can give you very valuable details while debugging tests. These tools may help with validating a query selector in real time or checking that the network request you expected to see go out was the one that actually went out.</p><p><a href="http://recordit.co/DPYy0lcrNj">http://recordit.co/DPYy0lcrNj</a></p><p>If you’re already comfortable with Dev Tools, this will make it easier to solve issues with your tests and it also helps lead to more stable tests which is a big priority if they are going to be part of your CI cycle. As you speak with people who have used Selenium for a non trivial project, you will hear horror stories about tests that sporadically fail and can only be fixed by adding or reducing time on wait functions, which leaves the developers feeling dirty and scared that tests might fail again at inopportune times. This concern is also taken care of by Cypress, they have the waiting mechanisms built in which reduces the developers responsibility is a positive way. Another great feature of Cypress, is that as you hover on the instructions executed from the sidebar you can see what element was accessed on the webpage and it even restores the state to the moment when the instruction was executed to give you a clearer picture of what might have gone awry.</p><p>So far my experience with Cypress has been very positive. Now that I’ve written a couple of tests, I have been able to see the power of Cypress first hand and I am very excited. This is not to say that Cypress is a silver bullet, it does have a few drawbacks when compared to Selenium. Currently Cypress only runs with Chrome which is an issue if you are concerned with cross browser compatibility. Also since Cypress executes on the browser it can only run Javascript and there are no plans for this to change so people coming from other languages might be discouraged. Still, Cypress provides a viable alternative to Selenium and it is more equipped to handle a modern site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d503911fd5c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/cypressio-a-reason-for-cautious-optimism-in-the-world-of-testing-d503911fd5c6">CypressIO: a Reason For Cautious Optimism in the World of Testing</a> was originally published in <a href="https://medium.com/entelo">Entelo Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>