<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Justin San Juan on Medium]]></title>
        <description><![CDATA[Stories by Justin San Juan on Medium]]></description>
        <link>https://medium.com/@justinsj?source=rss-457b4f5eadc3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*st1i98DUKqUvbjJHaj3lQg.jpeg</url>
            <title>Stories by Justin San Juan on Medium</title>
            <link>https://medium.com/@justinsj?source=rss-457b4f5eadc3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:12:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@justinsj/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A practical guide to 10× your value using an ease/impact matrix]]></title>
            <link>https://justinsj.medium.com/a-practical-guide-to-10-your-value-using-an-ease-impact-matrix-5a1012150330?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a1012150330</guid>
            <category><![CDATA[business-strategy]]></category>
            <category><![CDATA[practical-guides]]></category>
            <category><![CDATA[10x-engineer]]></category>
            <category><![CDATA[prioritization]]></category>
            <category><![CDATA[business-consulting]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 14:01:55 GMT</pubDate>
            <atom:updated>2022-12-02T14:01:55.802Z</atom:updated>
            <content:encoded><![CDATA[<p>At any point in our lives, we should be aiming to make the most value out of our efforts. Whether value is defined as maximizing your salary, personal enjoyment, or chances of a successful startup, we want to find out what the best actions are to take to move ourselves as far as possible forward in our lives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7N5_Dz6aKhA2XSZk" /><figcaption>Photo by <a href="https://unsplash.com/@jeshoots?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">JESHOOTS.COM</a> on <a href="https://unsplash.com/s/photos/chess?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>We want to propel ourselves forward as best as we can</h4><p>For example, we would not want to spend 3 months of our lives working on a project in a company that just accomplishes one thing for one client if we could execute on another venture that can impact more customers in the same amount of time, or can be done more easily.</p><p>If you cut off all the tasks in your work that have low potential for impact or are too difficult to do, then you can 10× the value of all of your effort.</p><p>There are many other articles on what an ease/impact matrix is, but none of them guide you in filling one out. This one does.</p><h4>The challenge is uncertainty</h4><p>Even if you have a number of options, for example, project A, B, and C, that each have different potentials and effort needed, in most cases, it is difficult to say which is the best one right off the bat.</p><p>The source of mistakes when picking our course of action is uncertainty of either the impact or the ease of implementation of for a project. Our goal then should be to minimize uncertainty.</p><p>In this article, a potential project is a direction or rough idea aimed at solving a specific problem.</p><p>The rest of this article is written in likeness of a troubleshooting article, which lists practical steps to identifying the best action to take.</p><h4>An ease/impact matrix plots projects in the dimensions of ease and impact, but how do we define these?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*w6WL6R2LcTDVkf6CyXEtSA.jpeg" /><figcaption>A blank Ease/Impact matrix</figcaption></figure><p>To start placing items on the graph, we need to ask two questions: how impactful is it? and how easy is it to complete?</p><p>Here are a few helpful questions to ask when determining <strong>“impact”</strong>:</p><ul><li>Is it a novel, structural architectural change? If yes, there is a better chance that it will have a huge impact.</li><li>How much people are impacted by it?</li><li>How frequently are people impacted by it?</li><li>Are people spending money on this problem already / is there a good history validating that this problem exists?</li></ul><p>Meanwhile, here are some questions to ask when determining <strong>“ease”</strong>:</p><ul><li>What is a good set of date ranges to divide these tasks? Set at most 3 ranges of dates such as: up to 1 week, up to 4 weeks, over 4 weeks.</li><li>How long can you do it? This is primarily based on your experience and intuition.</li><li>Can someone else do it for you?</li><li>How long can someone else do it?</li></ul><h4>Remember to keep it simple</h4><p>After placing a few items down, it may be tempting to ask whether working on some project will make other projects easier, but it is often more important to focus on the items individually to make a decision sooner than later.</p><h4>What if you are still unsure?</h4><p>If you have a gut feeling and indecisiveness on how impactful or easy a project is, treat it as a signal to get more information.</p><p>Ways you can get more information for impact include:</p><ul><li>Ask relevant audience members about their experience with the problem.</li><li>Look up relevant numbers such as potential market size, current spendings.</li><li>Estimate the benefit by modelling the effect of a project in an equation. For example, if a project can reduce the time for customers waiting in line, we can design an equation that outputs how much added revenue (sales) can be acheived for some amount of reduction in time.</li></ul><p>To get a better idea of ease:</p><ul><li>Ask experienced workers that have implemented similar projects</li><li>Research relevant durations if possible. For example, you can search the duration of some related projects in freelance websites.</li><li>Look at the cost of similar projects as another signal on ease of implementation.</li></ul><h4>When should you pick off a project?</h4><p>Once you have plotted each of your current potential projects, you can then think of picking one. However, the only time you should pick off a project at this point in time is when you have one on the top-right corner of the matrix.</p><p>If not, it may be a good idea to take time and identify more potential projects.</p><p>Meanwhile, if you already believe you have all your choices on the board, you may think about picking a project on the top area or the right side of the chart.</p><p>If the project is on the <strong>top area</strong> and more towards the left, you believe the project has potential for high impact but can be difficult to achieve. You may then consider onboarding more experienced people to work on the project.</p><p>If the project is on the <strong>right side</strong> of the graph and more towards the bottom, you may want to consider delegating to lower-cost labour, or automating it.</p><h4>Do this regularly and you will develop intuition</h4><p>The first time you use an ease/impact matrix is not necessarily easy. You may find that there are a lot of unknowns. However, the more you use it, the faster you will be as you develop intuition for different problems and their relevance to your projects.</p><p>Overall, it is important to identify what your next actions should be to maximize your value.</p><h3>Conclusion</h3><p>This article describes practical steps and questions to ask yourself in order to use an ease/impact matrix. The matrix helps you prioritize what your next action should be to maximize the value you create.</p><p>If you enjoyed this article or learned something from it, I would greatly appreciate your <em>clap</em>!</p><p>If you have anything to suggest, let me know in the comments or message me on <a href="https://www.linkedin.com/in/justin-sj/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a1012150330" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Simple Alert for Long-Running Jobs]]></title>
            <link>https://justinsj.medium.com/how-to-create-a-simple-alert-for-long-running-jobs-8fdff3656a5a?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fdff3656a5a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[alerts]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 14:01:21 GMT</pubDate>
            <atom:updated>2022-11-25T14:01:21.139Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are tired of executing long-running commands and having to wait idly for the result, you can set up a simple alert system to get notified when the task is finished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*toCBA_Jkjg1v90AyUHUWfg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rhodadesigns?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">rhoda alex</a> on <a href="https://unsplash.com/s/photos/bell?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Whether you are running a long Machine Learning training task, analyzing a load of data, or executing a long simulation, this alert enables you to step away from the computer and get notified when to come back.</p><p>In this article, I show you how to install a simple Python script that will send you a message on a Slack channel, Discord channel, or anything else. I use this often in my work and I hope it will be useful to you too.</p><p>This guide is created for Linux, but can also be installed for Mac or Windows as long as you can get Python.</p><p>The alert works by using the <a href="https://pypi.org/project/knockknock/">knockknock</a> library in Python. The main alert file in the repository is only 17 lines of code!</p><h3>Set up the alert in 6 easy steps</h3><h4>1. Clone the repository anywhere in your computer</h4><pre>git clone https://github.com/justinsj/alert-git</pre><h4>2. Install the requirements</h4><pre>sudo pip install setuptools-rust<br>python -m pip install — upgrade pip<br>python -m pip install -r requirements.txt</pre><h4>3. Set up your Slack webhook URL.</h4><p>To do this, check out <a href="https://api.slack.com/messaging/webhooks](https://api.slack.com/messaging/webhooks).">https://api.slack.com/messaging/webhooks.</a></p><h4>4. Change the SLACK_WEBHOOK_URL and DEFAULT_SLACK_CHANNEL in alert.</h4><p>In the file alert , update the variables to your webhook URL and default channel.</p><pre># alert<br><br>SLACK_WEBHOOK_URL = &#39;https://hooks.slack.com/services/T0JQQQQQQ/B0JQQQQQQ/XXXXXXXXXXXXXXXXXXXXXXXX&#39;<br>DEFAULT_SLACK_CHANNEL = &#39;your-slack-channel&#39;</pre><h4>5. Ensure that the alert code is executable</h4><pre>chmod +x alert</pre><h4>6. Copy the file to an easily accessible location like ~/alert.</h4><pre>cp alert ~/alert</pre><h3>Now you can use ~/alert with any long task!</h3><p>For example, from any folder, you can do:</p><pre>~/some-folder$ python some_long_task.py &amp;&amp; ~/alert</pre><p>Finally, you can set a custom message after the ~alert command:</p><pre>~/alert hello</pre><h3>Conclusion</h3><p>In this article, I have written about a simple alert system that I personally use often and install in almost every machine I work with.</p><p>If you enjoyed this article or learned something from it, I would appreciate your <em>clap</em>!</p><p>If you also have anything to suggest, let me know in the comments or message me on <a href="https://www.linkedin.com/in/justin-sj/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fdff3656a5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement the Builder Pattern in Python for Automating SQL Dashboard Analytics]]></title>
            <link>https://justinsj.medium.com/how-to-implement-the-builder-pattern-in-python-for-automating-sql-dashboard-analytics-f864b76749fe?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f864b76749fe</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 18 Nov 2022 14:01:50 GMT</pubDate>
            <atom:updated>2022-11-18T14:01:50.178Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I discuss the design and implementation of an SQL Builder in Python. The main benefit of this pattern is saving plenty of development time in making domain-specific queries. In addition, the builder pattern allows flexibility in where and when information is added to the query.</p><p>Most SQL builder libraries are built to support SQL-like statements in different languages. However, builders that can truly automate queries for companies can only be developed in-house because public libraries will always be designed to only solve general problems.</p><p>Through this article (source code available below!), you will be able to create your own custom SQL builder with syntax such as the following example where we want to get the number of cars sold in the past 24 hours.</p><pre>sql = (<br>    AdvancedSQLBuilder().SELECT(&quot;NAME&quot;).SELECT(&quot;COUNT(*)&quot;)<br>    .FROM(&quot;CARS&quot;).WHERE(&quot;NAME = &#39;BMW&#39;&quot;)<br>    .ORDER_BY(&quot;COUNT(*)&quot;).HOURS(&quot;SELL_DATE&quot;, 24)<br>    .GROUP_BY(&quot;NAME&quot;)<br>    .BUILD()<br>    )<br>print(sql)</pre><p>To output the following:</p><pre>SELECT NAME, COUNT(*)<br>FROM CARS<br>WHERE NAME = &#39;BMW&#39;<br>AND SELL_DATE &gt;= DATEADD(HOUR, -24, GETDATE())<br>GROUP BY NAME<br>ORDER BY COUNT(*)</pre><p>The above result uses MS SQL Server, but can be adapted for any SQL database.</p><h3>Motivation</h3><p>The naive way to instantiate an object of a class uses the following format:</p><pre>class MyClass:<br>    def __init__(self, item_a, item_b, item_c):<br>        self.a = item_a<br>        self.b = item_b<br>        self.c = item_c<br><br># Example<br>obj = MyClass(1, 2, 3)</pre><p>All is well using this method of object instantiation until we do not need to supply all of the values of a, b, c during instantiation. An example of this is when creating SQL statements.</p><p>A similar method of designing an SQL statement object may be the following:</p><pre>class SQLStatement:<br>    def __init__(self, select_properties, from_tables, <br>              where_conditions, group_by_clause, having_conditions):<br>        self.select_properties = select_properties<br>        self.from_tables = from_tables<br>        self.where_conditions = where_conditions<br>        self.group_by_clause = group_by_clause<br>        self.having_conditions = having_conditions<br>    def __repr__(self):<br>        return f&quot;&quot;&quot;SELECT {self.select_properties}<br>FROM {self.from_tables}<br>WHERE {self.where_conditions}<br>GROUP BY {self.group_by_clause}<br>HAVING {self.having_conditions}<br>&quot;&quot;&quot;<br><br># Example<br>sql = SQLStatement(&quot;NAME&quot;, &quot;CARS&quot;, &quot;COLOR = &#39;blue&#39;&quot;, &quot;&quot;,&quot;&quot;)<br>print(sql)</pre><p>This outputs:</p><pre>SELECT NAME<br>FROM CARS<br>WHERE COLOR = &#39;blue&#39;<br>GROUP BY  <br>HAVING  </pre><p>In the case above, we have an <em>SQLStatement </em>class that takes a required 5 arguments of select, from, where, group by, and having clauses. When we do not need to use the other arguments such “group by” and “having” as in the example, we need to put an empty argument. We can also adjust this class to use optional arguments, but that becomes messy very quickly.</p><h3>The Builder Pattern</h3><p>The builder pattern can be best described with a simple example:</p><pre>class MyBuilder:<br>    def __init__(self):<br>        self.a = None<br>        self.b = None<br>        self.c = None<br>    def a(self, arg):<br>        self.a = arg<br>        return self<br>    def b(self, arg):<br>        self.b = arg<br>        return self<br>    def c(self, arg):<br>        self.c = arg<br>        return self<br>    def build(self):<br>        list_of_values = [self.a, self.b, self.c]<br>        list_of_values = [i for i in list_of_values if i is not None]<br>        return list_of_values.join(&quot;,&quot;)<br><br># Example<br>myBuilder = MyBuilder().b(1).a(2)<br>print(myBuilder.build())<br><br># Outputs: 1,2</pre><p>The above example demonstrates the builder pattern, which has the following properties:</p><ul><li>Functions that set a class variable should return self. This allows chaining commands such as in the example.</li><li>The class should have a build() function (or any other name). This function should consume the information of all the variables that were set before calling it and return the desired output while handling missing information.</li><li>The setter functions can be called in any order.</li></ul><h3>Let’s build the SQL builder!</h3><p>Now that we know how to use the builder design pattern, we can use it to create a domain-specific SQL builder.</p><p>The goal of this builder is to make the process of aggregating data easier for any type of process. This is particularly useful for building queries for dashboards if we add the ability to restrict results within specific date ranges, segment different groups, etc.</p><p>First, we need a baseline SQL builder:</p><pre># SQLBuilder.py<br><br>newline = &quot;\n&quot;<br><br>class SQLBuilder(object):<br> def __init__(self):<br>  self._DECLARE = &quot;&quot;<br>  self._SELECT = &quot;&quot;<br>  self._FROM_MAP = {}<br>  self._WHERE = &quot;&quot;<br>  self._ORDER_BY = &quot;&quot;<br>  self._GROUP_BY = &quot;&quot;<br>  self._HAVING = &quot;&quot;<br> <br> <br> def DECLARE(self, key, type, value = &#39;&#39;):<br>  assert(key.startswith(&#39;@&#39;))<br>  <br>  # Handle keyword starting with declare<br>  s = &quot;\n&quot;<br>  if (self._DECLARE == &quot;&quot;):<br>   s = &quot;&quot;<br>  <br>  self._DECLARE += s + f&quot;DECLARE {key} {type}{&#39; = &#39; if value else &#39;&#39;}{value}&quot;<br>  return self<br> def SELECT(self, t):<br>  s = &quot;, &quot;<br>  if (self._SELECT == &quot;&quot;):<br>   s = &quot;SELECT &quot;<br>  <br>  self._SELECT += s + t<br>  return self<br> <br> def FROM(self, t, alias=&#39;&#39;):<br>  if (not t in self._FROM_MAP):<br>   self._FROM_MAP[t] = &#39;&#39;<br><br>  if (alias): <br>   self._FROM_MAP[t] = alias<br><br>  return self<br> def WHERE(self, t):<br>  if (self._WHERE != &quot;&quot;):<br>   return self.AND(t)<br>  self._WHERE = &quot;WHERE &quot; + t<br>  return self<br>  <br> def AND(self, t):<br>  s = &quot;\n&quot;<br>  if (self._WHERE == &quot;&quot;):<br>   s = &quot;WHERE 1=1\n&quot;<br>  <br>  self._WHERE += s + f&quot;AND {t}&quot;<br>  return self<br> <br> def GROUP_BY(self, t):<br>  s = &quot;,\n&quot;<br>  if (self._GROUP_BY == &quot;&quot;):<br>   s = &quot;GROUP BY &quot;<br>  <br>  self._GROUP_BY += s + t<br>  return self<br> <br> def ORDER_BY(self, t):<br>  s = &quot;,\n&quot;<br>  if (self._ORDER_BY == &quot;&quot;):<br>   s = &quot;ORDER BY &quot;<br>  <br>  self._ORDER_BY += s + t<br>  return self<br> <br> def HAVING(self, t):<br>  s = &quot;,\n&quot;<br>  if (self._HAVING == &quot;&quot;):<br>   s = &quot;HAVING &quot;<br>  <br>  self._HAVING += s + t<br>  return self<br> def JOIN(self, table_one, key_one, table_two, key_two):<br>  return self.FROM(table_one).FROM(table_two).AND(f&quot;{table_one}.{key_one} = {table_two}.{key_two}&quot;)<br> <br> def BUILD(self):<br>  self._FROM = &#39;, &#39;.join([f&quot;{name}{f&#39; {alias}&#39; if alias else &#39;&#39;}&quot; for name, alias in self._FROM_MAP.items()])<br>  return (<br>   f&quot;{self._DECLARE + newline if self._DECLARE else &#39;&#39;}&quot;<br>   + f&quot;{newline + self._SELECT if self._SELECT else &#39;&#39;}&quot;<br>   + f&quot;{newline + &#39;FROM &#39; + self._FROM if self._FROM else &#39;&#39;}&quot;<br>   + f&quot;{newline + self._WHERE if self._WHERE else &#39;&#39;}&quot;<br>   + f&quot;{newline + self._GROUP_BY if self._GROUP_BY else &#39;&#39;}&quot;<br>   + f&quot;{newline + self._HAVING if self._HAVING else &#39;&#39;}&quot;<br>   + f&quot;{newline + self._ORDER_BY if self._ORDER_BY else &#39;&#39;}&quot;<br>  )</pre><p>An example of using this base class is to find the count of entries in a table CARS that has the NAME equal to ‘BMW’.</p><pre>from SQLBuilder import SQLBuilder<br><br>print(<br>    SQLBuilder()<br>    .SELECT(&quot;NAME&quot;).SELECT(&quot;COUNT(*)&quot;)<br>    .FROM(&quot;CAR_SALES&quot;, &quot;C&quot;)<br>    .WHERE(&quot;C.NAME = &#39;BMW&#39;&quot;)<br>    .ORDER_BY(&quot;COUNT(*)&quot;)<br>    .BUILD()<br>)</pre><p>This outputs:</p><pre>SELECT NAME, COUNT(*)<br>FROM CAR_SALES C<br>WHERE C.NAME = &#39;BMW&#39;<br>ORDER BY C.COUNT(*)</pre><h3>We can now add special helper functions</h3><p>These helper functions can include:</p><ul><li>HOURS(key, n) to limit the range of the <em>key </em>up to <em>n </em>hours ago.</li><li>TODAY(key) to limit the values of <em>key </em>to be within today.</li><li>START_DATE(key, start_date) to limit the lowest value of <em>key </em>to <em>start_date</em></li><li>END_DATE(key, end_date) to limit the highest value of <em>key</em> to <em>end_date</em></li><li>LIKE(key, s) to add a WHERE condition that <em>key </em>is a string like <em>s</em>.</li><li>NULL(key) to add a WHERE condition that the value of <em>key </em>is null.</li><li>NOTNULL(key) to add a WHERE condition that the value of <em>key </em>is NOT null.</li><li>etc.</li></ul><pre># AdvancedSQLBuilder.py<br><br>from SQLBuilder import SQLBuilder<br><br>class AdvancedSQLBuilder(SQLBuilder):<br> def HOURS(self, key, n):<br>  assert(n &gt; 0)<br>  <br>  self.AND(f&quot;{key} &gt;= DATEADD(HOUR, -{n}, GETDATE())&quot;)<br>  return self<br><br> def TODAY(self, key):<br>  self.AND(f&quot;CONVERT(VARCHAR(10), {key}, 102) = CONVERT(VARCHAR(10), GETDATE(), 102)&quot;)<br>  return self<br> <br> def START_DATE(self, key, start_date):<br>  (self.DECLARE(&#39;@start_date&#39;,&#39;datetime&#39;,start_date)<br>   .AND(f&quot;{key} is not null&quot;)<br>   .AND(f&quot;{key} &gt;= @start_date&quot;))<br>  return self<br> <br> def END_DATE(self, key, end_date):<br>  self.DECLARE(&#39;@end_date&#39;,&#39;datetime&#39;,end_date)<br>  self.AND(f&quot;{key} is not null&quot;)<br>  self.AND(f&quot;{key} &lt; @end_date&quot;)<br>  return self<br> <br> def LIKE(self, key, s):<br>  self.AND(f&quot;{key} like &#39;{s}&#39;&quot;)<br>  return self<br><br> def NULL(self, key):<br>  self.AND(f&quot;{key} is null&quot;)<br>  return self<br> <br> def NOTNULL(self, key):<br>  self.AND(f&quot;{key} is not null&quot;)<br>  return self</pre><p>An example of using this is then to find the number of cars sold last year:</p><pre>from AdvancedSQLBuilder import AdvancedSQLBuilder<br><br>print(<br>    AdvancedSQLBuilder()<br>    .SELECT(&quot;NAME&quot;).SELECT(&quot;COUNT(*)&quot;)<br>    .FROM(&quot;CAR_SALES&quot;)<br>    .START_DATE(&quot;SELL_DATE&quot;, &#39;2021-11-18 00:00:00&#39;)<br>    .END_DATE(&quot;SELL_DATE&quot;, &#39;2022-11-18 00:00:00&#39;)<br>    .ORDER_BY(&quot;COUNT(*)&quot;)<br>    .GROUP_BY(&quot;NAME&quot;)<br>    .BUILD()<br>)</pre><p>This outputs:</p><pre>DECLARE @start_date datetime = 2021-11-18 00:00:00<br>DECLARE @end_date datetime = 2022-11-18 00:00:00<br><br>SELECT NAME, COUNT(*)<br>FROM CAR_SALES<br>WHERE 1=1<br>AND SELL_DATE is not null<br>AND SELL_DATE &gt;= @start_date<br>AND SELL_DATE is not null<br>AND SELL_DATE &lt; @end_date<br>GROUP BY NAME<br>ORDER BY COUNT(*)</pre><h3>We can achieve even more with this pattern</h3><p>Going into domain-specific examples, suppose our database uses ID numbers for our car names instead of a string in the following:</p><pre># Example database table: <br># CARS<br>+------------+--------+----------------+<br>| PRIMARY_ID | CAR_ID |   SOME_VALUE   |<br>+------------+--------+----------------+<br>| 1          | 103112 | some_value     |<br>| 2          | 103113 | another value  |<br>| ...        | ...    | ...            |<br>+------------+--------+----------------+<br># CAR_MAP<br>+--------+---------------+<br>| ID     |    CARNAME    |<br>+--------+---------------+<br>| 103112 | BMW           |<br>| 103113 | Aston Martin  |<br>| ...    | ...           |<br>+--------+---------------+</pre><p>We can add an automatic mapping function so that we can filter by car name:</p><pre># DomainSpecificSQLBuilder.py<br><br>from AdvancedSQLBuilder import AdvancedSQLBuilder<br>class DomainSpecificSQLBuilder(AdvancedSQLBuilder):<br>    def CARNAME(self, name, table_two, key_two):<br>        self.JOIN(&quot;CAR_MAP&quot;,&quot;ID&quot;, table_two, key_two)<br>        self.AND(f&quot;CAR_MAP.NAME = {name}&quot;</pre><p>An example of using this is to get all the names of cars with more than 30 sales:</p><pre>from DomainSpecificSQLBuilder import DomainSpecificSQLBuilder<br><br>print(<br>    DomainSpecificSQLBuilder()<br>    .SELECT(&quot;CARNAME&quot;).SELECT(&quot;COUNT(*)&quot;)<br>    .FROM(&quot;CAR_SALES&quot;)<br>    .CARNAME(&quot;BMW&quot;, &quot;CAR_SALES&quot;, &quot;CAR_ID&quot;)<br>    .WHERE(&quot;COUNT(*) &gt; 30&quot;)<br>    .BUILD()<br>)</pre><p>This outputs the following:</p><pre>SELECT CARNAME, COUNT(*)<br>FROM CAR_SALES, CAR_MAP<br>WHERE 1=1<br>AND CAR_MAP.ID = CAR_SALES.CAR_ID<br>AND CAR_MAP.NAME = BMW<br>AND COUNT(*) &gt; 30</pre><h3>Conclusion</h3><p>In this article, I have shown how to use the builder pattern to create a domain-specific SQL builder. This can then be used to programmatically generate SQL queries for different slices of data, allowing swift gathering of data for business dashboards and general analysis.</p><h3>GitHub Repository</h3><p>Feel free to check out the source code here: <a href="https://github.com/justinsj/sql-builder">https://github.com/justinsj/sql-builder</a></p><p>If you enjoyed this article or learned something from it, I would appreciate your <em>clap</em>!</p><p>If you also have anything to suggest, let me know in the comments or message me on <a href="https://www.linkedin.com/in/justin-sj/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f864b76749fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Implement the Interpreter Design Pattern for Messy Data in Python]]></title>
            <link>https://medium.com/better-programming/how-to-implement-the-interpreter-pattern-for-messy-data-in-python-594a54a74ebb?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/594a54a74ebb</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 11 Nov 2022 14:00:27 GMT</pubDate>
            <atom:updated>2023-02-09T22:48:11.177Z</atom:updated>
            <content:encoded><![CDATA[<h4>An in-depth guide to help you get more out of your data</h4><p>This article describes how you can implement the Interpreter design pattern to read messy data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBuZc7uWwbjjFF-GUzouyg.png" /><figcaption>Figure 1. Top 25% of company coop salaries</figcaption></figure><p>Figure 1 shows the average coop salaries of the top 25% of companies reported by students at the University of Waterloo. I will show you how to get to this graph step by step in this article.</p><h3>The Interpreter Pattern Can Read With Grammar</h3><p>It is usually used to evaluate mathematical text such as “32 * 5 + 23”. The usefulness of this pattern lies in how it performs arbitrary combinations of operations with a relatively simple set of rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*OzrkMcQVv0TtP6-jPSu9KA.png" /><figcaption>Figure 2. The Interpreter design pattern</figcaption></figure><p>The Interpreter design pattern is shown in Figure 2. It starts with a client that maintains a reference to a context, for example, the string “32 * 5 + 23”.</p><p>The bulk of the design pattern is then the AbstractExpression, which declares that all objects of this type should have an interpret(Context) function.</p><p>The classes that extend/inherit from the AbstractExpression then are two main types:</p><ul><li>TerminalExpression, also known as a LiteralExpression</li><li>NonTerminalExpression, which may contain references to AbstractExpressions</li></ul><p>Our implementations of these will be described later.</p><h4>Analyze the data for manually-reported salaries for coop</h4><p>Our goal is to rank companies by the reported salaries, according to a megathread on Reddit for the University of Waterloo students.</p><blockquote>Source code at the end of the article!</blockquote><p>The data contains the reported salaries for <a href="https://www.reddit.com/r/uwaterloo/comments/n4dse2/waterlooworks_spring_2021_megathread/">Spring 2021</a> and <a href="https://www.reddit.com/r/uwaterloo/comments/pkgmxh/waterlooworks_fall_2021_megathread/">Fall 2021</a>.</p><p>Here is an example of the data:</p><pre>1password: 25/h (1st coop), 32/hr (3rd coop), 42/hr (5th coop?)<br>Accedo: 24/hr (3rd coop)<br>⁠Achievers inc: 20-25/hr<br>⁠ADP: less than 44/hr<br>AGF: 18.50/hr<br>Akuna Capital: 65 USD/hour + return flight + corporate housing<br>Amazon: $7912/mo + 1875 USD/mo stipend + relocation(?)<br>AMD: 27/hr<br>American Express: 34.5/hr<br>⁠Apple: (34/hr + 1300-1500 stipend/month) (37/hr + 1350 stipend for 3A term)<br>Arctic Wolf: 20% above coop average, 23/hr (1st coop), 34/hr (4th coop)<br>Athos: 5000 USD/mo<br>Atolio: 34/hr (3rd coop), 38/hr (5th coop), 42/hr (6th coop)<br>⁠Autodesk: 24-30/hr<br>...</pre><p>The problem is that there are many different formats used. Here’s a few of them:</p><ul><li>X/hr</li><li>X/mo</li><li>USD X/month</li><li>X/hr (1st coop), Y/hr (3rd coop), Z/hr (5th coop)</li><li>etc.</li></ul><h4>We want to compare salary rankings using CAD/mo</h4><p>To compare salaries, we need to use the same units, and for this example, we will convert the salaries to Canadian Dollars (CAD) every month.</p><p>We use the following assumptions to simplify the problem:</p><ul><li>We take the average for range values (e.g., 20–25/hr → 22.5/hr)</li><li>We take the average for different coop term pays ( “34/hr (3rd coop), 38/hr (5th coop), 42/hr (6th coop)” → 38/hr )</li><li>The coop average is CAD 30.0/hr</li></ul><h4>Define the AbstractExpression</h4><p>To tackle the problem, we first define the AbstractExpression as follows:</p><pre># expressions.py<br><br>class AbstractExpression(object):<br>    def __init__(self):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: None -&gt; None<br>        &#39;&#39;&#39;<br>        pass<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br>        <br>        interpret: AbstractExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return 0<br>    def __repr__(self):<br>        &#39;&#39;&#39;<br>        Returns the string representation of the evaluated.<br>        <br>        __repr__: AbstractExpression -&gt; str<br>        &#39;&#39;&#39;<br>        return str(self.interpret())</pre><p>Note that we make interpret() a zero-argument function that returns a floating-point value. We assume that the necessary contexts are stored when the object is created. This is visible in the next section.</p><h4>A TerminalExpression usually refers to a single evaluated number</h4><p>We define it as follows:</p><pre># expressions.py<br><br>class LiteralExpression(AbstractExpression):<br>    def __init__(self, string):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: str -&gt; None<br>        &#39;&#39;&#39;<br>        self.string = string<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br><br>        interpret: LiteralExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return float(self.string)<br><br># Example:<br>LiteralExpression(&quot;32&quot;).interpret() # This returns the value 32</pre><h3>Let’s define an AddExpression</h3><p>Now that we have the base case, LiteralExpression, let’s add a simple addition operation to our interpreted language:</p><pre># expressions.py<br><br>class AddExpression(AbstractExpression):<br>    def __init__(self, left, right):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: AddExpression -&gt; None<br>        &#39;&#39;&#39;<br>        self.left = left<br>        self.right = right<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br>        <br>        interpret: AddExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return self.left.interpret() + self.right.interpret()<br><br># Example:<br>AddExpression(LiteralExpression(&quot;5&quot;), LiteralExpression(&quot;6&quot;)) # Returns 11</pre><p>The add operation takes two AbstractExpression objects to create. If we initialize it with two LiteralExpressions for 5 and 6, then the result we get from interpret() is 11.</p><p>The great thing about this is that the two input objects do not have to be LiteralExpressions. They can be other composite expressions such as MultiplyExpression or more AddExpressions.</p><h4>Now we need a SubtractExpression</h4><p>Almost exactly like the AddExpression, but we perform subtraction in interpret().</p><pre># expressions.py<br><br>class SubtractExpression(AbstractExpression):<br>    def __init__(self, left, right):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: AbstractExpression AbstractExpression -&gt; None<br>        &#39;&#39;&#39;<br>        self.left = left<br>        self.right = right<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br><br>        interpret: SubtractExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return self.left.interpret() - self.right.interpret()</pre><h4>We also need to define MultiplyExpression</h4><pre># expressions.py<br><br>class MultiplyExpression(AbstractExpression):<br>    def __init__(self, left, right):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: AbstractExpression AbstractExpression -&gt; None<br>        &#39;&#39;&#39;<br>        self.left = left<br>        self.right = right<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br><br>        interpret: MultiplyExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return self.left.interpret() * self.right.interpret()</pre><p>Now, in our case, we do not need a division expression, but it should be trivial now to create.</p><h4>We also define a few other expressions</h4><pre># expressions.py<br><br>class PercentAboveExpression(AbstractExpression):<br>    &#39;&#39;&#39;<br>    X% above Y --&gt; (Y) * (1 + X)<br>    &#39;&#39;&#39;<br>    def __init__(self, left, right):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: AbstractExpression AbstractExpression -&gt; None<br>        &#39;&#39;&#39;<br>        self.left = left<br>        self.right = right<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br><br>        interpret: PercentAboveExpression -&gt; float<br>        &#39;&#39;&#39;<br>        return (self.right.interpret()) * \<br>            (1 + self.left.interpret() / 100.0)</pre><pre># expressions.py<br><br>class AverageExpression(AbstractExpression):<br>    def __init__(self, array):<br>        &#39;&#39;&#39;<br>        Returns None.<br><br>        __init__: (list AbstractExpression) -&gt; None<br>        &#39;&#39;&#39;<br>        self.array = array<br>    def interpret(self):<br>        &#39;&#39;&#39;<br>        Returns the value of the expression.<br><br>        interpret: AverageExpression -&gt; float<br>        &#39;&#39;&#39;<br>        sums = list(filter(<br>            lambda x: x != 0, [x.interpret() for x in self.array]<br>        ))<br>        return sum(sums) / len(sums) if (len(sums) &gt; 0) else 0</pre><p>In our case, we need to define two additional expressions:</p><ul><li>PercentAboveExpression, to calculate text such as “20% above coop average”</li><li>AverageExpression, to calculate the average of “20–25/hr” and “34/hr (3rd coop), 38/hr (5th coop), 42/hr (6th coop)”</li></ul><h4>Add a parser</h4><p>Now that we have defined the AbstractExpression and its implementations, we need to write a function that converts an input string to Expression objects.</p><p>To do this, we utilize some properties of the problem. Namely, our goals are to:</p><ol><li>Remove unnecessary text</li><li>Convert variations of phrases such as /year, /yr, and /y to the same value</li><li>Interpret phrases to convert them into the correct expressions</li></ol><p>We first define the following constants in a constants.py file:</p><pre># contants.py<br><br>PER_HOUR = 1<br><br>PER_HR_TO_PER_MO = 40 * 4.34524     # 40 hrs a week, 4.34524 wks a month<br>PER_MO_TO_PER_HR = (                # working hours in a month<br>    1 / PER_HR_TO_PER_MO<br>)             <br><br>PER_YEAR_TO_PER_HR = (              # working hours in a year<br>    1 / (12 * PER_HR_TO_PER_MO)<br>)    <br>PER_WEEK_TO_PER_HR = 1 / 40         # working hours in a week<br>STIPEND_TO_PER_HR = (               # 4-month co-op<br>    1 / 4 / PER_HR_TO_PER_MO<br>)       <br><br>COOP_AVERAGE = {<br>    &quot;2021&quot;: {<br>        &quot;F&quot;: &quot;30.0&quot;,<br>        &quot;S&quot;: &quot;30.0&quot;<br>    }<br>}<br><br>CURRENCY_CONVERTER = {<br>    &quot;CAD&quot;: 1,<br>    &quot;USD&quot;: 1.26,<br>    &quot;¥&quot;: 0.01094<br>}<br><br>INPUT_FOLDER = &quot;inputs&quot;<br>OUTPUT_FOLDER = &quot;outputs&quot;</pre><p>Then, we define the text-cleaning functions remove_articles(string) and remove_symbols(string)</p><pre># helpers.py<br><br>def removeSymbols(string):<br>    &#39;&#39;&#39;<br>    Returns a string with all symbols removed.<br>    <br>    remove_symbols: Str -&gt; Str<br>    &#39;&#39;&#39;<br>    string = string.replace(&quot;$&quot;, &quot;&quot;)<br>    string = string.replace(&quot;\&quot;&quot;, &quot;&quot;)<br>    string = string.replace(&quot;~&quot;, &quot;&quot;)<br>    return string</pre><p>We then create a function to convert currencies called convert_currency(string)</p><pre># helpers.py<br><br>def convert_currency(string):<br>    &#39;&#39;&#39;<br>    Returns a string with all currencies converted to CAD.<br><br>    convert_currency: Str -&gt; Str<br>    &#39;&#39;&#39;<br>    # For each key in CURRENCY_CONVERTER, replace with value<br>    for key in CURRENCY_CONVERTER:<br>        lowered_key = key.lower()<br>        uppered_key = key.upper()<br>        # Special case for yen<br>        if lowered_key == &quot;¥&quot;:<br>            string = string.replace(<br>                lowered_key, <br>                f&quot;{CURRENCY_CONVERTER[uppered_key]} * &quot;<br>            )<br>        else:<br>            string = string.replace(<br>                lowered_key, <br>                CURRENCY_CONVERTER[uppered_key]<br>            )<br>    return string</pre><p>We also define a function to convert variations to a common value fix_variations(string)</p><pre># helpers.py<br><br>def fix_variations(string):    <br>    &#39;&#39;&#39;<br>    Returns a string with all variations such as <br>    /year, /yr /y replaced with multiplications with numbers.<br><br>    fix_variations: Str -&gt; Str<br>    &#39;&#39;&#39;<br>    # /yr<br>    string = string.replace(&quot;/year&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/yr&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/y&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;annual&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/annum&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/a&quot;, f&quot; * {PER_YEAR_TO_PER_HR}&quot;)<br><br>    # If X/hr regex (convert to /mo)<br>    string = string.replace(&quot;/hour&quot;, f&quot; * {PER_HOUR}&quot;)<br>    string = string.replace(&quot;/hr&quot;, f&quot; * {PER_HOUR}&quot;)<br>    string = string.replace(&quot;/h&quot;, f&quot; * {PER_HOUR}&quot;)<br><br>    # Else if X/mo<br>    string = string.replace(&quot;stipend/month&quot;, f&quot; * {PER_MO_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/month&quot;, f&quot; * {PER_MO_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/mo&quot;, f&quot; * {PER_MO_TO_PER_HR}&quot;)<br>    <br>    # Else if X/week or X/wk<br>    string = string.replace(&quot;/week&quot;, f&quot; * {PER_WEEK_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/wk&quot;, f&quot; * {PER_WEEK_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;/w&quot;, f&quot; * {PER_WEEK_TO_PER_HR}&quot;)<br><br>    # Else other cases<br>    string = string.replace(&quot;relocation&quot;, f&quot; * {STIPEND_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;stipend&quot;, f&quot; * {STIPEND_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;signing bonus&quot;, f&quot; * {STIPEND_TO_PER_HR}&quot;)<br>    string = string.replace(&quot;bonus&quot;, f&quot; * {STIPEND_TO_PER_HR}&quot;)<br><br>    string = string.replace(&quot;s&quot;, &quot;&quot;)<br><br>    # Handle thousands<br>    string = string.replace(&quot;k&quot;, &quot; * 1000&quot;)<br>    return string</pre><p>These helper functions can be done more concisely with regex expressions but are coded this way for easy reading.</p><p>We also need one more function for getting the coop average for a given term and year. Here’s what that looks like:</p><pre># helpers.py<br><br>def get_coop_average(term, year):<br>    &#39;&#39;&#39;<br>    Returns the average coop salary for a given term <br>    and year as a float in CAD PER HOUR units.<br><br>    get_coop_average: Str Str -&gt; Float<br>    &#39;&#39;&#39;<br>    return COOP_AVERAGE[str(year)][str(term)]</pre><p>Now, we can use this to create the recursive function parse_expression(string)</p><pre>#salary_parser.py<br><br>import re<br>from expressions import AbstractExpression, AddExpression, \<br>    SubtractExpression, PercentAboveExpression, AverageExpression, \<br>    MultiplyExpression, LiteralExpression<br>from helpers import remove_symbols<br><br>def parse_expression(string):<br>    &#39;&#39;&#39;<br>    Returns an AbstractExpression representing the given string.<br>    <br>    Requires:<br>        - string is a valid salary expression<br>        <br>    parse_expression: Str -&gt; AbstractExpression<br>    &#39;&#39;&#39;<br>    string = string.strip()<br>    # Remove symbols<br>    string = remove_symbols(string)<br><br>    if (string == &quot;&quot;): return AbstractExpression() # FIXME<br>    <br>    # parse any parenthesis if any<br>    result = re.search(r&quot;(\(.*?\)|\(.*$)&quot;, string)<br>    if (result):<br>        resultString = result.string[result.start()+1:result.end()-1]<br>        value = parse_expression(resultString).interpret()<br>        string = string[:result.start()] + &quot; or &quot; + \<br>            str(value) + &quot; &quot; + string[result.end():]<br>        return parse_expression(string)<br><br>    result = re.search(r&quot;(\[.*?\]|\[.*$)&quot;, string)<br>    if (result):<br>        string = string[:result.start()] + string[result.end():]<br>        return parse_expression(string)<br>    <br>    if (&quot;,&quot; in string or &quot; or &quot; in string):<br>        return AverageExpression([<br>            parse_expression(s) for s <br>            in re.split(r&quot;,| or &quot;, string)<br>        ])<br><br>    if (&quot;every add&quot; in string): return AbstractExpression()<br><br>    if (&quot;% above&quot; in string):<br>        parts = string.split(&quot;% above&quot;)<br>        leftString = parts[0]<br>        rightString = parts[1]<br>        return PercentAboveExpression(<br>            parse_expression(leftString), <br>            parse_expression(rightString)<br>        )<br><br>    if (&quot;+&quot; in string):<br>        parts = string.split(&quot;+&quot;)<br>        leftString = parts[0]<br>        rightString = &quot;+&quot;.join(parts[1:])<br>        return AddExpression(<br>            parse_expression(leftString), <br>            parse_expression(rightString)<br>        )<br><br>    if (&quot;above&quot; in string):<br>        parts = string.split(&quot;above&quot;)<br>        leftString = parts[0]<br>        rightString = &quot;above&quot;.join(parts[1:])<br>        return AddExpression(<br>            parse_expression(leftString), <br>            parse_expression(rightString)<br>        )<br>    <br>    if (&quot;below&quot; in string):<br>        parts = string.split(&quot;below&quot;)<br>        leftString = parts[0]<br>        rightString = &quot;below&quot;.join(parts[1:])<br>        return SubtractExpression(<br>            parse_expression(rightString), <br>            parse_expression(leftString)<br>        )<br><br>    if (&quot;*&quot; in string):<br>        parts = string.split(&quot;*&quot;)<br>        leftString = parts[0]<br>        rightString = &quot;*&quot;.join(parts[1:])<br>        return MultiplyExpression(<br>            parse_expression(leftString), <br>            parse_expression(rightString)<br>        )<br>    <br>    if (&quot;to&quot; in string):<br>        parts = string.split(&quot;to&quot;)<br>        leftString = parts[0]<br>        rightString = &quot;to&quot;.join(parts[1:])<br>        return AverageExpression([<br>            parse_expression(leftString), <br>            parse_expression(rightString)<br>        ])<br><br>    if (&quot; &quot; in string):<br>        return AverageExpression([<br>            parse_expression(s) for s <br>            in string.split(&quot; &quot;)<br>        ])<br><br>    if (string.replace(&#39;.&#39;,&#39;&#39;,1).isdigit()):<br>        return LiteralExpression(string)<br><br>    return AbstractExpression()</pre><p>The order of operations in the parse_expession(string) function is important to ensure multiplications occur “first” when evaluating the result.</p><p>In the code above, we use keywords such as the following:</p><ul><li>% above to create a PercentAboveExpression</li><li>+ to create an AddExpression</li><li>below for a SubtractExpression</li><li>* for a MultiplyExpression</li></ul><p>The return value of this function is an Expression object that we can interpret().</p><p>Finally, to parse the lines in the text, we have the main code, which looks like this:</p><pre># main.py<br><br>import argparse<br>import os<br>import re<br>import json<br>import pandas as pd<br>from constants import PER_HR_TO_PER_MO, INPUT_FOLDER, OUTPUT_FOLDER<br>from helpers import get_coop_average, remove_articles, fix_variations<br>from salary_parser import parse_expression<br>from plotter import plot    <br><br>def main(filename, term, year):<br>    &#39;&#39;&#39;<br>    Returns None.<br>    Reads the file in path and gets the average salary for<br>    each company in the file for the given term and year.<br>    The function then saves this data to a csv file.<br>    Also saves a bar chart for the company salaries.<br><br>    Effects:<br>        - Reads the file in path<br>        - Writes to {OUTPUT_FOLDER}/output.csv and <br>        {OUTPUT_FOLDER}/output_top_25_percent.csv<br>        - Writes to {OUTPUT_FOLDER}/output.png and <br>        {OUTPUT_FOLDER}/output_top_25_percent.png<br><br>    Requires:<br>        - term is F, W, or S<br><br>    main: Str Str Str -&gt; None<br>    &#39;&#39;&#39;<br>    companies = {}<br><br>    path = os.path.join(INPUT_FOLDER, filename)<br><br>    # Ensure input folder is created<br>    if not os.path.exists(INPUT_FOLDER):<br>        os.makedirs(INPUT_FOLDER)<br><br>    # Perform the analysis<br>    with open(path, &#39;r&#39;,  encoding=&quot;utf8&quot;) as f:<br>        lines = f.readlines()<br>        for line in lines:<br>            if (len(line.strip()) == 0): continue<br>            line_parts = line.split(&quot;: &quot;)<br>            company = line_parts[0]<br>            # Word joiner character removal<br>            company = company.replace(&quot;\u2060&quot;, &quot;&quot;) <br><br>            salary_string = line_parts[1].replace(&quot;\n&quot;, &quot;&quot;)<br>            salary_string = re.sub(<br>                r&quot;(\d),(\d{3})&quot;,r&quot;\g&lt;1&gt;\g&lt;2&gt;&quot;, <br>                salary_string<br>            )  <br>            salary_string = salary_string.lower()    <br>            salaries = []<br>        <br>            salary_string_part = salary_string<br><br>            salary_string_part = remove_articles(salary_string_part)<br>            <br>            salary_string_part = fix_variations(salary_string_part)<br><br>            salary_string_part.replace(<br>                &quot;coop average&quot;, <br>                get_coop_average(term, year)<br>            )<br><br>            salary = parse_expression(salary_string_part).interpret()<br>            if (salary != 0): salaries.append(salary)<br>            <br>            average = (<br>                sum(salaries) / len(salaries) \<br>                if (len(salaries) &gt; 0) else 0<br>            )<br>            average = average * PER_HR_TO_PER_MO<br><br>            companies[company] = {&quot;CAD/mo&quot;: average}<br><br>    pd.options.display.float_format = &quot;{:,.0f}&quot;.format<br><br>    df = pd.read_json(<br>        json.dumps(<br>            companies, indent=4, sort_keys=True<br>        ), <br>        orient=&#39;index&#39;<br>    )<br>    df = df.sort_values(by=[&#39;CAD/mo&#39;], ascending=False)<br>    df = df[&#39;CAD/mo&#39;].apply(lambda x: int(x))<br><br>    # Ensure output folder is created<br>    if not os.path.exists(OUTPUT_FOLDER):<br>        os.makedirs(OUTPUT_FOLDER)<br><br>    # Save the results<br>    output_path = os.path.join(OUTPUT_FOLDER, &quot;output.csv&quot;)<br>    df.to_csv(output_path, index_label=&quot;Company&quot;)<br><br>    output_path_top_25 = os.path.join(<br>        OUTPUT_FOLDER, <br>        &quot;output_top_25_percent.csv&quot;<br>    )<br>    df25 = df.head(int(df.count() * 0.25))<br>    df25.to_csv(output_path_top_25, index_label=&quot;Company&quot;)<br><br>    # Plot the graph<br>    plot(df, &quot;output.png&quot;)<br>    plot(df25, &quot;output_top_25_percent.png&quot;)<br><br>if __name__ == &#39;__main__&#39;:<br>    parser = argparse.ArgumentParser()<br>    parser.add_argument(<br>        &#39;filename&#39;, <br>        type=str, <br>        help=&quot;File name of input file from input folder&quot;<br>    )<br>    parser.add_argument(&#39;term&#39;, type=str, help=&quot;Term (F/W/S)&quot;)<br>    parser.add_argument(&#39;year&#39;, type=str, help=&quot;Year (e.g. 2021)&quot;)<br>    args = parser.parse_args()<br>    main(args.filename, args.term, args.year)</pre><p>In the code above, we get the per-hour average for each company, convert it to per month, then store it in a Pandas dataframe. We then export the data frame to two CSV files, the full list of ranked companies in output.csv, and the top 25 percent of companies in output_top_25_percent.csv.</p><h4>Now for a visualization!</h4><p>Finally, we plot a visualization using the following code:</p><pre># plotter.py<br><br>import os<br>import pandas as pd<br>import seaborn as sns<br>import matplotlib.pyplot as plt<br>from constants import OUTPUT_FOLDER<br><br>def plot(df, output_filename):<br>    &#39;&#39;&#39;<br>    Returns None.<br>    Plots the data in the dataframe df.<br>    Saves the output to {OUTPUT_FOLDER}/{output_filename}<br>    <br>    Effects:<br>        - Writes to {OUTPUT_FOLDER}/{output_filename}<br>    <br>    Requires: <br>        - df is a dataframe with two columns: Company and CAD/mo<br>        <br>    plot: DataFrame Str -&gt; None<br>    &#39;&#39;&#39;<br>    print(df.reset_index())<br>    # Plot the data<br>    sns.set(style=&quot;whitegrid&quot;)<br>    fig, ax = plt.subplots(figsize=(20, 0.25 * len(df)))<br>    g = sns.barplot(<br>        data=df.reset_index(), y=&quot;index&quot;, x=&quot;CAD/mo&quot;, <br>        ax=ax, palette=&quot;blend:limegreen,dodgerblue&quot;<br>    )<br>    g.set_title(&quot;Average Co-op Salaries&quot;)<br>    g.set_xlabel(&quot;CAD/mo&quot;)<br>    g.set_ylabel(&quot;Company&quot;)<br><br>    fig.tight_layout()<br><br>    path = os.path.join(OUTPUT_FOLDER, output_filename)<br>    fig.savefig(path)</pre><h4>Where to find more design patterns</h4><p>This is only one of the many design patterns that show the power of Object-Oriented Programming. I have also shown how to implement the <a href="https://medium.com/swlh/how-to-implement-the-memento-design-pattern-for-reactjs-1eb6b76c39c0">Memento pattern in another article</a>. If you want to learn more about Design Patterns, I highly recommend the book <em>Design Patterns: Elements of Reusable Object-Oriented Software</em> by Erich Gamma et al. (The Gang of Four). I would go so far as to call it the bible of programming.</p><h3>GitHub Repository</h3><p>Feel free to check out the source code here: <a href="https://github.com/justinsj/interpreter-coop-salaries">https://github.com/justinsj/interpreter-coop-salaries</a></p><p>Stay tuned for more if you enjoyed this article or learned something from it!</p><p>If you also have anything to suggest, let me know in the comments or message me on <a href="https://www.linkedin.com/in/justin-sj/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=594a54a74ebb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-implement-the-interpreter-pattern-for-messy-data-in-python-594a54a74ebb">How To Implement the Interpreter Design Pattern for Messy Data in Python</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How much do you earn from a master’s or doctoral degree?]]></title>
            <link>https://justinsj.medium.com/how-much-do-you-earn-from-a-masters-or-doctoral-degree-cf1eb95db02f?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf1eb95db02f</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[graduate-school]]></category>
            <category><![CDATA[financial-freedom]]></category>
            <category><![CDATA[personal-finance]]></category>
            <category><![CDATA[financial-planning]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 13:01:19 GMT</pubDate>
            <atom:updated>2022-11-04T13:01:19.443Z</atom:updated>
            <content:encoded><![CDATA[<p>Graduate degrees such as a master’s and doctoral (PhD) degree can be a great financial investment, but by how much?</p><p>In this article, I break down the costs and benefits of graduate degrees and look at ways to justify (or reject) this option. In particular, I focus on my experience from my thesis-based Master of Mathematics in Computer Science program at the University of Waterloo. Nonetheless, the insights written here also apply for doctoral degrees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*mzA6ZPpGR6-Jz75XDypfaA.png" /><figcaption>Figure 1. Projection of savings comparison from a Master degree to a Bachelor degree.</figcaption></figure><h3>First of all, a graduate degree is not for everyone</h3><p>The benefits you can gain from a graduate degree varies across industries and where you are in your career.</p><p>For example, the marginal benefit you gain from a degree diminishes the more experience you have in the industry (e.g. a fresh graduate v.s. 10 years of work experience).</p><p>Pursuing a graduate degree allows you to learn more about theory and allows you to specialize in a subfield in your industry. You will have more time to delve into fundamental concepts and understand niche insights compared to working directly after a bachelor’s degree or high school. This is because in a workplace, you are often pushed to complete tasks as soon as possible, leaving no time to develop a well-thought-out solution.</p><h4>There are also many project management skills that you can gain from a graduate degree</h4><p>Because a graduate degree is usually self-paced, I personally learned to look at the bigger picture, to prioritize goals with potential for <strong>huge impact</strong>, and work backwards from said goals.</p><p>I have also learned to absorb information quickly and be question-oriented when reading through numerous articles.</p><p>Overall, pursuing a graduate degree can train you to be autonomous, independent, and high-performing.</p><h3>A master’s degree gives you $380,000 more at retirement</h3><p>I used a <a href="http://finance.justinsj.com/">financial planning application</a> that I made to understand the economics of a graduate degree before pursuing it. The main benefit of this application is being able to <strong>visualize your finances with taxes automatically incorporated</strong> into the projections. This allows you to plan big-ticket decisions such as buying a house, a car, or… a graduate degree!</p><p>Like any financial planning application, it is <strong>garbage-in-garbage-out: </strong>if you use unrealistic numbers, you will get unrealistic results.</p><h4>The parameters for comparison</h4><p>Using the application, I compare a bachelor’s degree salary with the costs and salary gain from a master’s degree. I used numbers researched from online sources:</p><ul><li>The industry is Computer Science (for salary information)</li><li>A conservatively low bachelor’s degree salary of CAD 6000 / mo (Computer Science graduates that go to Silicon Valley / investment banking companies and the like earn much more)</li><li>Master’s degree pay raise of 15% ([<a href="https://www.indeed.com/career-advice/pay-salary/how-much-does-degree-increase-earnings">source</a>] claims a 20% increase)</li><li>The master’s degree takes 2 years (master’s degree salary starts after two years, and relevant funding lasts for 2 years, while the bachelor’s salary starts from year 0)</li><li>Both pay rates increase at 3%, inflation rate average of 3%</li><li>Using taxes in Canada, Ontario, Waterloo.</li><li>Tuition and funding is based on Fall 2021 entry to University of Waterloo’s Master’s program (e.g. tuition of around CAD 50,100 for 2 years (6 terms), and approximately CAD 3,317 of funding per month)</li></ul><p>The projection in Figure 1 can be loaded via <a href="https://finance.justinsj.com/load/?d=XQAAAAIFDAAAAAAAAABBKUpnQypgZFifTAmQ0XIa5VjiSUtNor1joTj7kV2Z9YuCdi7jYZfzav988R4YR-rzWPXf8XdaAWym0XTzNB2USVtiCDiYWle_mg-akA55uH82XQ2lmrdBqlfucQOo4DBtGS3zioNptXj1gG8NDSyLaSMK9YdxVIvEwJuzNwlrfMUGnoyNJqjC20MSQmE3r1C-77PbGxxv7qOgrjc-r86etulW43Nr67kec1cDgaFKQiWCBq_jXEBdXQ-_yGJ83AMpC-p6WgCDp2yMQncnX40Wbj-JSs5mrVFdcHWYlyJmVi78SG1hWgt6Cv_XSw_ckhZUYu7eY7KkmCz44YXETRlmE_Bv22dDhyZ6er-0N6-oR46oB6-s6ojdpSMCYCLIvCxBhedWp021xU-AymUqfNN4kJOzqvSyCmH8Z8TLSRLluCsZaVT9n2uSiofxFBiBoE7rIiGzXS-5VSPsaC9JarWMKpG7RbKtGioECS5at7gUuq1voj4WFwpSnpJyO0vgKZ2q9hrGz1tftvr_Y0V5Tc-sOG8swqviWoAwE89mXzfgmI34SCPNOAAjO9b9MzKI5Nkbv_pTvFEvomTnhlmpkQ5aZFFnw1hzawVn67mgufmaW-1NLmlcStdAPg2BX-QSgPtpKGedcLrrgtLlrjAxvJ-JsD0Zdo5GfCn4YSEYSDUn-hk-Vr1xra5tfI7ma3TMlAlR4fZjXiHN99ubxbFzTalXjGjrR2W-yZlnF6DqHcuO2v62jdozQCt5UxBMOU3jY1MKzsGY7S7OP-4hp2RCtZ0XFkNBaecQVqnqNtcqeRuHPi-wCeeXfW69hP5tThz-tSKzCFOWUVOXaF93wdRMo5ynmYbMjfDulkPH_GH1TEjtTBmBfy3tEhf0aA12Hqc4hr5JTfdOSaguj3fYdIjXM7Y2gDXwfZzI9RMbVCPuMHBVfJmWlOSFC6txLX0MQRG7ukKVgOXtnCDrp7BqlaGmy_w6iZwFNSGOcv5zbp_0FuGeH3bdP_GmbXf2luJv4nZpOtB7XxZ0YhctLGeCX5uuFjWgEqLckIq60sIWQq36xGZkhfk5bNDrCwOBijiFVMPqpfgaqVmijYi5eCsHUxClLCMnRRjrDV61Dw4Bux3xqYFWPUYApAtmj6H5-TTGPc1jgX4HMMu-2o-G533huSmYoJv2jgEoeADVR3QPYpTSEzAmFbT6fJErOMgVm-JmQF9QfJ6OGfvHpzI_aUzuGjeDMOeYl1f9leSWUBjX3odRgmsIUTwoe_MNl8EDTfYkUeIEZ-UE_6vRdz-B0zpb5-cPNoI0iCU4Ea3gjASXwppkoEjMT2kmr7Dhab0DPAyEPaKkBhGeTnvxgtdvZw6g_jVYV6K7J2EZZgFnJghZRksYXinX5pNZfqitJ9947_KLJYIbDDa934KwiT08ZtQopUsV_HZ-QCil30IwU-TFaWB-VDWvCzsVwELpMVCXQAkNDA3oFGEwy4b-OtCBExzG5lSBGNG-EK8BrZTE_g-8Qw"><strong>this link</strong></a>.</p><p>To perform this comparison in the application, we set the bachelor’s degree salary to be negative.</p><h4>The breakeven for the master’s degree, assuming conservative estimates, is 13 years</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*gunOimZUANcH0gWEUFM7qQ.png" /><figcaption>Figure 2. Projection showing the breakeven point for a Master degree compared to a Bachelor degree.</figcaption></figure><p>What does this mean?</p><p>That means in 13 years (as shown in Figure 2), you will have made the same amount of money as if you did not pursue the graduate degree. At the same time, your salary is higher at that point in time, meaning you will earn even more than your bachelor self moving forward.</p><p><strong>But how much more?</strong></p><h4>At the end of retirement (assuming a retirement age of 65 and 40 years of working), you will have earned ~CAD 380,000 more</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ByKjlu69SdJEQg33WhHJFg.png" /><figcaption>Figure 3. Projection of additional savings at the end of 40 years of working for a master’s degree compared to a bachelor’s degree</figcaption></figure><h4>Taking into account interest rates / inflation at 3%, this is equivalent to getting CAD 116,480.87 now.</h4><p>This is because of the “time value of money” (e.g. a dollar 40 years from now is less valuable as a dollar now).</p><p>What does this look like in other terms?</p><h4>This is equivalent to an additional 2x CAD 2,488 week-long vacations every year or an additional CAD 94.2 per week</h4><p>These numbers are of course subject to your actual increase in earnings (Hopefully above 15%!)</p><h3>BONUS: Without adjusting for taxes, your projections would be off by 77%!</h3><p>The projection without taxes can be seen in <a href="https://finance.justinsj.com/load/?d=XQAAAAIJDAAAAAAAAABBKUpnQypgZFifTAmQ0XIa5VjiSUtNor1joTj7kV2Z9YuCdi7jYZfzav988R4YR-rzWPXf8XdaAWym0XTzNB2USVtiCDiYWle_mg-akA55uH82XQ2lmrdBqlfucQOo4DBtGS3zioNptXj1gG8NDSyLaSMK9YdxVIvEwJuzNwlrfMUGnoyNJqjC20MSQmE3r1C-77PbGxxv7qOgrjc-r86etulW43Nr67kec1cDgaFKQiWCBq_jXEBdXQ-_yGJ83AMpC-p6WgCDp2yMQncnX40Wbj-JSs5mrVFdcHWYlyJmVi78SG1hWgt6Cv_XSw_ckhZUYu7eY7KkmCz44YXETRlmE_Bv22dDhyZ6er-0N6-oR46oB6-s6ojdpSMCYCLIvCxBhedWp021xU-AymUqfNN4kJOzqvSyCmH8Z8TLSRLluCsZaVT9n2uSiofxFBiBoE7rIiGzXS-5VSPsaC9JarWMKpG7RbKtGioECS5at7gUuq1voj4WFwpSnpJyO0vgKZ2q9hrGz1tftvr_Y0V5Tc-sOG8swqviWoAwE89mXzfgmI34SCPNOAAjO9b9MzKI5Nkbv_pTvFEvomTnhlmpkQ5aZFFnw1hzawVn67mgufmaW-1NLmlcStdAPg2BX-QSgPtpKGedcLrrgtLlrjAxvJ-JsD0Zdo5GfCn4YSEYSDUn-hk-Vr1xra5tfI7ma3TMlAlR4fZjXiHN99ubxbFzTalXjGjrR2W-yZlnF6DqHcuO2v62jdozQCt5UxBMOU3jY1MKzsGY7S7OP-4hp2RCtZ0XFkNBaecQVqnqNtcqeRuHPi-wCeeXfW69hP5tThz-tSKzCFOWUVOXaF93wdRMo5ynmYbMjfDulkPH_GH1TEjtTBmBfy3tEhf0aA12Hqc4hr5JTfdOSaguj3fYdIjXM7Y2gDXwfZzI9RMbVCPuMHBVfJmWlOSFC6txLX0MQRG7ukKVgOXtnCDrp7BqlaGmy_w6iZwFNSGOcv5zbp_0FuGeH3bdP_GmbXf2luJv4nZpOtB7XxZ0YhctLGeCX5uuFjWgEqLckIq60sIWQq36xGZkhfk5bNDrCwOBijiFVMPqpfgaqVmijYi5eCsHUxClLCMnRRjrDV61Dw4Bux3xqYFWPUYApAtmj6H5-TTGPc1jgX4HMMu-2o-G533huSmYoJv2jgEoeADVR3QPYpTSEzAmFbT6fJErOMgVm-JmQF9QfJ6OGfvHpzI_aUzuGjeDMOeYl1f9leSWUBjX3odRgmsIUTwoe_MNl8EDTfYkUeIEZ-UE_6vRdz-B0zpb5-cPNoI0iCU4Ea3gjASXwppkoEjMT2kmr7Dhab0DPAyEPaKkBhGeTnvxgtdvZw6g_jVYV6K7J2EZZgFnJghZRksYXinX5pNZfqitJ9947_KLJYIbDDa934KwiT08ZtQopUsV_HZ-QCil30IwU-TFaWB-VDWvCzsVwELpMVCXQAkNDA2_eD2fuxjedkLvM5WbgdumXR22-SVe3Uz9gqm1yf8TI2oA"><strong>this link</strong></a>.</p><p>With the same inputs, we can select the tax location to no taxes. With this setting, the projected savings at the end is CAD 672,707 which is 77% more than if you included taxes.</p><h3>Conclusion</h3><p>In this article, I have compared the earnings increase of pursuing a master’s degree with the costs of the degree, and opportunity cost of sticking with a bachelor’s degree. The insights gained from this article can be extrapolated into the expected benefits of a doctoral degree.</p><p>You can use <a href="https://finance.justinsj.com/">finance.justinsj.com</a> to automatically incorporate taxes and make your own projections.</p><p>If you found this article useful or enjoyed it, I would really appreciate <em>your clap</em> :)</p><p>If you have more ideas that you think can help, send me a message or comment down below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf1eb95db02f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Performance metrics every system architect should know]]></title>
            <link>https://justinsj.medium.com/5-performance-metrics-every-system-architect-should-know-e23a53442a12?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e23a53442a12</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-performance]]></category>
            <category><![CDATA[it-service-management]]></category>
            <category><![CDATA[system-architecture]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 28 Oct 2022 13:01:53 GMT</pubDate>
            <atom:updated>2022-10-28T13:01:53.057Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I describe a few (non-exhaustive) performance metrics every system architect should know.</p><h3>The goal of system architects is to design and oversee the development of IT infrastructure that supports business goals</h3><p>Firstly, we need to understand what a system architect does:</p><blockquote>A system architect is in charge of devising, configuring, operating, and maintaining both computer and <a href="https://www.bmc.com/blogs/enterprise-networking/">networking systems</a>. They objectively analyze desired processes and outcomes and advise on the right combination of <a href="https://www.bmc.com/blogs/what-is-it-infrastructure-and-what-are-its-components/">IT systems and components</a> to achieve specific business, department, team, or functional goals (Shiff, 2022).</blockquote><p>With this, every system architect must fully understand the different IT services being supported, how they interact with each other, and the performance requirements of each one and as a whole.</p><h3>There are 5 important metrics useful for measuring service performance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*twvfzVxS7E3zI3W-8rF0Ow.png" /><figcaption>Figure 1. A simple request, process, response sequence between two services.</figcaption></figure><h4>1. Latency (first-byte)</h4><p>The first important metric is the first-byte latency. This is the time it takes for the smallest input (typically a single byte) to be processed from the start of the request to the end of the response. These are often what are written in hardware or system specifications (e.g. disk latency, memory access latency, etc.).</p><h4>2. Latency (end-to-end)</h4><p>The end-to-end latency, similar to first-byte latency, is the time it takes from the start to finish of the transaction. The difference between the two arises due to processing times that depend on the size of the input. For example, matrix multiplication between two 1000x1000 matrices takes longer than two 2x2 matrices.</p><p>This is the performance metric that system architects need to be aware of for every service. It is especially important when gathering numbers to be aware of this relationship between latency and input size. For example, comparing the end-to-end latency of processing a small input to a large input is like comparing apples to oranges.</p><h4>3. Throughput</h4><p>Throughput is the number of tasks that a service completes within a given time range. For example, services are often measured in terms of requests per second (rps).</p><h4><strong>4. Bandwidth</strong></h4><p>Bandwidth is the maximum rated capacity of a service. A typical example of this is network bandwidth, which is what is advertised by the Internet Service Provider (ISP) based on the specifications of hardware used.</p><p>In a service, the bandwidth is essentially the maximum number of requests it can process per second. In contrast, throughput is the actual requests per second that is realized by the system, which is equal to or less than the bandwidth.</p><h4>5. Concurrency</h4><p>Finally, concurrency is the number of requests that a service can process at the same time. Note that this is measured with a time duration as the denominator (e.g. 100 concurrent requests v.s. 1000 requests per second).</p><p>The maximum concurrency of a system and the average latency of requests define the bandwidth of the system:</p><blockquote>100 concurrent requests * 500ms requests means = bandwidth of 200 requests per second</blockquote><h4>System architects need to identify the bottleneck in order to find opportunities for improvement</h4><p>To increase the performance of a system, different strategies could be used. For example, decreasing the end-to-end latency of requests by minimizing the processing time can increase the bandwidth of the service. Similarly, horizontally scaling the service by adding more worker nodes can increase the concurrency and thus can also increase the bandwidth of the service.</p><h4>To identify such opportunities, system architects can think like chemists</h4><p>An analogy to Chemistry is that in a chemical reaction, with material inputs converted to outputs, the expected amount of output can be determined by finding the “limiting reagent”.</p><p>In IT services, the bottleneck can be the memory space of a system. For example, a worker node may only be able to host 4 instances of a service due to the memory size of each service being a quarter of the worker node’s memory capacity.</p><p>Since memory is the limiting reagent, the compute power of the worker node must be underutilized. To tackle this, decreasing the memory size of the instances, or even shuffling instances in the memory through paging could be techniques to increase the bandwidth of the service.</p><h3>Conclusion</h3><p>In this article, I have described 5 important performance metrics that system architects should be aware of. These metrics are first-byte latency, end-to-end latency, throughput, bandwidth, and concurrency. To identify ways to improve a service and meet desired performance levels, the system architect must identify the bottleneck in the system. Knowing the bottleneck will point to solutions that will help, and rule out solutions that will not.</p><p>If you enjoyed this article or learned something from it, I would really appreciate <em>your clap</em> :)</p><p>If you have more ideas that you think can help, send me a message or comment down below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e23a53442a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you need to build habits AND set goals]]></title>
            <link>https://justinsj.medium.com/why-you-need-to-build-habits-and-set-goals-36d6de1a1845?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/36d6de1a1845</guid>
            <category><![CDATA[habits-for-success]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[goals-in-life]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 13:02:19 GMT</pubDate>
            <atom:updated>2022-10-21T13:02:19.926Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describes the benefits of building habits, and why you need to pair them with goals. The underlying force of why we want to build habits and set goals is to maintain high motivation to be productive in our lives.</p><h3>The benefits of building habits</h3><p>There are several life-changing keystone habits. These include regular exercise, bullet journaling, reading, and meditation according to <a href="https://www.youtube.com/watch?v=GriR73kSvPY">Improvement Pill’s video on ranking 32 habits</a>. Among other powerful habits are cooking, writing, socializing, etc.</p><h4>The reasons these habits are great is because they focus on your health</h4><p>That is, they generally revolve around physical, mental, and emotional health. This allows you to become more energized, recuperate, and develop better learning from your daily life.</p><h4>Another reason building habits is good is to exhibit continuous progress</h4><p>This is another important point from Improvement Pill’s video where our many failures in life can lead to significant demotivation especially when we are aiming for a lofty goal. This is because success and failure are binary results — either we did it or not. Meanwhile, building the right habits contribute the chances of our next attempt being successful.</p><p>For example, if our goal is to become an entrepreneur and start a successful business, an important habit to build is to talk to customers, and even if several of our businesses fail, it is crucial to recognize that we are actually closer to achiveing our goal.</p><h4>A view from a different lens — Failing multiple times is like running in circles, building habits is like rising in a spiral</h4><figure><img alt="Building habits is an upward spiral rather than running in circles" src="https://cdn-images-1.medium.com/max/411/1*IBx9WOV2QaIhXiSGkpXA_w.png" /><figcaption>What feels like running in circles is an upward spiral if you build powerful habits.</figcaption></figure><p>In my own experience in developing a thesis for my Masters program, I had to find a topic that was not yet well-researched. I numerous topics one after another, each time finding that this problem had already been addressed. This felt like running in circles as I was back to not having a topic every time.</p><p>However, along the way, I developed strong habits that accelerated my research paper reading skills. Specifically, this is the habit of first developing target questions and then scanning papers first to find the answers instead of reading the whole paper in one go. Because of this, later iterations of this topic-search process were easier. Eventually, after looking through 6 different topics in the field of Serverless architecture and Networking, I settled on a 7th topic involving accelerating GPU cold starts in serverless data centers.</p><h3>The limitations of building habits</h3><p>However, just building habits for the sake of building habits will still lead to demotivation. This is speaking from personal experience. In my case, reading papers on a regular basis is a good habit, but it felt like my newly developed skills have only gotten me so far. Remembering and reminding myself of the goal of completing the thesis program and getting better leverage in my industry helped empower me to move forward. It also helps to break such broad goals down into smaller phases to make it feel closer and more achievable.</p><h4>Without a dream, there is no real reason to build a habit</h4><p>In this case, you will find yourself with no motivation even if you have build the habit without seeing progress made to some direction. A quick reminder of WHY you are building a habit is important.</p><p>It is important to note that busy ≠ productive —just because you are fully occupied, does not mean you will acquire a sense of achievement. It is crucial then to set goals that matter to you.</p><h3>The benefits of setting goals</h3><h4>Setting goals can inspire you to work towards it</h4><p>Our goals, whether it is to become an influencer, become a data analyst, or to become an athlete, help motivate us to take action.</p><h4>The path towards it becomes clearer when we set our goals</h4><p>By starting with “what success looks like”, it then becomes easier to work backwards, and find out that in order to reach some milestone of say, getting 100k followers, we need to begin writing articles every week.</p><p>Why this works so well is because by setting our goals, we fix a point in our future of where we want to be, then any action we plan on taking from now on can easily be deciphered as building towards it, or not.</p><h3>The limitations of setting goals</h3><h4>Goals give binary results, which can be disappointing</h4><p>As mentioned before, because we either succeed or fail in meeting our goals, it can lead to demotivation when we fail. Goals have no means of showing progress, and thus are limited in that way.</p><h4>Goals can and tend to be too broad</h4><p>Some argue that you should make your goals as wild as possible (e.g. aim to make 10 million this year instead of just aiming for 100 thousand (Ferris, 2009) in the book “The 4-Hour Workweek”. Whether your goal is wild or not, analyzing this goal and working backwards to define next steps is crucial to gaining the motivation to work towards it.</p><h4>Reaching your goal can lead to demotivation</h4><p>Upon climbing to the top of a mountain, we can breathe in the fresh air and a great view, but from there, if there is no other mountain in sight, the path ahead is only downwards. When we meet our goals, especially after an immensely long journey, focusing on the lack of further goals, and not paying attention to the positive habits that we have built and is fuel for pessimism.</p><h4>Some claim that talking about your goals makes you less inclined to doing it</h4><p>Derek Sivers in a <a href="https://www.ted.com/talks/derek_sivers_keep_your_goals_to_yourself?language=en">2014 TED talk</a> says this because when you talk about your goal, you picture yourself more in your completed state, allegedly causing you to be more complacent and not work towards it.</p><p>Arguably for me, discussing my goals with my peers helps me refine them and energizes me to work towards it.</p><h3>Conclusion</h3><p>Overall, the path towards meaningful productivity rather than wasteful occupancy looks like setting a high-level goal for ourselves, working backwards to what our next steps should be, then building the habits to maximize our chances of reaching that goal.</p><p>I hope these tips can help you become more productive and motivated. If so, I really appreciate <em>your clap</em> :)</p><p>If you have more ideas that you think can help, send me a message or comment down below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36d6de1a1845" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proactive or Reactive Provisioning, Which is Better in Serverless Systems?]]></title>
            <link>https://justinsj.medium.com/proactive-or-reactive-provisioning-which-is-better-in-serverless-systems-13a8b44b5da4?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/13a8b44b5da4</guid>
            <category><![CDATA[resource-management]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[scheduling]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 14 Oct 2022 14:14:15 GMT</pubDate>
            <atom:updated>2022-10-14T14:14:15.626Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describes the similarities and differences of scheduling policies in serverless. In partcilar, I will focus on the dimension of proactive v.s. reactive provisioning in the environment of serverless systems. I list out the different policies by goal and effect, then briefly describe each one.</p><p>The paradigm of “serverless” consists of two main parties: the <strong>service provider</strong>, and the <strong>business customer</strong>.</p><p>The business customer itself includes developers that upload code to the service provider. The business customer also has end-customers that request the usage of the uploaded code via an Application Programming Interface (API). These requests may be triggered from interacting with the business’ website, or other devices used by the business.</p><h4>The overall objective of Serverless is to provide businesses with an economic “pay-as-you-go” option for hosting code, with comparable performance to on-site servers.</h4><p>Serverless service providers are able to build a business through economies of scale and sharing its infrastructure with multiple tenants (business customers). For example, businesses who purchase a couple of server-grade machines are likely not going to use them 100% (maximum utilization), which means there is space for sharing this capacity, which is what serverless service providers do.</p><p>On the business customer side, this enables businesses to use the compute infrastructure on-demand, thus only paying for what it uses, rather than paying the up-front capital cost of building / setting up servers and the necessary network infrastructure.</p><figure><img alt="Golden balance to represent tradeoff of performance and resource efficiency in serverless scaling policies." src="https://cdn-images-1.medium.com/max/1024/1*ILe6HAXmD3wRB0VHtJggfg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@miracleday?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Elena Mozhvilo</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>The main problem in serverless is “cold starts“— in order to share the infrastructure, the business customers’ code needs to be shuffled in and out, which leads to several requests occurring with no instance of the code already running.</h4><p>To tackle this problem serverless service providers rely on scheduling techniques to manage the trade-off between cold start penalties and server utilization.</p><p>There are several examples of scheduling policies adopted by current commercial offerings of Serverless:</p><ul><li><a href="https://www.usenix.org/conference/atc18/presentation/wang-liang">AWS Lambda: Bin Packing</a> — AWS Lambda appears to aim to have the fewest possible number of instances running to serve a load of requests. AWS Lambda uses the amount of memory required by the function as declared by the developer to determine if new VMs need to be instantiated to meet demand.</li><li><a href="https://cloud.google.com/compute/docs/autoscaler">Google Cloud Functions (GCF): Utilization-based</a>— Google enables the most configurability in its developer-specified scaling policy. However, this is arguably contradictory to the paradigm of serverless where it should be the role of the service provider to scale instances in and out. GCF allows developers to use CPU utilization, HTTP serving rate, and cloud metrics as signals to scale in and out. GCF also allows developers to <a href="https://www.infoq.com/news/2021/09/cloud-functions-min-instances/">set the minimum number of instances</a> to reduce the cold start frequency for a function.</li><li><a href="https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/event-driven-scaling.md">Microsoft Azure Functions: Queue-Length Based</a>—Azure Functions scale differently depending on the trigger. For example, using an Azure Queue storage trigger, scales the number of instances using the queue length and age of the oldest queue message.</li></ul><p>Other scheduling techniques include:</p><ul><li><strong>Heuristics — Least Connections, Round Robin</strong>. These scheduling policies are often mentioned in load balancing. As a note, these do not determine the amount of server resources allocated to a certain piece of code and thus are not provisioning policies.</li><li><strong>More Bin-Packing Scheduling</strong> — On the contrary, some scheduling policies like bin-packing can influence the system’s provisioning strategy. For example, the popular open-source OpenWhisk serverless platform relies on keep-alive timeouts to reduce the number of instances when an instance is not used. It uses a hashing scheduler that attempts to schedule requests primarily on the “first” available worker based on an order defined by a hashing function, allowing older instances to become stale and deallocated.</li><li><strong>More Utilization-based Scaling</strong>— One of the challenges with bin-packing scheduling is runtime performance degradation due to sharing VM resources among multiple containers as discussed in TK1. To address this, TK2 aims to balance runtime performance with resource efficiency by setting a target range of CPU / memory utilization, and scaling instances in-out based on that.</li><li><strong>Prediction-based — </strong>Ideally, if the number of incoming requests can be predicted, instances can be pre-provisioned as the rate or requests increase. Several works including (<a href="http://rboutaba.cs.uwaterloo.ca/Papers/Journals/2013/ZhangJSAC13.pdf">Zhang et al, 2013</a>) and (<a href="https://www.usenix.org/system/files/atc19-zhang-chengliang.pdf">Zhang et al, 2019</a>) use Auto-Regressive Integrated Moving Average (ARIMA) and LSTM ML models respectively to predict the future request rate and scale in/out correspondingly. In addition, functions in a pipeline (function chain) can be more easily predicted (<a href="https://dl.acm.org/doi/10.1145/3423211.3425690">Daw et al, 2020</a>), (<a href="http://faculty.washington.edu/wlloyd/courses/tcss562/papers/ETAS-predictiveSchedlingofFunctionsonWorkerNodesofApacheOpenWhiskplatforms.pdf">Banaei and Sharifi, 2021</a>). The main limitation of these methods depend on the predictability and amount of historical information of the workload. These works also incur large computational overhead due to the usage of ML models to perform the inference for scheduling actions that occur at 1000s of requests per second.</li><li><strong>Logistics-based — </strong>Another class of scheduling techniques are based on the study of logistics and queuing theory. For example, (<a href="https://www3.cs.stonybrook.edu/~anshul/acsos20_ensure.pdf">Suresh et al, 2020</a>) uses the <a href="https://www.networkpages.nl/the-golden-rule-of-staffing-in-contact-centers/">square-root staffing policy</a> to pre-provision extra resources based on the volatility of demand and a target service rate (cold start frequency).</li></ul><h4>A provisioning strategy determines when instances of code are “warmed up”.</h4><p>Now, let’s divide these methods by proactive and reactive provisioning strategies.</p><h4>Proactive Provisioning</h4><p>These methods typically aim to increase performance (by reducing cold start frequency) while sacrificing server utilization. This is done by proactively running instances of code, which could remain unused but is prepared to receive new requests.</p><p>Serverless service providers that use this policy tend to continue charging by the actual number and duration of requests, thus absorbing the idle resource cost instead of passing the cost of running idle servers to the business customers.</p><p>Proactive provisioning policies include:</p><ul><li>Prediction-based policies</li><li>Utilization-based policies</li><li>Logistics-based policies</li></ul><h4>Reactive Provisioning</h4><p>These methods aim instead to minimize resource costs by lazily instantiating new instances of request code when the current allocation of servers do not meet an increasing load of oncoming requests.</p><p>By doing this, serverless service providers do not incur additional idle server costs, but sacrifices performance by having an increased frequency of cold starts. This may be unattractive for business customers that have stringent latency requirements.</p><p>Reactive provisioning policies include:</p><ul><li>Bin-packing policies</li></ul><h3>How can these problems be solved?</h3><p>There are different research directions to tackle this trade-off between resource efficiency and performance, which include:</p><ul><li><strong>Reducing the cost cold start. </strong>By reducing the cost of cold starts, reactive provisioning can become more attractive. This is because idle resources can be instead used for actual computation rather than awaiting future requests that may not arrive. Reactive provisioning with low cold start costs are especially attractive with increasing adoption of accelerators such as GPUs in serverless due to the expensive nature of GPUs.</li><li><strong>Accurately predicting future workload. </strong>As noted previously, accurate prediction of workloads can ideally allow maximum resource utilization while minimizing cold start penalty. Workload prediction works in both individual functions as well as function chains.</li><li><strong>Reducing the cost of idle resources. </strong>Under the paradigm of proactive provisioning to minimize cold start frequencies, an alternative is to reduce the cost of idle resources. This can be done by using cheaper / lower-end machines to host proactively provisioned instances.</li></ul><h3>Conclusion</h3><p>This article compares and contrasts proactive and reactive provisioning strategies. There are more diverse proactive provisioning policies than reactive. This article starts by identifying the motives of actors in the serverless paradigm, mainly service providers and business customers, then by identifying commercial scheduling policies and relating them back to provisioning policies. Finally, future directions for research in serverless are provided.</p><p>If you enjoyed this article and want more, I would really appreciate <em>your clap</em> :)</p><p>If you have more ideas that you think can help, send me a message or comment down below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13a8b44b5da4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Acute Procrastination Syndrome — and How to Cure It with 3 Tips]]></title>
            <link>https://justinsj.medium.com/acute-procrastination-syndrome-and-how-to-cure-it-with-3-tips-b4a5758977e7?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4a5758977e7</guid>
            <category><![CDATA[procrastination]]></category>
            <category><![CDATA[productivity-tips]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 14:32:04 GMT</pubDate>
            <atom:updated>2022-10-07T14:32:04.734Z</atom:updated>
            <content:encoded><![CDATA[<h3>Acute Procrastination Syndrome — and How to Cure It with 3 Tips</h3><p>I’m often known for being interested in a topic or hobby for a short period of time and leaving several projects unfinished. If you face this too, then you are not alone. In this article, I will describe <strong>3 key tips </strong>to avoiding this level of procrastination.</p><p>When it comes to craft hobbies, I always purchase necessary equipment, finish one sample, then tend to move on to another hobby.</p><p>When it comes to entrepreneurship, I believe I put enough effort to discover that these ideas are not worth pursuing.</p><p>This type of issue can be seen in many different levels, and is what I would call “Acute Procrastination Syndrome”.</p><p>Recently, I have noticed this in the number of drafts that have accumulated in my Medium account in Figure 1. This shows that I frequently delve into a topic, write a few key points about it, but usually do not complete an article about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uonp_yKm3OGXHuEolushPQ.png" /><figcaption>Figure 1. An accumulation of drafts.</figcaption></figure><p>To understand this problem, we need to break it down into the forces involved.</p><p>On one end, we want to finish a project. However, the project often appears too daunting for us to tackle, thus we leave it to a later time when we feel more ready to face it. This then repeats and the cycle of procrastination goes on indefinitely. This issue is also compounded by the number of different interests we have, which give more reason to leave other projects for another.</p><p>These are the key forces that lead to procrastination:</p><ul><li>The scope of a project is too big</li><li>You have many things to work on, but do not know what to prioritize</li><li>There is no urgent deadline for the project</li></ul><p>In order to tackle these, the following tips are essential:</p><ol><li><strong>Break down (quantize) the project into phases, and limit the scope. </strong>Once the phases of a project are identified, you can break it down further into standalone, relevant, bite-sized tasks. This will help you get over the initial procrastination barrier and consistently get you into a flow state. It will also help you continuously make progress, which encourages you further to complete the project. Taking the example of writing articles on Medium, I narrowed down the scope of the broad topics I had in mind by avoiding topics that I have no significant experience in.</li><li><strong>Learn how to prioritize</strong> among tasks using <a href="https://justinsj.medium.com/the-one-prioritization-method-that-boosts-my-productivity-and-focus-17d57b7e595b"><strong>The Ranking Table Method</strong></a> I published earlier. I highly recommend reading through it and practicing this method a few times. It will help you identify what criteria is important to you and effectively prevent you from procrastinating critical tasks. Once you are familiar with this method, you can develop intuition for prioritization, which improves your productivity tenfold.</li><li><strong>Set your own deadlines</strong> for small tasks. By picking a small task, you can estimate how much time it takes more confidently than a big undefined project. For example, a small task may be to write a paragraph for a topic, which we can estimate to be doable in 15 minutes. By using this thought process, we can then schedule this task on our calendar as a 15-minute event and almost guarantee that we will make progress towards this project.</li></ol><h3>Conclusion</h3><p>By identifying the forces that lead to procrastination, I have identified 3 important tips (quantization, prioritization, and setting deadlines) to tackle this problem. In this article, I have thoroughly described these tips and listed examples that show how these tips work in my own experience.</p><p>I hope these tips can help you eliminate procrastination. If so, <em>please clap</em> :)</p><p>If you have more ideas that you think can help, send me a message or comment down below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4a5758977e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The One Prioritization Method That Will Boost Your Productivity and Focus]]></title>
            <link>https://justinsj.medium.com/the-one-prioritization-method-that-boosts-my-productivity-and-focus-17d57b7e595b?source=rss-457b4f5eadc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/17d57b7e595b</guid>
            <category><![CDATA[methodology]]></category>
            <category><![CDATA[prioritization]]></category>
            <category><![CDATA[productivity-hacks]]></category>
            <category><![CDATA[focus]]></category>
            <dc:creator><![CDATA[Justin San Juan]]></dc:creator>
            <pubDate>Sat, 01 Oct 2022 04:25:53 GMT</pubDate>
            <atom:updated>2022-10-01T04:57:16.844Z</atom:updated>
            <content:encoded><![CDATA[<p>Oftentimes at work or in schooling, there are many tasks to complete. However, not all tasks are created equal. An important skill in life is to be able to prioritize. This article will teach you a simple way to prioritize tasks that only takes a few minutes and can be generalized to any set of tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPtw77lhTE2weK5KN8PYfg.jpeg" /><figcaption>Credit to <a href="https://unsplash.com/@jmuniz">Joel Muniz</a> on <a href="https://unsplash.com/photos/XqXJJhK-c08">Unsplash</a></figcaption></figure><p>The method works by creating a ranking table. I find that this works best for me using pen &amp; paper, but you can also opt for using a spreadsheet, presentation software with tables, or a digital notepad.</p><p>This method is intended as a rational way to approach prioritization. In the end, it is best to develop an intuition for what should be prioritized, and using this method regularly can help you get there.</p><h3>How does this benefit you?</h3><p>Before we get to the methodology, I want to explain why it is important, and how it can benefit you.</p><p>This methodology will teach you<strong> 3</strong> things:</p><p><strong>Lesson 1</strong>. Learn to break down projects into sizeable tasks</p><p><strong>Lesson 2</strong>. Learn to identify importance</p><p><strong>Lesson 3</strong>. Learn to be selective and get into flow state</p><h3>How to Use a Ranking Table</h3><p>There are 5 simple steps:</p><h4>1. List all your tasks in separate rows</h4><p>As an example, we can take selecting a book to read during free time. Each task is then reading a separate book.</p><p>Different books have different genres, for me personally, I am interested in books on architecture, programming, as well as entrepreneurship.</p><p>The table would look like as follows in Figure 1.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*7ae1cPTYBuST2rft1g_DoQ.png" /><figcaption>Figure 1. Initial ranking table with rows</figcaption></figure><h4>2. List out criteria as new columns in the table</h4><p>Now, we want to identify criteria to indicate what is important to us. These are written out in the form of columns in the table.</p><p>In the example, these could be:</p><ul><li>Financial application in the near term,</li><li>Room for personal growth, and</li><li>The length of the book (the shorter the better)</li></ul><p>Other criteria, depending on your ultimate goal, could be:</p><ul><li>Discussability (level of controversy for social inquiry)</li><li>Level of escapism (with the aim for relaxation)</li><li>Etc.</li></ul><p>Tips for listing out these criteria include asking yourself:</p><ol><li>“What is your ultimate goal right now?” It could be to become more social, more financially stable, or something else.</li><li>What abstract features of the task are aligned with your goal (e.g. provide the most value)?</li><li>What concrete features are aligned with your goal?</li></ol><p>The table would then look like that in Figure 2. below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oi2N3pzTYCV9xZR1rc_I4g.png" /><figcaption>Figure 2. Ranking table with columnal criteria</figcaption></figure><h4>3. Score each task for each column</h4><p>You have to evaluate each task in the view of each criteria and give it a score of importance.</p><p>You can do this by adding a ‘✓’ tick for each point that you give.</p><p>In this step, aim to be as objective and fair as possible. It helps to look at each criteria one by one, marking each task before moving on to the next criteria.</p><p>For me, this would look as follows in Figure 3.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6BBg2iA-T0QPsAQD57RSw.png" /><figcaption>Figure 3. Ranking table with score for each column</figcaption></figure><h4>4. Select your top 3 to work on today</h4><p>From there, you can tally up the score for each task, and select which your top 3 tasks are for the day.</p><p>In the example, I would only be reading one book and prefer not to switch multiple times in a day. The final ranking table would look as in Figure 4.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hgZpNFfpvegmenqckUq6Q.png" /><figcaption>Figure 4. Tallied ranking table with final ranks.</figcaption></figure><h4>5. Select your top 1 to work on right now</h4><p>From these three tasks, you can then select 1 to work on right now. Most likely, that will be the topmost ranked item.</p><p>Once you have selected what you want to work on today, and you have convinced yourself that this is the best task to work on, then the rest of the world fades away and you can get into the <strong>flow</strong>. I know for me, it has!</p><h4>Do it enough and develop your intuition</h4><p>What I love about this method is that you do not have to rely on it forever. When you do this enough, you start to develop an intuition for what is important and should be worked on right now.</p><p>As such, this is a method that brings you to the next level and does not aim to inhibit your productivity.</p><h3>Conclusion</h3><p>The ranking table can help you isolate the most important task for you at any given point in time. By practicing this method, you can perform your ranking quickly and become confident and focused in your work. This amplifies your productivity and satisfaction in your work.</p><p>The ranking table method can help you identify what you care about in your life, as well as help identify when you are stuck with too many options.</p><p>I hope this method can help you prioritize and focus on creating value from your actions. If so, <em>please clap</em> :)</p><p><strong>Happy Ranking!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17d57b7e595b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>