<?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[Entelo Engineering - Medium]]></title>
        <description><![CDATA[Entelo: Get the latest HR, technology, and recruiting insights on our blog - Medium]]></description>
        <link>https://medium.com/entelo?source=rss----39efb5891372---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Entelo Engineering - Medium</title>
            <link>https://medium.com/entelo?source=rss----39efb5891372---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 22:22:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/entelo" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why You Should Make Everyone a Project Lead]]></title>
            <link>https://medium.com/entelo/why-you-should-make-everyone-a-project-lead-f167472b580d?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/f167472b580d</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[team]]></category>
            <category><![CDATA[management-and-leadership]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[management]]></category>
            <dc:creator><![CDATA[João Antunes]]></dc:creator>
            <pubDate>Wed, 24 Apr 2019 15:51:49 GMT</pubDate>
            <atom:updated>2019-04-24T15:51:49.491Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jbVo1P763tm6cm3iswJnNw.jpeg" /><figcaption>Photo by <a href="https://www.flickr.com/photos/159535053@N06/">Christopher Mance</a> on <a href="https://www.flickr.com/">Flickr</a></figcaption></figure><p>In this blog post, I’ll describe my latest approach to improving morale and growing the team when facing a more challenging quarter. It is not a one-size-fits-all solution and it might not be well-suited to other teams or other types of roadmap, but it was successful for my team and could be for yours too.</p><p>Before we start, let me give a little bit of context. At the beginning of the last quarter (Q4), I took on the role of Engineering Manager (EM) of the team responsible for the two most prominent and user-facing Entelo products, Search and Envoy. Q4 is typically the most impactful quarter for the company because due to budget constraints and commitments, most prospects prefer to wait until the end of the fiscal year to sign high-dollar deals. This usually translates into a higher effort from product and engineering to accommodate minor (and sometimes major) requests from prospects or trial accounts.</p><h4>Morale</h4><p>Sales renewals are a huge challenge for many SaaS companies, even the most successful ones. Failure to do so, also known as customer churn, can affect not only Annual Recurring Revenue (ARR) but also team morale.</p><p>This is particularly true for startups, where limited resources restrict how many current, new, and future customers can be supported and kept happy. Sales teams, focused on reaching out to prospects and building pipeline, feel the pressure to rapidly replenish churning business with new deals. Customer Success (CS), on the other hand, is forced to prioritize larger customers over smaller ones, risking discontented customers who feel neglected. Even Engineering can become frustrated and disheartened that their efforts ultimately do not produce the expected results.</p><h4>Ambitious roadmap</h4><p>To reduce customer attrition, our CS and Data Science teams partnered up to identify the user actions most strongly correlated with user engagement and customer retention. We then devised a rather ambitious roadmap with several user-facing product enhancements as well as multiple experiments designed to increase user-engagement.</p><p>Some of these features required coordinated efforts between our team and the Infrastructure and Data Science teams to build services that would implement and execute new machine learning models. It’s fair to say that the roadmap called for both intra-team (backend, frontend) and cross-team collaboration (product, design, infrastructure, data science, CS).</p><h4>Communication</h4><p>With so many teams and stakeholders involved, one of the main challenges was keeping everyone (or at least the decision-makers) up-to-date on the status of the several roadmap items to anticipate any roadblocks as soon as possible. It was imperative that the overall status of any feature could be regularly determined in a quick and accurate manner to avoid unexpected delays that could jeopardize the execution of the roadmap.</p><h4>Quality</h4><p>Another challenge my team faced was improving our relationship with CS. Being an agile and high-performing team, we are used to ship fast and, sometimes, break fast. We typically rollout big features internally first, and then phase them out to the customers. With the goal of getting a Minimum Viable Product (MVP) out of the door quickly, we sometimes don’t spend as much time and resources as we’d like in thorough testing, in particular on our internal releases to CS users. As a consequence, our CS team grew frustrated when bugs popped up in newly rolled out features.</p><p>We had a challenging quarter ahead of us.</p><h3>Make everyone a leader</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fpIWJycDvG-w6Htx" /><figcaption>Photo by <a href="https://unsplash.com/@slelham?utm_source=medium&amp;utm_medium=referral">Steven Lelham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There were many times I succeeded and there were also times I failed, but even in the face of failure I kept trying out new things until I finally found success. The times I learned the most, performed the best, and overall had the most fun, were when I was given extra responsibility and was pushed out of my comfort zone.</p><blockquote>“When people are given purpose (vision), autonomy (decision making and growth ownership) and mastery (functional ownership), they can reach decisions based on their expertise and what would fit best to the team’s values.”<br> — Oren Ellenbogen [<a href="https://leadingsnowflakes.com/">Leading Snowflakes</a>]</blockquote><p>Typically, we do this before promoting an individual: we put them in a position where they need to informally perform a new role with new responsibilities. Once they “prove” they can perform the new role at an acceptable level, they are officially promoted. This is a very common promotion approach designed to avoid the <a href="https://en.wikipedia.org/wiki/Peter_principle"><em>Peter Principle</em></a>, in which employees are continually promoted based on their success at previous roles and until they reach a level at which they are no longer competent. Promotions, and the extremely valuable growth opportunities that come with it, are, however, rare events (e.g., once a year or every two years) and as such they are given away very sparingly.</p><h4>Why not provide team members with increased responsibilities and growth opportunities more often?</h4><p>If your team is craving for growth, give them those opportunities. Don’t wait for promotion season to groom a few chosen ones, who are probably not the ones in greater need of learning opportunities. Push your team out of their comfort zone into roles of higher responsibility. Do it to <em>all of them</em>, so they can learn from their successes and failures together.</p><blockquote>Highly empowered employees showed engagement levels in the 79th percentile, whereas disempowered workers rated in the 24th percentile for engagement. [<a href="https://www.forbes.com/sites/joefolkman/2017/03/02/the-6-key-secrets-to-increasing-empowerment-in-your-team">Forbes</a>]</blockquote><h4>Project Leads</h4><p>Given the nature of our ambitious roadmap and the challenges ahead, it seemed natural to give everyone on the team a little more responsibility. Responsibility gives people a higher sense of commitment and motivation. With this in mind, we introduced the concept of Project Lead.</p><p>For each larger feature or User Story, an engineer was chosen to lead its design and implementation, and to coordinate its execution with other stakeholders (engineers, product managers, designers, marketing, etc). The size and complexity of each project can vary, but at a minimum they require a one-week effort involving more than one engineer. We believe that if it takes less than one week, then it’s probably too simple to take advantage of a Project Lead.</p><blockquote>Businesses with a strong learning culture enjoy employee engagement and retention rates around 30–50% higher than those that don’t. [<a href="https://www.roberthalf.co.uk/press/employers-fear-45m-workers-could-be-move-year"><em>Robert Half</em></a><em>]</em></blockquote><p>In addition to the design and implementation, each Project Lead also had to make sure their project was on the right track to be integrated into production, which lead us to come up with the acronym <strong>SFM</strong>:</p><p>Status updates: The Project Lead became the central point of communication for their designated project, which, from the EM and PM standpoint, made determining the current status of a project straightforward. This shifts the burden of piecing together the progress or delays of multiple tasks from each of their several contributors from the EM and PM to the Project Lead, who now also has the responsibility of understanding the entire scope of the project and to be well-informed at every step along the way.</p><p>Feature flags: The Project Lead makes sure every major feature is available through feature flags, so we can control how to roll out the feature to our customers, as well as how to roll it back if needed.</p><p>Metrics: To track the impact of each feature, Project Leads must add support for metrics (e.g., <em>statsd</em>, controller or user events, etc.). This will allow us, in future quarters, to understand which feature we should further work on, eliminate, or leave as-is.</p><p>We also provide the Project Leads with the necessary support and resources. At any point, they have the autonomy to schedule short 30-min meetings with anyone on the team to discuss any parts of the project. Preliminary brainstorming sessions with the EM and Team Leads are highly encouraged, as are meetings with any experts outside the team.</p><p>Furthermore, to ensure high quality standards, each Project Lead is granted a 30-min testing session with the entire team. This provides the Project Lead with very early feedback on large portions of the functionality and thus allows them to rollout a much more robust version for the internal release. Having a more stable first version allows CS to uncover harder-to-find bugs and avoids some of the frustration that comes from using a prematurely released feature.</p><blockquote>In the end, it was the experience of leading a project, any project, of being given a leadership opportunity and the responsibility that comes with it, that made this a successful growth experience.</blockquote><h4>Elect, Don’t Select</h4><p>Picking the right Project Lead for a given project is no trivial task. Everyone has their own interests, which could lead to some pretty strong opinions about who should lead which project. We aim to be as democratic as possible, but we also know that we can’t accommodate everyone’s first choice.</p><p>At first, I asked each team member to privately share with me their top choices, so I could try to match Projects with Project Leads. I would then ask them (not tell them) if they would like and agree to lead a particular project. If the project they were elected to lead was their first choice, it was a plus, not a requirement.</p><p>Having a wide variety of projects to choose from (8–10 projects for 6 Project Leads) certainly helps, but ultimately, I think what made this a success was that everyone on the team, from Junior to Senior, was a Project Lead of at least one project. In the end, it was the experience of leading a project, any project, of being given a leadership opportunity and the responsibility that comes with it, that made this a successful growth experience.</p><blockquote>Failures can be partial successes, but only if we learn from them.</blockquote><h4>Project Retrospectives</h4><p>At Entelo, we foster an engineering culture that encourages experimentation with new approaches to achieve ambitious goals (even if they end up failing). This safe environment, together with our exciting roadmap and increased responsibilities, makes the team feel both supported and eager to see what they can accomplish.</p><p>Naturally, success is the ultimate goal, but saying that a project succeeded or failed may be too simplistic. Failures can be partial successes, but only if we learn from them. And even successful projects can hide partial failures, which, if not reviewed and understood, may reoccur in future projects.</p><blockquote>“By asking why five times and answering it each time, we can get the real cause of the problem.”<br>–Taiichi Ohno (Architect of the Toyota Production System)</blockquote><p>A popular tool from the Agile methodology used to review past actions and learn from them are Retrospectives. A week after the project is released, the Project Lead schedules a team meeting to review and discuss the project’s implementation and results. These meetings are also lead by the Project Lead, who walks through the project’s timeline, important decisions, and outcomes. After all the facts are laid out, the team discusses what went well (and should be repeated in future projects) and what didn’t go so well and could have perhaps been prevented. Sometimes, when we need to drill into the root cause, we might even employ the <a href="https://en.wikipedia.org/wiki/5_Whys"><em>Five Whys</em></a> strategy. Information and transparency is key in leading a good retro.</p><p>It is crucial to keep in mind that Project Retros are not performance review hearings. They can provide valuable feedback and constitute one of the best learning tools, but only if everyone is candid, respectful and checks their egos at the door.</p><h3>A Quarter Full of Promising Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZx4w0TzAHsUWhwC" /><figcaption>Photo by <a href="https://unsplash.com/@japhethmast?utm_source=medium&amp;utm_medium=referral">Japheth Mast</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Project Leads have an increased responsibility to lead the design and implementation of the solution, but they are also empowered with a great deal of autonomy. They decompose the project into smaller tasks, choose who should collaborate on it and even assign those tasks. They are the key figures who know the status of the project at all times. When the Project Leads take on a project, they are owning it and committing themselves to its success.</p><p>There’s also an implicit trust placed in them, which further drives their engagement. They don’t want to let anyone down, especially themselves. The project they lead becomes part of them and this is a very powerful motivator.</p><blockquote>Let them fail. But be there by their side when that happens to help them get back up.</blockquote><h4>Growth Opportunity</h4><p>Being a Project Lead can be more or less challenging, depending on the complexity of the project and the engineer’s experience. In some cases, it could really bump the engineer out of their comfort zone. For instance, junior engineers, accustomed to taking on smaller tasks during Sprint Planning, might find it hard to scope the project and decompose it into smaller tasks. Even a more seasoned engineer might struggle with other parts of the role, like cross-team collaboration or communication. And even if you’ve managed a Sprint or a project before, the more times you do it, the better you’ll get at it.</p><blockquote>42% of employees say learning and development is the most important benefit when deciding where to work. [<a href="https://about.udemy.com/ideas-and-opinions/2018-millennials-at-work-research-report/">Udemy</a>]</blockquote><p>It’s important to note that having an accepting and supportive culture is paramount. Depending on the Project Lead’s experience, their new role may be overwhelming, so it’s important to provide them with the necessary support and understanding. This includes checking-in on them periodically and allowing them to ask for help at any point. And, as long as it doesn’t negatively impact the company or their career, let them fail. But be there by their side when that happens to help them get back up.</p><h4>Recognition</h4><p>A project carries the weight of a larger, independent feature. With the responsibility of being the one in charge of its execution, the Project Lead also feels a sense of pride and gratification in delivering it. At Entelo, every contribution to the product is recognized in many ways, from an email from the Product Team to all employees announcing the newly released features, to a mention by the CEO in the company-wide Week-In-Review presentations on Fridays. The Project Lead is always at the head of the list of contributors that made that project come to life.</p><p>At the end of Q4, we couldn’t be happier with the results. We successfully completed our roadmap, including seven Projects (lead by their respective Project Leads). It might be a bit unfair to compare the productivity of different quarters as many different factors are at play and roadmaps can vary greatly, but in the end, the team considered this one of the most productive quarters to date.</p><p>Project Leads have been highly motivated, engaged and committed. They have learned how to scope and plan the execution of a Project, as well as how and when to collaborate with other stakeholders to get results. From a management point-of-view, delegating some of these responsibilities to the Project Leads was a very efficient reallocation of resources and alleviated our work. From a Project Lead perspective, it was a fulfilling experience in which they felt more involved and learned more than in previous quarters.</p><p>Have you used a similar strategy with your team? What other ways to motivate and grow your teams have you used? Let us know in the comments below.</p><p>Also, if you’d like to know more about Entelo or our Engineering Team, please visit <a href="https://sourcecode.entelo.com/">SourceCode</a>, our blog about engineering in the recruiting industry.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f167472b580d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/why-you-should-make-everyone-a-project-lead-f167472b580d">Why You Should Make Everyone a Project Lead</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[Entomology: The Art of Classifying Bugs]]></title>
            <link>https://medium.com/entelo/entomology-the-art-of-classifying-bugs-fce44224565f?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/fce44224565f</guid>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Alan Ridlehoover]]></dc:creator>
            <pubDate>Mon, 22 Apr 2019 17:08:48 GMT</pubDate>
            <atom:updated>2019-04-22T17:08:47.888Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*id40lCIJeM3-U7QTtAKwDA.png" /></figure><h4>Classifying bugs correctly helps customers, engineers, and everyone in between.</h4><p>All software contains bugs. Period. Some bugs require immediate attention, once discovered. And, some bugs aren’t worth fixing at all. How you differentiate between the two makes all the difference inside and outside of your Engineering department. This is how we do entomology at Entelo…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sArCaftIGPpv4chDlpAGEg.png" /></figure><h3>A Framework for Classifying Bugs</h3><p>We classify a bug by <strong><em>severity</em></strong> and <strong><em>scope</em></strong> in order to assign it a <strong><em>priority</em></strong>.</p><ul><li><strong><em>Severity</em></strong> is a measurement of a bug’s impact on the usefulness of the software. A high severity bug significantly curtails the user’s ability to derive value from the system. A moderate severity bug limits a user’s access to a major feature. And, a low severity bug is a minor nuisance, but not blocking use of any features.</li><li><strong><em>Scope</em></strong> is a measurement of the number of users impacted by the bug. The more users affected, the broader the scope. The fewer users affected, the narrower the scope.</li><li><strong><em>Priority</em></strong> is used to set expectations between departments (and with our customers) as to when an issue will receive attention. Essentially, a priority level is shorthand for a service level agreement and the actions we take in response to a bug.</li></ul><p>We define priority levels as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVVBbnSjpe872LuBXPr85A.png" /></figure><p>A few notes on scope:</p><ul><li>If we think a bug affects all users, we treat it as such until we discover otherwise. If we discover that, in fact, the bug did not affect all users, we will downgrade the bug as appropriate.</li><li>If we can reproduce a bug, we treat it as though at least a subset of users (some) are affected, even if only a single user has reported the issue.</li><li>If we cannot reproduce a bug that was reported by a single user, we treat it as such.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*exXYPT7YLmPDP30k7E_Ijw.jpeg" /></figure><h3>Service Level Agreements</h3><p>We define our default service levels as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JdM9uW5355Ms6lmZs6EbvA.png" /></figure><p>Note that “receives attention” means that the Product team will prioritize and the Engineering team will look into the bug within the specified time frame. It does not promise resolution within that time. Some bugs are harder to fix than others.</p><h4>Adjusting Service Levels Based on Circumstances</h4><p>For the vast majority of bugs, the default service level should be fine. But, from time to time, we may encounter an issue that requires more urgent attention than the default SLA affords. Specifically, the Product Manager may decide (in consultation with Customer Success) to prioritize a bug sooner than the SLA would warrant, based on the presence of one or more aggravating circumstances, including but not limited to:</p><ul><li>The bug affects our relationship with a strategic customer.</li><li>The bug affects the renewal of a large account.</li></ul><p><em>It is important to note that </em><strong><em>aggravating circumstances only affect a bug’s SLA. </em></strong><em>They do not change a bug’s priority level, since priority levels govern the type of response Engineering is required to undertake for SOC 2 compliance. This is important because the additional overhead associated with P0 and P1 bugs means that Engineering can actually resolve more P2 bugs than P0 and P1 bugs in the same amount of time.</em></p><h3>Conclusion</h3><p>Actually, this is just the beginning. We’ve just rolled out the framework across the company. Our hope is that it will reduce communication friction between departments by setting priority levels objectively, based on severity and scope.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fce44224565f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/entomology-the-art-of-classifying-bugs-fce44224565f">Entomology: The Art of Classifying Bugs</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[Making Sense of Your Rails Monolith]]></title>
            <link>https://medium.com/entelo/making-sense-of-your-rails-monolith-ea54692241c3?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/ea54692241c3</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Alan Ridlehoover]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 01:05:56 GMT</pubDate>
            <atom:updated>2019-09-06T04:59:53.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WVrTALm0K4A2sryjRcZ2DQ.png" /><figcaption>Photo by Soloman Soh from Pexels</figcaption></figure><h4>How a little abstraction can significantly improve your applications and your quality of life</h4><p>Have you ever wondered why your monolith is so damned hard to work with? There are likely several contributing factors. Often those issues boil down to code that is highly coupled and loosely cohesive. But, what does that even mean? Let’s see if we can figure it out together by looking at some code.</p><p>Here are three classes from the same Rails application that deal with the creation of “Alert” objects. Each class has parameters passed to it in slightly different ways. And, each one does something slightly different in response to the creation of the Alert. But, as you’ll see that they all have the same shape.</p><p>First, here is a controller that receives an HTTP request, creates an Alert and performs one set of actions on success and a different set of actions on failure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2fb88f592e06cf2aa96ec2b42a6406a/href">https://medium.com/media/b2fb88f592e06cf2aa96ec2b42a6406a/href</a></iframe><p>Second, here’s a Worker class that reads messages off a queue, creates an Alert and performs one set of actions on success and a different set of actions on failure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fbec9d9a5f8ef4bd355e20dc77a2ef5/href">https://medium.com/media/6fbec9d9a5f8ef4bd355e20dc77a2ef5/href</a></iframe><p>Finally, here is a Source model that reads items from an RSS feed, creates an Alert and performs one set of actions on success and a different set of actions on failure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3607932071b73f9a187a74f62b47ad09/href">https://medium.com/media/3607932071b73f9a187a74f62b47ad09/href</a></iframe><p>In all three cases, the underlying business logic is “creates an Alert and performs one set of actions on success and a different set of actions on failure.” But, in all three cases that code is intermingled with (or coupled to) infrastructure code that has nothing to do with the business logic, specifically: HTTP responses, queue management, and logging. Furthermore, the fact that the same business logic exists in three different classes means that these classes lack cohesion. There should be one class with that responsibility, not three.</p><p>Our goal then is to invert this pattern. Let’s see if we can refactor our way to a less coupled, more cohesive application and see what that looks like.</p><h3>Refactor 1: Extract LogAdapter</h3><p>The first and most glaring similarity between these classes is the structured logging. Since this logger is external, it is considered infrastructure code. But, it is mixed up with the domain logic, inside the if statements.</p><p>So, let’s begin by extracting an <a href="https://en.wikipedia.org/wiki/Adapter_pattern">adapter</a> from the Source model so that the business logic doesn’t have to speak directly to the ExternalLogger:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db2a62637498086edd925f714d83c753/href">https://medium.com/media/db2a62637498086edd925f714d83c753/href</a></iframe><p>And, now we can use the adapter in the Source model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f4bea80a98550b6566ecf91a22310be/href">https://medium.com/media/4f4bea80a98550b6566ecf91a22310be/href</a></iframe><p>This refactor may seem like a small step. And, it is. But, it has a couple of things going for it:</p><p>First, it is a step toward removing the duplication of the logging code in the three different classes. Eventually, we’ll only have one class that directly talks to the logger. That’s a huge win, especially if we ever decide to change which logging service we’re using.</p><p>Second, the LogAdapter class is now translating between the business logic and the actual API of the ExternalLogger class. In other words, the business logic is no longer directly coupled to the logger. Let’s move on to see how we can remove the indirect reference to the logger as well.</p><h3>Refactor 2: Extract CreateAlertCommand</h3><p>That takes care of some of the infrastructure code that was trapped in the business logic. Now, let’s address the infrastructure code that is trapping the business logic by extracting a <a href="https://en.wikipedia.org/wiki/Command_pattern">command</a> object to create the Alert:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01adf5d9f1c6adcc0420d7956203eaa4/href">https://medium.com/media/01adf5d9f1c6adcc0420d7956203eaa4/href</a></iframe><p>And, here’s the refactored Source model with the command object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/373031b27a6172d81cb8f7add0479fde/href">https://medium.com/media/373031b27a6172d81cb8f7add0479fde/href</a></iframe><p>Note that the adapter has been injected into the command object (on line 8), allowing the command object to rely on an abstraction (the LogAdapter interface) rather than a concretion (the actual LogAdapter class). This is a fine example of the <a href="https://en.wikipedia.org/wiki/Dependency_inversion_principle">Dependency Inversion Principle</a>.</p><p>This completes the second step of our refactor. The LogAdapter and Source model now are complete. Let’s move on to the Worker class.</p><h3>Refactor 3: Extract QueueAdapter</h3><p>Here is the Worker class, again, this time with the LogAdapter:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e356b1ac23a1aca13dea04247af4c64d/href">https://medium.com/media/e356b1ac23a1aca13dea04247af4c64d/href</a></iframe><p>We’d like to introduce the CreateAlertCommand here. But, there’s one more external dependency getting in our way: @message.delete (on line 12). We first need to wrap that dependency in another adapter before we can utilize the command object.</p><p>Here’s the QueueAdapter extracted from the Worker:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2e496b34d63f6ebdda4a97a454d7562/href">https://medium.com/media/a2e496b34d63f6ebdda4a97a454d7562/href</a></iframe><p>There are two things to note here:</p><p>First, look at how little responsibility this class has. All it knows about is how to delete a message. It doesn’t even know when to delete the message. That decision is made outside this class. This is a great example of the <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a>.</p><p>And, second, note that the QueueAdapter satisfies the same interface as the LogAdapter via duck typing. In other words, it has both a command_succeeded and a command_failed method, just like the LogAdapter. That’ll be important in just a few seconds…</p><p>Now, if only we could inject multiple adapters into the CreateAlertCommand:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d94dffacc2be49e6d677552fcbab2557/href">https://medium.com/media/d94dffacc2be49e6d677552fcbab2557/href</a></iframe><p>Here, we are now accepting multiple different adapters into the command object and it is notifying each of them of whether or not the Alert was successfully created. This is the <a href="https://en.wikipedia.org/wiki/Observer_pattern">observer</a> pattern. And, this is why the two adapters need to be duck types.</p><p>Great! Now we can finish this refactor by using the CreateAlertCommand in the Worker:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1de93514f23103c4325b0fb3f6446bcb/href">https://medium.com/media/1de93514f23103c4325b0fb3f6446bcb/href</a></iframe><p>Three down. One to go…</p><h3>Refactor 4: Extract ControllerAdapter</h3><p>The last thing to refactor is the AlertsController. Here it is with the LogAdapter:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22bd3ca168ffd06f141be939e4b361ff/href">https://medium.com/media/22bd3ca168ffd06f141be939e4b361ff/href</a></iframe><p>Here again, we need to extract an adapter in order to hide an external dependency from the domain logic. So, let’s extract a ControllerAdapter:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/529f64ff850dc295795755b6658d1cb4/href">https://medium.com/media/529f64ff850dc295795755b6658d1cb4/href</a></iframe><p>There’s a lot going on here. But, before we unpack it, let’s look at the refactored AlertsController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3edcd3a8083ff6b7f11800b24b3a245f/href">https://medium.com/media/3edcd3a8083ff6b7f11800b24b3a245f/href</a></iframe><p>Ok. So, the first thing to look at is the creation of the ControllerAdapter on line 6, above. Notice that we’re passing self into the adapter. In this context, self refers to the instance of the AlertsController class that is handling this specific HTTP request. So, by passing self into the adapter, we are able to delegate the redirect_to and render methods to it on line 8 of the ControllerAdapter. (Keep in mind that redirect_to and render are both instance methods on the controller.)</p><p>The next thing to note is that we did <strong><em>not</em></strong> have to change CreateAlertCommand in order to extend it to include the behavior provided by ControllerAdapter. All we had to do was inject the new adapter, just like we did before. This is a perfect illustration of the <a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle">Open/Closed Principle</a>, which states that classes should be open for extension, but closed for modification.</p><p>Finally, there is a one last change that can use an explanation: on line 15 of the ControllerAdapter, we changed the line from render :new to render :new, locals: { record: record }. Why? Well, ordinarily, Rails would perform some magic to expose the alert to the view through a controller instance variable named @alert. But, since we’re calling render outside the context of the controller, we can’t do that. So, instead, we are injecting the alert into the view as a local variable called record. This means we’ll need to make a small change to the new alert view to use the local variable, on line 3 below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5724efa83a44c19d0aa27b2baf1d5343/href">https://medium.com/media/5724efa83a44c19d0aa27b2baf1d5343/href</a></iframe><p>We chose record as the variable name to allow us to reuse the ControllerAdapter with other controllers.</p><h3>Summing It Up</h3><p>That’s it! Using <a href="https://en.wikipedia.org/wiki/SOLID">SOLID object-oriented principles</a> and standard <a href="https://en.wikipedia.org/wiki/Design_Patterns">Gang-of-Four design patterns</a>, we’ve taken a fairly traditional bit of Rails code that intermingled infrastructural concerns with business logic and separated the two, leaving us with three distinct layers of software: infrastructure, application, and domain.</p><p>The infrastructure layer is the outermost layer, representing external resources like HTTP requests, queues, databases, etc. In a Rails application, this layer consists of controllers, models, workers, and gems that directly interact with the infrastructure that supports the application (like the ExternalLogger).</p><p>The domain layer is the inner-most layer. This layer consists of all the business logic for the application. These are typically plain old Ruby objects (POROs). And, generally speaking, they should not reference infrastructure classes except through adapters.</p><p>The application layer is the glue that holds the infrastructure and domain layers together. Classes in this layer (also usually POROs) translate between the interface of a domain class and the interface of an infrastructure class, allowing both to remain ignorant of the other.</p><p>This three layered approach is the definition of a <a href="https://declara.com/content/va7eLmgJ">Hexagonal Architecture</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*20NJa-T6zvH-OxhN2VCzaA.png" /><figcaption>Hexagonal Architecture</figcaption></figure><p>In the context of the application we just refactored, the AlertsController, Worker, and Source are all infrastructure classes. The adapter classes belong to the application layer. And, the command class is in the domain layer.</p><p>To which the astute observer would now interject, “Ah, but what about that reference to the Alert class inside the CreateAlertCommand? Isn’t that coupling the domain layer to the infrastructure layer?”</p><p>The answer is yes. And, in a truly hexagonal application we’d need to decouple that code, probably using the <a href="https://www.martinfowler.com/eaaCatalog/repository.html">Repository</a> pattern. But, for the work my team and I do, we’ve not yet found this to be necessary. ActiveRecord meets our needs. So, many of our command classes directly reference ActiveRecord objects. We jokingly refer to this as a “Trapezoidal Architecture.”</p><p>In fact, we’re very happy with our trapezoid. The patterns you saw in this post — in conjunction with a <a href="https://engineering.entelo.com/extension-without-modification-cb0f9cfb64a3">self-registering implementation</a> of the GoF <a href="https://en.wikipedia.org/wiki/Factory_method_pattern">factory</a> pattern — allow us to add new business logic to our application by adding a single command class (and the appropriate tests). We rarely have to touch our infrastructure or application layers. As a result, this is a super productive way to work. It has greatly improved developer happiness on our team! We really cannot recommend this approach highly enough!</p><p>This is the way my team writes software. If you’d like to know more about Entelo or our Engineering Team, please visit <a href="https://sourcecode.entelo.com/">SourceCode</a>, our blog about engineering in the recruiting industry.</p><p>I’d like to thank <a href="https://medium.com/u/527732fa0727">Fito von Zastrow</a> for pairing with me on this project. I’d also like to thank <a href="https://medium.com/u/8d4967915111">Ivan Gonzalez</a>, <a href="https://medium.com/u/5024139868ba">Jason Rosendale</a>, <a href="https://medium.com/u/3fb73159892e">Kelly Hale</a>, and <a href="https://medium.com/u/370fd8e65b4b">Ryan A Booth</a> for their clarifying questions, comments, and general encouragement.</p><p>And, thank you! You win a prize for reading this far. Mention this article to me IRL for a free sticker!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea54692241c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/making-sense-of-your-rails-monolith-ea54692241c3">Making Sense of Your Rails Monolith</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[Extension without Modification]]></title>
            <link>https://medium.com/entelo/extension-without-modification-cb0f9cfb64a3?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/cb0f9cfb64a3</guid>
            <category><![CDATA[factory-pattern]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[open-closed-principle]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Fito von Zastrow]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 18:53:35 GMT</pubDate>
            <atom:updated>2019-03-22T18:53:35.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_gzVo-qaqWpv3qYUorceQ.jpeg" /></figure><h4>Build objects that are easily extensible and resilient to change</h4><p>Building software often requires changing and extending existing behavior. This need presents itself in different ways. One example is the need to take different actions depending on some input. This can be a painful process if our code is not prepared for change.</p><p>Let’s look at a concrete example. Imagine we are working on an application in charge of sending notifications to users via an API. When there is only one API to interact with, the following class meets our needs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f28c9f1b2a6201df4514876246b8f2b9/href">https://medium.com/media/f28c9f1b2a6201df4514876246b8f2b9/href</a></iframe><p>If our application is successful, we’ll be required to support multiple channels of communication. No problem, we can modify our class to support multiple channels:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b47186ed5f13191d961b2dc57c30fb6e/href">https://medium.com/media/b47186ed5f13191d961b2dc57c30fb6e/href</a></iframe><p>Our changes satisfy the new requirements. But, our class has taken on new responsibilities. It used to be in charge of one thing only: notifying users via an API. Now, it is also in charge of building the correct API object for the given channel.</p><p>In order to build these objects, our class knows what each one of them requires. Adding support for additional channels will increase the complexity and brittleness of this class. It has too many reasons to change.</p><p>We can improve our design by applying <a href="https://en.wikipedia.org/wiki/SOLID">SOLID object-oriented principles</a> and <a href="https://en.wikipedia.org/wiki/Design_Patterns">design patterns</a>. First, let’s extract the API specifics into small objects, each with a <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">single responsibility</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5c2bae5574a013e41de85702903f745/href">https://medium.com/media/c5c2bae5574a013e41de85702903f745/href</a></iframe><p>Each Messenger object is in charge of interfacing with one API. Now we can change UserNotifier to use these objects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6679fe74b5244cb9360a38f8e7715b10/href">https://medium.com/media/6679fe74b5244cb9360a38f8e7715b10/href</a></iframe><p>Extracting Messenger objects decouples theUserNotifier from the specifics of the APIs.</p><p>UserNotifier no longer knows how to build API objects. It has fewer reasons to change than before. Still, adding new messaging channels results in changes to this class.</p><p>A pattern that’s very helpful when dealing with this type of structure is the <a href="https://en.wikipedia.org/wiki/Factory_method_pattern">Gang-of-Four factory method pattern</a>. Let’s apply it to our code and see what it reveals:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28495b3c1b8cf339a54fa91a1507a733/href">https://medium.com/media/28495b3c1b8cf339a54fa91a1507a733/href</a></iframe><p>Extracting the factory method makes it clear UserNotifier has two responsibilities:</p><p>• Mapping channel types to Messenger objects.</p><p>• Asking the Messenger to deliver a message.</p><p>Since we are trying to minimize the reasons for UserNotifier to change, let’s apply the Single Responsibility Principle and extract the factory method into an object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c57828a0d41ca567996498ec9b75486/href">https://medium.com/media/0c57828a0d41ca567996498ec9b75486/href</a></iframe><p>Then, UserNotifier can delegate to MessengerFactory to build the correct Messenger object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99eea241f62b5dd5f6184efb7d391b6e/href">https://medium.com/media/99eea241f62b5dd5f6184efb7d391b6e/href</a></iframe><p>The UserNotifier no longer knows how to build a Messenger object or what channel they correspond to. It only knows MessengerFactory will return an object that responds to deliver. This is an example of the <a href="https://en.wikipedia.org/wiki/Dependency_inversion_principle">Dependency Inversion Principle</a>, where you rely on abstractions, not concretions.</p><p>The main benefit of extracting MessengerFactory is that UserNotifier no longer needs to change when adding new channels: Adding support for WhatsApp would require a new entry in MessengerFactory::MESSENGER_CLASS and a WhatsAppMessenger class.</p><p>All Messenger classes have the same initialization requirement. Adding a BaseMessenger class removes this duplication, simplifying the addition of new Messenger types:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5871edd9ac0aac66503d892d39da8dcb/href">https://medium.com/media/5871edd9ac0aac66503d892d39da8dcb/href</a></iframe><p>Let’s take a look at what we’ve done so far.</p><p>Our UserNotifier class is in better shape now. However, all we’ve done is move the reason to change from UserNotifier to MessengerFactory. We can do better and completely remove the need for these classes to change when adding new channels.</p><p>A common approach in Ruby is to introduce a convention and use metaprogramming to build factory objects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b782e351a9dc6124aeda64db161f568/href">https://medium.com/media/1b782e351a9dc6124aeda64db161f568/href</a></iframe><p>This approach works for our current requirements, but it has a few pitfalls:</p><p>• It prevents a global search from finding all references to a class.</p><p>• New keys or classes might not fit nicely with our convention: whats_app -&gt; WhatsAppMessenger.</p><p>• Changing a class name requires us to change all references to its corresponding factory key.</p><p>There is a different approach: Factory self-registration. Let’s generalize MessengerFactory so that it no longer references Messenger classes directly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac492cfe674feef994ec7b1a3df0ffba/href">https://medium.com/media/ac492cfe674feef994ec7b1a3df0ffba/href</a></iframe><p>The main change to the MessengerFactory is that it now allows classes to be registered on it. It no longer cares about what type of object it’s building. If it has a corresponding key in its registry, MessengerFactory will build it.</p><p>Now, we want our Messenger classes to register themselves on the factory. An elegant way to give our Messenger classes this ability is via a module:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75aef5a129e5269d18558cd298ca9059/href">https://medium.com/media/75aef5a129e5269d18558cd298ca9059/href</a></iframe><p>We can include MessengerFactoryRegistration in the BaseMessenger and configure a key on each Messenger class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2af2c3bdecf36b3eea8e3087a81e140/href">https://medium.com/media/f2af2c3bdecf36b3eea8e3087a81e140/href</a></iframe><p>Calling the corresponds_to method registers the class on the factory, under the provided key. The correspondence between a class and its key is explicitly stated in the class definition.</p><p>Our MessengerFactory is now <a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle">open/closed</a>: we can extend its functionality without having to modify it. Adding support for WhatsApp requires only a new class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb52231a4cd9555e5dd0ea1ead27a32f/href">https://medium.com/media/cb52231a4cd9555e5dd0ea1ead27a32f/href</a></iframe><p>This approach provides the following benefits:</p><p>• It does not require a convention.</p><p>• Adding a new Messenger class does not require other classes to change.</p><p>• Class names are decoupled from their factory keys. Renaming either one does not require the other to change.</p><p>My team and I use this pattern. Adding new functionality to our application usually only requires adding a new class and its corresponding tests. In fact, we have gotten so much value out of this pattern that we decided to extract it into an open source gem: <a href="https://github.com/entelo/industrialist">Industrialist</a>.</p><p>Industrialist provides the factory and self-registration functionality. All you have to do is configure your base class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52dc8432febfc34b798779c79a7c0b0f/href">https://medium.com/media/52dc8432febfc34b798779c79a7c0b0f/href</a></iframe><p>That’s it! We started by adding complexity to a simple class, giving it multiple responsibilities and multiple reasons to change. Then, we applied the single responsibility principle and the factory pattern to produce a design that’s resilient to changes and easily extensible. I bet each of these classes would be a joy to test as well!</p><p>This is the way my team writes software. If you’d like to know more about Entelo or our Engineering Team, please visit <a href="https://sourcecode.entelo.com/">SourceCode</a>, our blog about engineering in the recruiting industry.</p><p>I’d like to thank <a href="https://medium.com/@aridlehoover">Alan Ridlehoover</a> for introducing me to this pattern and pairing with me on it. I’d also like to thank <a href="https://medium.com/@ram_selvan">Vijay Ram</a> for his clarifying questions and comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb0f9cfb64a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/extension-without-modification-cb0f9cfb64a3">Extension without Modification</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[10 Lessons Learned Extracting a Service from a Monolith]]></title>
            <link>https://medium.com/entelo/10-lessons-learned-extracting-a-service-from-a-monolith-535a15c6d277?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/535a15c6d277</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Alan Ridlehoover]]></dc:creator>
            <pubDate>Sat, 15 Dec 2018 00:02:30 GMT</pubDate>
            <atom:updated>2019-01-24T00:55:51.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fjILAnGqbbPAvkPfZOzvg.jpeg" /></figure><p>My team and I just built a new messaging service to replace an aging subsystem in Entelo’s primary application. We modeled the service on real life concepts, simplifying the data model considerably, in order to unlock new features. Here are ten things we learned along the way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sK91Kl5Bbq53rlb7B823GQ.jpeg" /></figure><h3>Our worst-case, most pessimistic estimate was wildly optimistic</h3><p>Our most conservative guess as to how long it would take to complete the project was three months. It took ten.</p><p>To be fair, we estimated that the entire team would take three months to complete the work. But, in reality, we split our time between this project, ongoing maintenance, and various new features. So, given half the resources, the original estimate was more like six months.</p><p>That said, most of the underestimated work was related to disentangling the existing subsystem from the rest of the monolith. What started out as a search for references to classes owned by the subsystem, turned into a search for raw SQL queries that referenced the underlying database tables. That’s how tightly coupled the subsystem was to the rest of the app.</p><p><strong>Lesson learned: </strong>Pay attention to all the integration points between the subsystem you are extracting and the rest of the system. There’s likely more work there than you think.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*guLE4Bn4D6agTo9CGxFXLQ.jpeg" /></figure><h3>Build a moat around the subsystem in the monolith</h3><p>In his book <em>Working Effectively with Legacy Code</em>, Michael Feathers recommends finding seams within the software, where you can insert yourself and add tests. And, in his book <em>Domain Driven Design, </em>Eric Evans described the Anti-corruption Layer Pattern as a means of inserting a façade or adapter between two subsystems to prevent them from bleeding into each other.</p><p>So that’s what we did: we wrapped a façade layer around our subsystem within the monolith. This allowed us to route all requests from the rest of the system through the façade before hitting our subsystem. By adding that layer to the system, we were able to write integration tests for the subsystem that needed to continue working even after we switched over to the new service.</p><p>As mentioned above, this was by far the most difficult piece of extracting the service. Pulling half of a raw SQL query behind the façade and integrating the results with the rest of the query is time consuming work.</p><p><strong>Lesson learned: </strong>When constructing an application, whether building a monolith or a service oriented architecture, it is important to maintain boundaries between subsystems. This is the only way to keep your application pliable, so that subsystems can be refactored to make room for interesting new features without affecting the rest of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssSUmPxy6XQzhgJwvz7FHA.jpeg" /></figure><h3>Run both systems in parallel</h3><p>We ran both systems in parallel for months as we brought the new service up to feature parity with the old subsystem. We could do this because we created the façade mentioned above. When a request came into the façade, we could send it to both the service and the subsystem, compare the results, and check for (and fix) data inconsistencies before cutting over. It also allowed us to test the new service infrastructure against production traffic as a real-world stress test.</p><p><strong>Lesson learned: </strong>We found most of our bugs by running production traffic through the new service before switching over to it. Though, this did cause an increase in complexity within the façade, we believe that the confidence gained in the new service justified the cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KvC1rhBKQlzOxLhmvLieOw.jpeg" /></figure><h3>Use feature flags to stage rollout</h3><p>A feature flag is a boolean value that can be turned on to enable a feature, or turned off to disable the feature. Typical feature flag systems allow you to turn the flag on for a subset of your users. This allows you to roll out functionality gradually, rather than all at once.</p><p>Our implementation used four separate flags:</p><ul><li>One flag controlled whether or not to write to the new system. This allowed us to run the systems in parallel. We turned this flag on very early in the process, giving us the benefits described above.</li><li>Another flag controlled whether to read data from the legacy subsystem or the new service. This allowed us to turn on the new service for our team in order to test the validity of the data being returned before turning it on more broadly.</li><li>The last two flags controlled which system could access our third-party email providers. One flag turned off the legacy subsystem. The other turned on the new service. We separated these flags so as to allow us to turn both systems off in the event that we detected a serious flaw in the process. (Thankfully, we did not end up needing this functionality. But we are glad we took the time to prepare for the worst case scenario.)</li></ul><p>The last advantage of using feature flags is that we were able to roll out the new service in a way that was least disruptive to the business. For example, my team was able to do internal testing before asking everyone else at Entelo to help out. And we were able to gradually roll out the changes to our customers in the order that made most sense to the customer facing teams.</p><p><strong>Lesson learned: </strong>Use separate feature flags for writing to and reading from the new service. This allows you to begin running the service in parallel with the legacy system. And, in our case, adding the extra flags to prevent duplicate emails from being sent was critical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7Cjf2so0p9UUQvBRw7SDQ.jpeg" /></figure><h3>Add logging, exception handling &amp; monitoring early</h3><p>One of the first things we built inside the new service was a logger. The logging and exception handling turned out to be crucial when debugging the system — especially across the service boundary. And, later, adding monitoring allowed us a window into our data import process. We were able to do this easily because every operation that logged data did so via our centralized logger.</p><p><strong>Lesson learned: </strong>Centralize your logging and exception handling, and build it early. You’ll thank yourself later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SWKJr5EEDxXCk0QGs-F9A.jpeg" /></figure><h3>Expect issues migrating your data</h3><p>In order to be able to present historical data without having to query both systems, we decided to port our old data to the new service so that all data requests could eventually be served from there. The vast majority of the data migrated over correctly. But there were multiple valid edge cases. Each time we would figure out one of the edge cases, we would adjust the migration.</p><p>In the end, we had about 700 records (out of 1.2M) left over that we could not explain. The vast majority were several years old. Basically, this data did not fit any of the corner cases we’d identified and resolved. Rather than sinking more time into it, we decided to mark these records as “failed” and move on — but not before we’d spent days whittling that number down as low as we could.</p><p><strong>Lesson learned: </strong>Production data is sloppy. Most of it will look correct. Some of it will not. The older the data, the harder it is to migrate. Records will be missing. Foreign keys won’t exist. Just roll with it. Make the best, most user friendly decisions you can.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Wxd4mnyvNnReCrgBgf7bg.jpeg" /></figure><h3>Use deterministic UUIDs and idempotent migrations</h3><p>When you have two different systems running in parallel, you need a shared id space. Any UUID will do. But we chose to use deterministic UUIDs in order to support idempotent migrations. A deterministic UUID is one that is generated from underlying data, typically a namespace and a unique id. Given the same data, the algorithm always produces the same UUID.</p><p>In our case, the façade in the main application generates these UUIDs based on the data that makes the record unique in the legacy system. Then it sends the UUID to the service for storage. Inside the service, we then indexed the UUID field with a uniqueness constraint preventing duplicates. This makes idempotency possible. Whenever we get a uniqueness constraint violation, we know that the record already exists.</p><p><strong>Lesson learned: </strong>Given how unpredictable your data will likely be, you will probably need to run your migrations multiple times as you adjust them to handle corner cases that arise out of your existing data. Using a deterministic UUID makes this possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmGaCiWXxeLzWzLz3HbQBA.jpeg" /></figure><h3>Use queues</h3><p>Introducing a new service means introducing another point of failure. In order to protect ourselves from minor service outages, we decided to communicate with the service via a queue. This granted us a bit of fault tolerance, given that the queue will likely remain up even when the service goes down. We also specifically chose a FIFO queue in order to guarantee the order of operations, so that an update never precedes a create or follows a delete.</p><p><strong>Lesson learned:</strong> Using a robust queue allows you several advantages, including the ability to monitor traffic into your service. Plus, should you need to handle more traffic, just scale up the number of workers listening on the queue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lc7V5wp_kSLOjoMBGEHfnw.jpeg" /></figure><h3>Use circuit breakers</h3><p>If you are going to read data from a service asynchronously via a queue, your user interface needs to be able to respond to the server pushing data to it (probably via a socket). Unfortunately, we did not have time to rebuild the front-end of our application to work this way. So, we chose to use HTTP for read operations. This worked well, until it didn’t.</p><p>During testing, a bug in the deployment process took the new service down and with it the entire staging environment for the main application, since we were preloading some state from the service when the user first hit the site. The solution was to implement the circuit breaker pattern.</p><p>This pattern retries failed calls a certain number of times, then gives up and returns something reasonable (nil in our case) for all subsequent requests during a cooldown period. When the cooldown period expires, the circuit breaker begins to call the service again. If it’s back up, great. If not, the circuit breaker trips again preventing additional calls to the service that is down.</p><p><strong>Lesson learned:</strong> If you must use HTTP for communicating with your service, make sure that the calling application does not fail in the event that the service is down. Circuit breakers are one mechanism to prevent this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7q0tKXySyCBsgP47KNhgQ.jpeg" /></figure><h3>Executive Sponsorship</h3><p>The success of long term projects often comes down to executive sponsorship. We were fortunate that both our VP of Product and our VP of Engineering were on board with our plans. They put a great deal of trust in us. And when the project began to look bigger than we’d planned, they stood by us. We could not have completed our work without their support.</p><p>Why were our executive sponsors willing to go to bat for us? Several reasons. But one of the most important is that we were open and honest in our communications with them. They knew where the project was and they knew what was left to do.</p><p><strong>Lesson learned: </strong>When embarking on a long-term, high risk project, make sure you have the support of your leadership. Make sure they fully understand the benefits as well as the risks. And, communicate continuously. It builds trust, which you’ll need if you’re going to succeed.</p><h3>What would we do differently?</h3><p>We thought we did our due diligence before proposing the project. We found every reference to the models used in the subsystem. But we did not search for direct references to the underlying table names in raw SQL statements. That was an oversight. We will definitely do that next time.</p><p>If we could go back in time even further, we would advocate for isolating the subsystems <em>WITHIN</em> the monolith. Doing so would have greatly simplified the extraction process, and perhaps even made the extraction unnecessary, since we would have been able to safely refactor the subsystem in place.</p><h3>So, would we do it again?</h3><p>It was a long journey, for sure. Extricating our subsystem from the monolith turned out to be a whole lot more difficult than we thought it would be thanks to some truly epic coupling. We did that work out of necessity. It was not enjoyable work. It felt like a chore.</p><p>On the other hand, working with the new service is a dream. The code is very well factored. We have super high test coverage. And, there is a one-to-one relationship between use cases and “operation” classes, making it clear what the application does in response to specific requests without having to spelunk through controllers and models to piece it together. Extending the service is just a matter of adding another operation and writing some tests.</p><p>Would we do it again?</p><p>As engineers? We would definitely do it again. The project led to improvements in developer happiness and productivity. The trade-off was worth it for us in terms of job satisfaction alone.</p><p>As an organization? Given the length of the project, we need to see a very strong return on our investment before making additional large scale bets on service extractions.</p><p>Stay tuned…</p><p>If you’d like to know more about Entelo or our Engineering Team, please visit <a href="https://sourcecode.entelo.com/">SourceCode</a>, our blog about engineering in the recruiting industry.</p><p>I’d like to thank <a href="https://medium.com/u/527732fa0727">Fito von Zastrow</a>, <a href="https://medium.com/u/5024139868ba">Jason Rosendale</a>, <a href="https://medium.com/u/370fd8e65b4b">Ryan A Booth</a>, and <a href="https://medium.com/u/fc4dbb683df8">Cole Goeppinger</a>, all of whom made invaluable contributions to this article.</p><p>And, thank you! You win a prize for reading this far. Mention this article to me IRL for a free sticker!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=535a15c6d277" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/10-lessons-learned-extracting-a-service-from-a-monolith-535a15c6d277">10 Lessons Learned Extracting a Service from a Monolith</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[Casting a Wider Net]]></title>
            <link>https://medium.com/entelo/casting-a-wider-net-cad2403ab2de?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/cad2403ab2de</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[diversity]]></category>
            <dc:creator><![CDATA[Kelly Hale]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 17:31:03 GMT</pubDate>
            <atom:updated>2018-10-25T17:31:03.106Z</atom:updated>
            <content:encoded><![CDATA[<h3>An Overview</h3><p>In 2013, Tracy Chou, an engineer at Pinterest, published a <a href="https://github.com/triketora/women-in-software-eng">Github repository</a> report on the alarming stats of women in engineering. A wave of tech-company diversity disclosures soon followed and today many tech companies have adopted the practice of publishing Diversity Reports.</p><p>It almost goes without saying that hiring diverse workforces is notoriously difficult. While it is typically tech companies that make headlines in this regard, tech is far from alone. Many companies have a hard time hiring a diverse workforce, and simply finding candidates is often the first and most challenging problem recruiting teams encounter. Entelo builds products to help recruiters achieve their hiring goals, so this challenge of identifying and engaging diverse talent is very much in our wheelhouse.</p><p>Our flagship product, <a href="https://blog.entelo.com/announcing-entelo-diversity">Entelo Search, has provided diversity filters since 2014</a>, but we’re always looking for new ways to improve our coverage. The challenge is that verifying a person’s membership in a given demographic category is often difficult and time consuming. So the question becomes, how can we help our customer discover profiles of people who likely belong to a given group in a way that is both automated and doesn’t make too many assumptions.</p><p>Entelo has over 500 million candidate profiles, many of which contain a lot of information about educational backgrounds and professional associations. In his book, <a href="https://www.amazon.com/Inclusion-Recruiting-Secrets-recruiting-workforce/dp/1495237567">Inclusion Recruiting: The 12 Secrets to recruiting a diverse workforce</a>, Darrell James, an executive with over 20 years of experience in recruiting, lays out, among other things, a fairly comprehensive list of professional associations, networks, colleges/universities and Greek organizations that specifically serve underrepresented groups within many industries. Drawing from these lists is one example of a way we’re able to compile a vetted list of organizations with memberships that tend to be self-selecting.</p><p>It becomes fairly trivial then to create a process that parses the data contained within our profiles, identifies listed membership in an association from the list and marks the profile accordingly with a field that represents an aggregation of a specific category of network. For example, profiles that list membership in sororities or women in tech organizations would be marked with a field for “women’s organizations”, whereas profiles that state that they’re alumni of a Historically Black College, would be marked with “African American/Black organizations”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/0*IxNZ80CMGB6OSQ48" /><figcaption>Entelo profile insights, highlight professional networks</figcaption></figure><p>In the example above, we don’t necessarily know the demographic categories that the person attached to this profile occupies, but we do know that said person has identified herself/themself as being part of a women’s professional organization. Profiles marked with this data are then ingested into our elasticsearch cluster, where a field identifying membership in a given “diversity network” is added to the to a profile’s ES document. This field can be searched upon directly, or included as part of a more general diversity query.</p><h3>Two Ways to Search</h3><p>Labeling profiles with diverse network fields allows for us to offer two different diversity search experiences to customers. The first is through our established diversity filters, which when paired with our new diverse network setting, allows the customer to specify whether they’d like any given diversity search to include people that identify as belonging to an organization focused on the advancement of minorities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*JreNFAJbAq31aM0G" /><figcaption>Diversity Setting enabling the use of diversity networks in search</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/0*EbbGGHuizeiopXxE" /><figcaption>Entelo Search’s diversity filter dropdown</figcaption></figure><p>The second, is to search directly for profiles with a specific diverse networks field. For example, if a recruiter was looking for an engineer and was using sorority membership in college as a way of hopefully finding a female candidate, their search query might look something like the following:</p><blockquote>(“Alpha Chi Omega “ OR “Alpha Delta Chi “ OR “Alpha Delta Pi “ OR “Alpha Epsilon Phi “ OR “Alpha Gamma Delta “ OR “Alpha Kappa Alpha “ OR “Alpha Kappa Delta Phi “ OR “Alpha Kappa Phi Agonian “ OR “Alpha Omega Epsilon “ OR “Alpha Omicron Pi “ OR “Alpha Phi “ OR “Alpha Phi Gamma “ OR “Alpha Pi Phi “ OR “Alpha Pi Sigma “ OR “Alpha Sigma Alpha “ OR “Alpha Sigma Kappa “ OR “Alpha Sigma Rho “ OR “Alpha Sigma Tau “ OR “Alpha Theta Beta “ OR “Alpha Xi Delta “ OR “Chi Delta Theta “ OR “Chi Omega “ OR “Chi Sigma Xi “ OR “Chi Upsilon Sigma “ OR “Delta Alpha Theta “ OR “Delta Chi Gamma “ OR “Delta Delta Delta “ OR “delta Delta Phi Zeta “ OR “Delta Gamma “ OR “Delta Kappa Delta “ OR “Delta Phi Epsilon “ OR “Delta Phi Lambda “ OR “Delta Phi Omega “ OR “Delta Pi “ OR “Delta Psi Delta “ OR “Delta Psi Epsilon “ OR “Delta Sigma Chi “ OR “Delta Sigma Theta “ OR “Delta Xi Nu “ OR “Delta Xi Phi “ OR “Delta Zeta “ OR “Gamma Alpha Omega “ OR “Gamma Nu Delta “ OR “Gamma Phi Beta “ OR “Gamma Phi Omega “ OR “Gamma Sigma Sigma “ OR “Iota Delta “ OR “Iota Gamma Upsilon “ OR “Kappa Alpha Sigma “ OR “Kappa Alpha Theta “ OR “Kappa Beta Gamma “ OR “Kappa Delta “ OR “Kappa Delta Chi “ OR “Kappa Delta Phi NAS “ OR “Kappa Delta Sigma “ OR “Kappa Gamma Delta “ OR “Kappa Kappa Gamma “ OR “Kappa Phi “ OR “Kappa Phi Lambda “ OR “Lambda Pi Chi “ OR “Lambda Pi Upsilon “ OR “Lambda Psi Delta “ OR “Lambda Sigma Gamma “ OR “Lambda Tau Omega “ OR “Lambda Theta Alpha “ OR “Lambda Theta Nu “ OR “Mu Sigma Upsilon “ OR “Omega Phi Alpha “ OR “Omega Phi Beta “ OR “Omega Phi Chi “ OR “Phi Beta Chi “ OR “Phi Mu “ OR “Phi Sigma Rho “ OR “Phi Sigma Sigma “ OR “Pi Beta Phi “ OR “Pi Phi Delta “ OR “Sigma Alpha “ OR “Sigma Alpha Epsilon Pi “ OR “Sigma Alpha Omega “ OR “Sigma Delta “ OR “Sigma Delta AAU “ OR “Sigma Delta Tau “ OR “Sigma Gamma Rho “ OR “Sigma Iota Alpha “ OR “Sigma Kappa “ OR “Sigma Lambda Alpha “ OR “Sigma Lambda Gamma “ OR “Sigma Lambda Upsilon “ OR “Sigma Omicron Pi “ OR “Sigma Phi Lambda “ OR “Sigma Phi Omega “ OR “Sigma Psi Zeta “ OR “Sigma Sigma Rho “ OR “Sigma Sigma Sigma “ OR “Sigma Theta Psi “ OR “Tau Sigma Phi “ OR “Theta Alpha “ OR “Theta Nu Xi “ OR “Theta Phi Alpha “ OR “Theta Phi Gamma “ OR “Zeta Phi Beta “ OR “Zeta Phi Gamma “ OR “Zeta Sigma Chi “ OR “Zeta Tau Alpha “) AND position:”engineer”</blockquote><p>But now, thanks to our ability to target profiles with diverse networks directly by field, a recruiter could simply select the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*eiJQI4-_G_gS8hRB" /><figcaption>Entelo Search’s “search by highlights” filter</figcaption></figure><p>Hiring a diverse workforce is challenging, but our hope is that the time and effort associated with sourcing diverse candidates will get easier over time. Heuristics for identifying candidates’ age, race, ethnicity, LGBTQ or veteran status will never be 100% accurate, but are a step in the right direction and give recruiters the means to reliably increase diversity in their candidate pipelines and workforces. With a continued focus on diversity, a bit of creative data analysis, and support from our engineering team, we can enable our customers to cast a wider net and discover great candidates they may not have discovered otherwise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad2403ab2de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/casting-a-wider-net-cad2403ab2de">Casting a Wider Net</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[The Science (and Art) Behind Quantifying Seniority]]></title>
            <link>https://medium.com/entelo/the-science-and-art-behind-quantifying-seniority-9fd3e45c05f?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/9fd3e45c05f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[architecture-design]]></category>
            <dc:creator><![CDATA[Chin Ling]]></dc:creator>
            <pubDate>Fri, 13 Jul 2018 20:22:28 GMT</pubDate>
            <atom:updated>2018-07-13T20:22:27.374Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMwapFi7LvMQLNeHAzgQkg.jpeg" /></figure><p>In a recent article on <a href="https://blog.entelo.com/entelo-women-in-tech-report">Quantifying the Gender Gap in Technology</a> published by <a href="https://medium.com/u/73aeda649930">Elena Sigacheva</a>, product manager at Entelo, we presented some very interesting insights and profound findings about gender disparity in technology and how the differences get exacerbated as individuals progressed in their career.</p><p>In this article, I would like to bring you deeper into the nitty-gritty of a core attribute underpinning the above analysis — <em>seniority.</em></p><h3>What is Seniority?</h3><p>There are many ways one could think of seniority. But before I get started, here is a definition given by Wikipedia¹:</p><blockquote>Seniority is the concept of a person or group of people taking precedence over another person or group because the former is either older than the latter or has occupied a particular position longer than the latter. Seniority is present between parents and children and may be present in other common relationships, such as among siblings of different ages or between workers and their managers.</blockquote><p>Since <em>Entelo</em> is primarily a sourcing tool for talent acquisition practitioners, we will be focusing on professional relationships only. Also, such relationship goes beyond superior-subordinate settings, and include levels of experience, expertise, and so on.</p><p>Going back to the Wikipedia abstract, whilst the definition is clear in plain language, it is actually much harder to interpret than it seemed. Let’s just use this phrase as an example — seniority is based on “…a <em>person [who] occupied a particular position longer than the latter.” </em>However, here are some other ways one could also look at seniority:</p><ul><li>By job title and/or role</li><li>Total years of work experience</li><li>Total years of <em>relevant</em> experience</li></ul><p>The second and third factors fit nicely into the definition above. On the other hand, the last factor can be further decomposed into the definition of what constitutes relevancy. For example, relevancy can be based on:</p><ul><li>Recent job title and/or role</li><li>Recent skills and/or cluster of <em>related</em> skills</li><li>Other categorical attributes such as company types, company size, sector, sub-industry, industry, and industry family</li></ul><p>Of course, they do not just end there. Each of the factors may be related to one another, and they may behave significantly different from one dimension versus the other. For example, a <em>Vice President</em> for non-financial industry is considered executive-level but remotely so for the same title in financial industry. Moreover, a <em>Vice President</em> may have a shorter tenure in comparison to a more generalist role such as <em>Software Engineer</em>.</p><p>As you can see, the concept of seniority is complex, even just looking from a definition standpoint.</p><h3>Why is <em>Seniority</em> Important?</h3><p>To truly understand the importance of quantifying <em>seniority</em>, I think it’s insightful to look at it from the angle of <em>why are we doing this</em>, i.e. what are some of the common use-cases and/or problems that we are looking to solve:</p><p><strong>1. Search &amp; Discovery</strong></p><ul><li>User would like the ability to search by seniority, e.g. entry-level, mid, senior and executive</li><li>Prioritize by seniority, e.g. more senior folks first followed by the rest</li><li>Remove over- or under-qualified candidates</li><li>Remove not-relevant candidates, e.g. recruiters in a non-recruiting role often appear in search results due to keyword match hits</li></ul><p><strong>2. Profile (Derived) Insights²</strong></p><ul><li>Identify <em>rising star</em> profiles, i.e. profiles that has a high promotion rate based on years of experience, understanding the concept of promotion is highly dependent on quantifying <em>seniority</em> correctly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*ico_0M60GC-RwtdekPSReA.png" /><figcaption>Figure 1: Example of “rising star<em>” profile</em></figcaption></figure><p><strong>3. Second-order (Derived) Insights</strong></p><ul><li>Recent promotion may (or not) influence <em>More Likely to Move</em>™, one of our core predictive indicator to help user surface profiles that are more receptive to new opportunities within the next 90-days (from the date of evaluation)</li><li>Seniority can also be used to customize candidate engagement experience, for example, one would expect the language around seniority-based opportunity (career progression, higher responsibility, promotional move) would be different from role-based ones (new technical challenges, professional development, exciting (“disruptive”) industry and/or company)</li></ul><p><strong>5. Business Intelligence, Reporting &amp; Analysis</strong></p><ul><li>Overall trends related to seniority, for example by gender, role, sector/industry, and many more</li></ul><p>The above is by no means an exhaustive list, but it serves a strong product-case of the importance of quantifying seniority and do it in such as way that is completely scalable, reproducible and most importantly reusable.</p><h3>Data Representation</h3><p>So, back to the discussion on the definition of seniority and complexity around it, how do we go about representing it in such as way that it is usable given our understanding of some of the use-cases highlighted above? Quoting Wikipedia³:</p><blockquote>In machine learning and pattern recognition, a feature is an individual measurable property or characteristic of a phenomenon being observed…Features are usually numeric…The concept of “feature” is related to that of explanatory variable used in statistical techniques such as linear regression.</blockquote><p>So, as a starting point, it makes valid sense to ensure the features are numerically represented. Fortunately, for most part, they are primarily variations of years of experience, which in itself is already numerical in nature. Narrowing further, we are left with one that is not properly represented, namely the job title itself.</p><p>For the remainder of this section, I will first talk about how to quantify the job title — from fuzzy, free-form textual representation to numerical — then circle back to walking you through some considerations around using years of experience — both total and relevant respectively — to quantify seniority.</p><h4>1. Seniority Score</h4><p>Here, I will introduce a new metric, namely <em>seniority score</em>, to address the job title representation issue. What constitutes a seniority score? What are some of my thoughts around it?</p><p>In aggregate, one can pull a relationship using some of the following attributes (non-exhaustive):</p><ul><li>Years of experience to reach that title</li><li>How long one stays in that title</li><li>At what stage of one’s career would this title usually lands itself</li></ul><p>The above should be able to give us meaningful numbers that for example distinguishes between a <em>Chief Data Scientist</em> and a <em>Junior Data Scientist</em>. It’s worthy to note that some titles are more tricky, for example, I observed that <em>Big Data Engineer</em> has very high seniority score on its own and if compared wrongly, would produce incorrect results.</p><p>Furthermore, it’s important to note that seniority score is of ordinal scale in nature, i.e. “<em>it is the order of the values is what’s important and significant, but the differences between each one is not really known.” ⁴ </em>Also, without additional attributes (e.g. title category, role, sector and industry), the numbers are not very useful by itself, and they are not comparable. In the earlier example, we are able to compare <em>Chief</em> vs <em>Junior Data Scientist</em> as they both fall in the same role, i.e. data scientist, however, one is not able to do the same between <em>Big Data Engineer</em> and generalist <em>Software Engineer</em> (here we define data engineer as a separate/ different than software engineer).</p><p>Additionally, some are less obvious, for example, <em>Software Engineer</em> and <em>Software Manager</em>, the latter would be more senior in comparison but it would carry a lower seniority score under <em>Management</em> title category. Nevertheless, the seniority score as a metric remains a meaningful and reusable feature that we can leverage as a building block for more complex analytics.</p><h4>2. Total Years of Experience</h4><p>How about <em>years of experience to </em>quantify seniority? Besides numerous definitional variation, here, I would like to illustrate some nuances in this attribute:</p><ul><li>Years of experience may be overlapping in between positions/ experiences</li><li>How do we distinguish between real and what’s reported? How about what’s intentional vs. not (due to data error or bug)? <em>Figure 2</em> below presents an example of a profile that reported 117 years of total experience. Now, assuming there is no data error in this situation, it remains likely that this profile intentionally over-inflate its experience, unintentional error in data entry by this individual, no longer active in the social footprints nor employable, or the individual may have been deceased.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*WJTcu1qEXUnyUV6z53Ib_Q.png" /><figcaption>Figure 2: Interpreting what’s reported in the resume data</figcaption></figure><ul><li>Career gap adjustment, detecting it would be tricky if there are overlapping positions</li><li>Senior and/or Executive-level profiles tend to remove older positions/experiences, and hence, potentially deflating it’s total years of experience</li></ul><p>To cater for varying needs, here are some metrics that I have introduced:</p><ul><li>Total years of experience based on sum of each individual position durations</li><li>Based on the difference between evaluation date and graduation date or first position start date</li><li>Similar to above but adjusting for gaps</li></ul><p>It is important to understand that each metrics has their strengths and flaws, and in this situation, its technically not feasible to have a single metric that addresses all the nuances illustrated above. For example, the first metric may inflate the total years of experience calculation due to overlapping experiences mentioned earlier, and the second metric would adjust for that. However, the second metric assumes education information exists in the profile data and/or we have one’s complete work histories, both of which is not true (based on our analysis, only 40% of the profiles have education information reported). In this case, my best bet would be to use the first metric. To give you another example, in situation where the sensitivity and accuracy of the numbers matter s— such as for UI display in <em>Figure 2 — </em>I would recommend a more conservative and aggressive metric, i.e. the one based on difference between evaluation date and graduation date and adjusting for gaps.</p><p>As illustrated, having the metrics at a granular level — with multiple definition of total years of experience — helps as it provides me with ample flexibility for downstream interpretation and use.</p><h4>3. Years of Relevant Experience</h4><p>Next I would like to focus on years of relevant experience, but primarily on one that is based on most recent job title and/or role. As you could imagine, job title itself can be pretty dirty, and different titles may mean the same thing. I have allocated an entire section to talk about this in <a href="https://medium.com/p/9fd3e45c05f#081b"><em>Implementation</em></a> but <em>Figure 3</em> illustrates a profile that has different job title that we would like to somehow still able to mix-and-match and combine to come to the final value for years of relevant experience, i.e. those that corresponds to <em>Software Developer</em> and <em>Software Engineer</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbKhUX154xlioROuzeKnTw.png" /><figcaption>Figure 3: Relevant years of experience with varying job title</figcaption></figure><p>Now, how about the profile shown in <em>Figure 4</em> below? On one hand, some would regard <em>Senior Software Engineer</em> and <em>Backend Software Engineer</em> are categorically relevant, i.e. both are software engineer, and hence should rollup into the calculation. On the other hand, some teams would regard this as different <em>specialization — a </em>generalist vs. a specialist role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*JuCZDJ81BY5W3dZmKcujDw.png" /><figcaption>Figure 4: Senior Software Engineer vs. Backend Software Engineer</figcaption></figure><h3>Visual Representation</h3><blockquote>One Ring to rule them all, One Ring to find them, One Ring to bring them all, and in the darkness bind them⁵</blockquote><p>So, should we take a step further and come up with an ultimate metric that would somehow capture all the above, including but not limited to seniority score, years of experience both total and relevant, etc.? I decided to take a more liberal approach of keeping them at a granular level such that it provides me with plenty of flexibility for downstream use.</p><p>There is another benefit of keeping it separate, this time from a product standpoint. If you look at <em>Figure 5</em>, the visual cue gives us a clean two-dimensional view of the one’s career path, in this case I can see the time spent at each company (potentially numerous title/role) and how their seniority progress (e.g. Mid-level to Mid-level) within each group. Having such expression would enable our user to make an informed holistic view of one’s work experience beyond just the title and years of experience as standalone construct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*pWSsj-lk8SQCS3-1Z86m8Q.png" /><figcaption>Figure 5: Visual representation of seniority</figcaption></figure><h3>Implementation</h3><p>We didn’t arrive at the final implementation on a get-go, a topic worthy of another blog in future. However, we do arrive at two different (but eventually related) approaches — one is offline and the other is online — to service a myriad of use-cases we presented earlier. Before I dive deeper into some technical details of both approaches, it’s noteworthy to talk a little bit about the architecture and guiding principles underpinning some of the design choices made.</p><h4>Architecture &amp; Guiding Principles</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lCl5ZCadtsVAVQxqRIT8Hw.png" /><figcaption>Figure 6: Simplified version of the Data Pipeline Architecture</figcaption></figure><p><em>Figure 6 </em>gives a simplified overview of how our data science data pipeline looks like. We do the majority of our data gymnastics in Databricks/Pyspark environment and placed the output of our data products in the Data Lake (AWS S3). The diagram only illustrates any data that is produced by the Data Science team, from consolidated data to expansive analytics ranging from both descriptive and predictive in nature.</p><p>In turn, derived analytics get brokered to downstream consumer systems in different means, some are directly used to power Entelo website, some are the facilitate retrieval leveraging ElasticSearch, machine-learning based micro-services to perform online scoring and classification, and so on.</p><p>I wouldn’t go too much further into the architectural discussion and some of the decisions made but I do want to end this section with a summary of the core guiding principles that we adopt as we think through implementing a robust data pipeline architecture to help us scale our analytics capabilities:</p><ul><li><strong>Layered Architecture</strong><br>- Each layer has a specific role and responsibility</li><li><strong>Modularity</strong><br>- Focus on domain driven/ intent design, not fields and contracts<br>- Use language of business, not technology — abstraction</li><li><strong>Data Quality</strong><br>- Completeness &amp; Timeliness<br>- No gaps, data always available based on best available information<br>- Breadth — multi-sourced approach<br>- Consistency — taxonomy &amp; naming convention<br>- Etc — Histories, Reusability, Lineage/ Traceability &amp; Replay-ability</li><li><strong>Simplicity &amp; Ease of Maintenance</strong><br>- Decoupling between offline and online requirements<br>- Removal of circular (data) dependencies</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0uCymlxe4jZzAFslTaC20Q.png" /><figcaption>Figure 7: Illustration of Domain-based Data Model and Layering Approach</figcaption></figure><h4>From Raw to Canonical Title</h4><p>We have about 450 million merged profiles in our database, and of those 61% has some positional information such as job title, company name and potentially short summary describing one’s role in that position. Job titles — especially on public footprints— are unfortunately, notoriously dirty and unstandardized. As illustrated in <em>Figure 8 </em>below, we have close to 160 million unique raw titles, many of which are referenced at most only once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*0Ztb-hrqScPY4H5lVRWaBA.png" /><figcaption>Figure 8: Canonical Titles</figcaption></figure><p>Our end goal is to be able to somehow map and associate each position title to it’s smaller and more manageable canonical equivalent. The latter would be much smaller set, but allows us to conveniently group and perform aggregated analysis such as computing average years of total experience for those that carries canonical title <em>Software Engineer</em> versus <em>Director of Software Engineering</em>.</p><p>Here are some of the steps to generate a canonical set of 500k entries given the raw titles:</p><ul><li>Basic clean-up such as punctuations, numbers, whitespaces and unicode characters</li><li>Simple expansion and acronyms. For example Sr. to Senior, Mgr. to Manager, and CEO to Chief Executive officer</li><li>Identify titles that are more frequently used, either leveraging profiles data themselves, and/or usage data based on past job title search patterns</li><li>(Optionally) leverage curators to manually look at the bottom half the sample set to shave off any remaining spurious job titles</li></ul><p>Solution based on these steps are usable, however we could bring this a step further by identifying title clusters, a.k.a. similar titles that may be called differently but meant the same thing. In this situation, the structure of the titles would be not obvious and significantly different, for example, software developer can also be associated with software engineer, hacker, software evangelist, coder, and so on. It’s note-worthy to point out that title clustering is an interesting topic to talk about separately, and there are some really cool machine learning techniques one can use to perform such tasks.</p><p>Now, once you have a smaller predetermined set of canonical titles that in turn you can associate with the original position set, performing aggregation logic to derive some of the metrics mentioned<em> </em><a href="https://medium.com/p/9fd3e45c05f#f8b6"><em>Data Representation</em></a> section should be much easier and robust.</p><h4>Online / Micro-services</h4><p>The above is nice and clean if our data science use-cases only end in having the data in a persistent store or database. At Entelo, our journey as data scientists go beyond just plain simple data analysis nor data engineering/ wrangling with the end results being data at rest.</p><p>One of the use-case that I would like to highlight that I think would be interesting to dive a bit deeper into is “<em>[User would like the ability to] remove over- or under-qualified candidates.</em>” Notice the formulation of this problem statement is quite different from what we have presented thus far — it is a classification problem! So how do we go about doing this (hopefully) without a completely different set of architecture?</p><p>Fortunately, we are presented with couple of options, both of which are built on top of existing functional capabilities, i.e. leverage the 500k canonical titles data product that contains associated seniority scores and other metrics, such as years of experience that we have produced based on the above work:</p><ol><li>Build a service that would take in a list of candidate profiles core information (depending on the model, e.g. most recent job title, years of experience, etc.) and classify each of them as over- or under-qualified given a target job title</li><li>Bring the 500k canonical titles dataset further upstream against the position dataset. Now, you have seniority-related information for every single position that exists in the database that you can in turn use the similar classification approach</li></ol><p>Option 1 and 2 sound similar but boils down to one intricate details, i.e. in the former, the service expects a list of candidate profiles <em>as-is</em>, and in turn, use that to deduce other data points such as seniority score, in real-time. This pose three additional technical challenges:</p><ol><li>Can the service respond in a timely manner?</li><li>How do one map a notoriously dirty and unstandardized title to it’s canonical equivalent, also, in a timely manner?</li><li>How would this approach impact the <em>coverage</em>, another metric to indicate how many of the candidates can we successfully classify as over- or under- vs. those that we do not have any opinion because we can’t do the latter well in the first place?</li></ol><p>Zooming in, I would like to talk a bit more about the second technical challenge noted above. What I have done is to take in the dataset of 500k canonical titles, compute MinHash LSH⁶ against each of the canonical titles and store the results in pickle format in Model Store. On the API endpoints, it would accept a list of candidates as one of the input parameter, and for each of the candidate title, determine it’s MinHash value and query that against the LSH model we stored earlier. Here is the code snippet:</p><pre><strong>def </strong>get_similar(raw_title, lsh, num_perm=MINHASH_NUM_PERM):<br>    mq = MinHash(num_perm=num_perm)<br>    <strong>for </strong>d <strong>in </strong>raw_title.split():<br>        mq.update(d.encode(<strong>&#39;utf8&#39;</strong>))<br><br>    result = model.query(mq)<br>    <strong>return </strong>result</pre><p>I brush through talking about MinHash LSH algorithm earlier (see <a href="https://medium.com/p/9fd3e45c05f#07bf"><em>References</em></a><em>⁶ </em>for details) but the idea is pretty simple. <em>MinHash Locality Sensitive Hashing (LSH)</em> is conceptually similar to the concept of <em>Hashing</em> (although the intent is opposite/ different). In hashing, we usually would like to have the array large enough to avoid collisions, here, we actually do want to have some collisions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*8z8aHAzo8WPA_k1jai_JLw.png" /><figcaption>Figure 9: Concept of Hashing⁷</figcaption></figure><p>The goal is to find a representational set that we can work with without doing a full table scan on all the record. Also, note that this approach is more robust (in comparison to say “ <em>select * from table like ‘%data scientist%’</em> ” approach) as it also elegantly captures titles that may be out of order. Here is a sample JSON of how the representational set looks like for <em>data scientist</em>:</p><pre>{<br>  &quot;results&quot;: [<br>    {<br>      &quot;model_id&quot;: &quot;974ca263-af59-4c99-89df-4846396a63d6&quot;,<br>      &quot;uuid&quot;: &quot;872487d1-81f7-4ca8-bae1-9e8a1238255c&quot;,<br>      &quot;score&quot;: &quot;100&quot;,<br>      &quot;canonical_title&quot;: &quot;freelance data scientist&quot;<br>    },<br>    {<br>      &quot;model_id&quot;: &quot;974ca263-af59-4c99-89df-4846396a63d6&quot;,<br>      &quot;uuid&quot;: &quot;a743280b-6de3-45b7-90e1-d38b24708cf5&quot;,<br>      &quot;score&quot;: &quot;100&quot;,<br>      &quot;canonical_title&quot;: &quot;data scientist&quot;<br>    },<br>    {<br>      &quot;model_id&quot;: &quot;974ca263-af59-4c99-89df-4846396a63d6&quot;,<br>      &quot;uuid&quot;: &quot;b430b730-6a70-4eb1-962f-13188a1a835e&quot;,<br>      &quot;score&quot;: &quot;100&quot;,<br>      &quot;canonical_title&quot;: &quot;big data scientist&quot;<br>    }<br>  ],<br>  &quot;title&quot;: &quot;data scientist&quot;<br>}</pre><p>Once we have a representational set, we can apply further logic to choose the best representational canonical title matching the given raw.</p><p>A brief note on deployment, since bootstrapping the model file takes a bit of time (due to file size of ~1.2GB, time it takes to download from Model Store and finally load it into memory), we separate it into two phases, spot instances and on-demand instances. That large complex modules require smart/health-mediated deployments to avoid downtime, a topic interesting on its own that we can talk about in details in the future blog. Also, worthy to mention as the reader think about micro-services is to consider the guidelines of the <em>Twelve-Factor App</em>⁸ to ensure your services are deployment friendly (and portable).</p><p>Tracing back, how about Option 2, <em>i.e. bring the 500k canonical titles dataset further upstream against the position dataset</em>? How would that simplify the code and implementation? By precomputing seniority score into each position in our database, the list of candidates pass into the service would now include the score itself, i.e. it does not need to perform any of the MinHash LSH logic, and jump straight into applying scoring as a simple classifier problem!</p><p>I would defer the discussion about how we formulate and apply different classification algorithm to detect over- and under-qualified candidates. There are plenty to talk about on this topic alone, from how do we think about collecting label data, various algorithmic techniques, including but not limited to logistic regression, random forest to using neural networks, what are the key lessons learnt and/or observed, how do we measure the efficacy of our classifiers (confusion matrix, precision-recall curve, ROC curve, etc.) and product challenges in making this usable.</p><p>I hope by now you are intrigued by my writings and some of the work that we do at Entelo. Hope you enjoy reading this article and please feel free to reach out for any question, feedback and comments!</p><h3>Acknowledgements</h3><p>This article was greatly strengthened thanks to the detailed and invaluable feedback by colleagues at Entelo, and external technical reviewers, in particular, <a href="https://medium.com/u/2347777444f5">Ayush Joshi</a>, <a href="https://medium.com/u/a0b8926cd15f">Travis Thompson</a> and <a href="https://medium.com/u/64f378824ba">Sneha Chatterjee</a>.</p><h3>References</h3><ol><li><a href="https://en.wikipedia.org/wiki/Seniority">https://en.wikipedia.org/wiki/Seniority</a></li><li><a href="https://blog.entelo.com/introducing-entelo-insights">https://blog.entelo.com/introducing-entelo-insights</a></li><li><a href="https://en.wikipedia.org/wiki/Feature_(machine_learning)">https://en.wikipedia.org/wiki/Feature_(machine_learning)</a></li><li><a href="http://www.mymarketresearchmethods.com/types-of-data-nominal-ordinal-interval-ratio/">http://www.mymarketresearchmethods.com/types-of-data-nominal-ordinal-interval-ratio/</a></li><li><a href="http://tolkiengateway.net/wiki/Ring_Verse">http://tolkiengateway.net/wiki/Ring_Verse</a></li><li><a href="https://medium.com/engineering-brainly/locality-sensitive-hashing-explained-304eb39291e4">https://medium.com/engineering-brainly/locality-sensitive-hashing-explained-304eb39291e4</a><br><a href="https://ekzhu.github.io/datasketch/lsh.html">https://ekzhu.github.io/datasketch/lsh.html</a><br><a href="http://matthewcasperson.blogspot.com/2013/11/minhash-for-dummies.html">http://matthewcasperson.blogspot.com/2013/11/minhash-for-dummies.html</a></li><li><a href="https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html">https://www.cs.cmu.edu/~adamchik/15-121/lectures/Hashing/hashing.html</a></li><li><a href="https://12factor.net/">https://12factor.net/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fd3e45c05f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/the-science-and-art-behind-quantifying-seniority-9fd3e45c05f">The Science (and Art) Behind Quantifying Seniority</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[Other Benefits of Redux]]></title>
            <link>https://medium.com/entelo/other-benefits-of-redux-c394522b4e9e?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/c394522b4e9e</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vandeth Nop]]></dc:creator>
            <pubDate>Mon, 23 Apr 2018 17:13:54 GMT</pubDate>
            <atom:updated>2018-04-23T17:13:53.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQ3n1WHn5Bu-6llQGRmAEg.jpeg" /></figure><p>If you’ve used React before, then I’m sure you’re familiar with unidirectional data flow and how it can be a bit of a hassle at times. The image below represents a React application and each numbered circle is a component. Imagine if you had to pass data from the state as properties from component 1 all the way down to component 8, and component 8 would like to update the state with new data. At this point or later when the application continues to grow, adding Redux would help to manage passing data and functions to other components. What are some other benefits of adding Redux to an application?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*T4ac93u2lxTaz92Fxw-z2A.png" /><figcaption>React Application</figcaption></figure><p>It’s fine and not impossible to build an application without Redux, but using Redux comes with a few benefits such as predictability, maintainability, and testability. Redux has a store (source of truth) that holds the application state. The image below represents an application that uses React and Redux. Component 6 connects to the store to have access to the application state and component 8 dispatches an action (a Javascript object) to the store to update the application state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*sAiFND0PhQOikcSpRUh69w.png" /><figcaption>React Application with Redux</figcaption></figure><p>All application state changes are made in the store. Reducers are pure functions that handle all changes made to the store. Using pure functions to update the application state helps keep an application predictable, because it will always return a new state and not mutate the previous state.</p><p>Introducing Redux to an application will help with maintaining an application. We remove the strong coupling of parent and children components, because we no longer need to pass properties from the very top of the application all the way down to the children components. This allows us to make necessary changes in a child component without having to make changes in every component connecting to the parent component. For example in the image above, if we needed to remove only component 6, we could just remove it and have component 5 take its place with connecting to the store and components 7 and 8.</p><p>Redux also helps with testability of an application. The store contains the application state and reducers handle updating the state. So, we are able to test the reducers which are pure functions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c394522b4e9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/other-benefits-of-redux-c394522b4e9e">Other Benefits of Redux</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[A Code Refactor]]></title>
            <link>https://medium.com/entelo/a-code-refactor-39479f08215f?source=rss----39efb5891372---4</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:20 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[Responsible Use of Ruby Metaprogramming]]></title>
            <link>https://medium.com/entelo/responsible-use-of-ruby-metaprogramming-5561701887fb?source=rss----39efb5891372---4</link>
            <guid isPermaLink="false">https://medium.com/p/5561701887fb</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[metaprogramming]]></category>
            <dc:creator><![CDATA[Alexander Deeb]]></dc:creator>
            <pubDate>Mon, 26 Mar 2018 03:44:18 GMT</pubDate>
            <atom:updated>2018-04-08T00:40:42.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syCan-V72N2G48SnGTrOmQ.jpeg" /></figure><p>Metaprogramming is one practice in software development that has mixed opinions. On one hand, it has the potential to DRY up your code by reducing redundant patterns. On the other hand, it can make your code convoluted and difficult to maintain. So how do you determine when you should use it and when you should stick to traditional programming?</p><p>First, it is valuable to define metaprogramming. According to <a href="https://en.wikipedia.org/wiki/Metaprogramming">Wikipedia</a>:</p><blockquote>Metaprogramming is a programming technique in which computer programs have the ability to treat programs as their data. It means that a program can be designed to read, generate, analyze or transform other programs, and even modify itself while running.</blockquote><p>Metaprogramming can help you write more succinct code for your applications. A common use case in Ruby is to define new classes and methods. Let’s consider the following class:</p><pre>class MyClass<br>  def red<br>    &#39;red&#39;<br>  end</pre><pre>  def blue<br>    &#39;blue&#39;<br>  end</pre><pre>  def green<br>    &#39;green&#39;<br>  end</pre><pre>  def yellow<br>    &#39;yellow&#39;<br>  end<br>end</pre><p>This is a simple class that has a method for each color (red, blue, green, and yellow) and outputs the color name. This is how the class could look if you used metaprogramming:</p><pre>class MyClass<br>  COLORS = [&#39;red&#39;, &#39;blue&#39;, &#39;green&#39;, &#39;yellow&#39;]</pre><pre>  COLORS.each do |color|<br>    define_method color do<br>      color<br>    end<br>  end<br>end</pre><p>This class functions exactly as the previous class definition, except the code is much shorter. This is a simple example that conveys one way in which metaprogramming can deliver value: succinct code. If you had a small, finite list of colors, as shown above, metaprogramming probably isn’t worth it, but if you need similar methods for thousands of colors, metaprogramming can keep your code manageable.</p><p>One of the most popular examples of metaprogramming is <a href="http://guides.rubyonrails.org/active_record_querying.html#dynamic-finders">dynamic finders</a> in Rails’ ActiveRecord. Because the finders are based on the columns in your database table, metaprogramming is necessary to dynamically define the methods. It would be ridiculous for Rails contributors to try to predict every column name that users of the framework would have and define methods for each one of them.</p><p>Let’s take a look at another, more sophisticated use of metaprogramming that serves as a detrimental use of the pattern. Try to understand what the module is doing.</p><pre>module ContextualModels  <br>  CONTEXTUAL_MODELS = [&#39;job&#39;, &#39;user&#39;, &#39;candidate&#39;]</pre><pre>  def self.included(base)<br>    base.class_eval do<br>      define_singleton_method(:contextual_model) do |name|<br>        define_method(&quot;contextual_#{name}&quot;.to_sym) do<br>          <a href="http://twitter.com/contextual_models">@contextual_models</a> ||= {}<br>          <a href="http://twitter.com/contextual_models">@contextual_models</a>[name] ||= &quot;Models::#{name.camelcase}&quot;.constantize<br>        end<br>      end</pre><pre>      CONTEXTUAL_MODELS.each do |name|<br>        contextual_model(name)<br>      end<br>    end<br>  end<br>end</pre><pre>module Models<br>  class MyModel<br>    include ::ContextualModels<br>    <br>    ..<br>  end<br>end</pre><p>This code adds contextual_job, contextual_user, and contextual_candidate class methods to whichever class includes it, in this case MyModel. Those class methods simply refer to the respective classes, Models::Job, Models::User, and Models::Candidate, with the goal appearing to be for one class to know about all of its related models and be able to easily access them.</p><p>The code in the example is actually an adapted version of a module that was previously in <a href="https://www.entelo.com/">Entelo’s</a> code base. None of the engineers on the team wanted to work with that code, nonetheless refactor it, and it was a pain point in creating new functionality because of its convoluted nature. It’s an example of over-complication through metaprogramming because it adds complexity and does not provide any real value. The code can more easily be written by explicitly referencing a class, Models::Job, instead of using a contextual_{method} method to refer to the class.</p><p><strong>So, in which situations should you consider using metaprogramming?</strong></p><ol><li>You have redundant patterns that can be greatly simplified with metaprogramming</li><li>The value of succinct code outweighs the sacrifice of readability and increased complexity</li><li>Performance is not a concern</li><li><a href="https://stackoverflow.com/a/13759950/2430657">“When it will make your life easier and not complicate others’ lives.”</a></li></ol><p><strong>In which situations is metaprogramming a suboptimal choice?</strong></p><ol><li>It is used as the basis for core functionality. While it depends on the type of application you’re building, if some core functionality is metaprogrammed, you’ll want to reconsider your approach since it may be difficult to maintain.</li><li>If you could reasonably solve the problem without metaprogramming.</li><li>The purpose of using metaprogramming is unwarranted. For example, you implement Ruby’s method_missing just to lowercase a string.</li><li>Performance is a concern. Metaprogramming will often invalidate the <a href="https://github.com/charliesome/charlie.bz/blob/master/posts/things-that-clear-rubys-method-cache.md">Ruby method cache</a>, resulting in performance losses.</li></ol><p><strong>Additional considerations:</strong></p><ol><li>Since reading metaprogrammed code isn’t always intuitive, include comments explaining the code’s function at a high level so that other developers can understand conceptually what the code is doing.</li><li>Consolidate all metaprogrammed code so there is less overhead in switching between metaprogramming and traditional programming when reading through the codebase.</li></ol><p>How are you using metaprogramming in your codebase?</p><p>P.S. Entelo is hiring! Check out our <a href="https://www.entelo.com/company/careers">open positions</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5561701887fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/entelo/responsible-use-of-ruby-metaprogramming-5561701887fb">Responsible Use of Ruby Metaprogramming</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>