<?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 Steven Blowers on Medium]]></title>
        <description><![CDATA[Stories by Steven Blowers on Medium]]></description>
        <link>https://medium.com/@shdblowers?source=rss-767e2f51ec6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ias7Ut3YHx8dEKtpxvy0qA.jpeg</url>
            <title>Stories by Steven Blowers on Medium</title>
            <link>https://medium.com/@shdblowers?source=rss-767e2f51ec6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:20:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shdblowers/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[Sharing Base Functionality in Elixir]]></title>
            <link>https://medium.com/rekkiapp/sharing-base-functionality-in-elixir-8d28e9d0619?source=rss-767e2f51ec6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d28e9d0619</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[protocol]]></category>
            <category><![CDATA[behaviour]]></category>
            <category><![CDATA[polymorphism]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Steven Blowers]]></dc:creator>
            <pubDate>Mon, 19 Nov 2018 15:01:27 GMT</pubDate>
            <atom:updated>2019-08-24T11:16:56.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPg6_dRZQ8hZgPpo1yOV5g.png" /></figure><p>At <a href="http://rekki.com/">Rekki</a> we write a lot of Elixir code. Elixir is a language whose influences are a mix between object-oriented programming and functional programming. This is evident in how it provides tools typically of an object-oriented style in a functional way.</p><p>One such implementation of these tools is for polymorphism, which is the idea that something (function / module) can have different forms, based on the type of input. These tools are <a href="https://hexdocs.pm/elixir/Module.html#module-behaviour">Behaviours</a> and <a href="https://hexdocs.pm/elixir/Protocol.html">Protocols</a>.</p><p>You would use Protocol when the desired behaviour of the functions are the same, but the data type is different. Here is an example: a Protocol for a size function, the desire of all the functions is the calculate the length of the input, but the data type is different, here is the example from the Elixir website:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3be4442f2ea4e588b60dd66cb791a63/href">https://medium.com/media/d3be4442f2ea4e588b60dd66cb791a63/href</a></iframe><p>Behaviours are used when the desire of the modules are the same, but the situation is different. An example being parser modules, the desire of each module is to parse data of a specific format, the situation of what that format is changes, here is another example from the Elixir website:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f80f94e64e70908e07c23be4159c6e3/href">https://medium.com/media/8f80f94e64e70908e07c23be4159c6e3/href</a></iframe><p>Now that we’ve seen how you can achieve polymorphism in Elixir, how would we allow each implementation to share functionality?</p><p>By making use of a mix of either Behaviour or Protocol along with the use macro, then polymorphism and extension can be achieved at the same time.</p><p>An example would be a FilePrinter Protocol, it would parse a file in a particular format and then print that to standard output. The parsing of the file would change based on the file type, but the way it would print would remain the same. Therefore, we would only want to write the implementation of how its prints to standard output once, and this would be shared between all implementations:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7492e0d02a34f5c3f1af6268e97a0ea3/href">https://medium.com/media/7492e0d02a34f5c3f1af6268e97a0ea3/href</a></iframe><p>And an example of the Behaviour being implemented:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8b48d09c167d50a4eec958581dc5b25/href">https://medium.com/media/a8b48d09c167d50a4eec958581dc5b25/href</a></iframe><p>We would then be able to call JSONPrinter in the following manner:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f70b693ae385042df8a9fb70f7f2b8f7/href">https://medium.com/media/f70b693ae385042df8a9fb70f7f2b8f7/href</a></iframe><p>It might seem strange at first, using both use and @behaviour on the module. It also looks like we are introducing coupling where it is not needed, coupling the implementation of the parser to the implementation of how it is output. What if we wanted to extend the functionality of the parser, maybe to parse JSON as it comes in from a web request? This is true, coupling has been introduced where it doesn’t need to be, however this coupling has allowed the possiblity of some benefits: duplicated code is kept to a minimum, being able to add new scenarios does not require much code and the user of this code is presented with a clean interface to work with.</p><p>In the blog post you have seen how to share functionality between different implementations of a Protocol or Behaviour with the use of the use macro. It may not fit every situation, so take a critical eye to it before deciding to implement it yourself, but under the right circumstances it is a great asset to have when implementing polymorphism in Elixir.</p><p>—</p><p>Want to know more about us? Go <a href="https://www.rekki.com/careers/engineering">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d28e9d0619" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rekkiapp/sharing-base-functionality-in-elixir-8d28e9d0619">Sharing Base Functionality in Elixir</a> was originally published in <a href="https://medium.com/rekkiapp">REKKI team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips and Tricks for Writing Elixir BDD Gherkin Tests with White Bread]]></title>
            <link>https://medium.com/hackernoon/tips-and-tricks-for-writing-elixir-bdd-gherkin-tests-with-white-bread-4f9894e9ea18?source=rss-767e2f51ec6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f9894e9ea18</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[bdd-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Steven Blowers]]></dc:creator>
            <pubDate>Fri, 03 Feb 2017 22:16:49 GMT</pubDate>
            <atom:updated>2019-05-15T09:17:06.689Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing behavior driven <a href="https://hackernoon.com/tagged/development">development</a> tests with the <a href="https://github.com/cucumber/cucumber/wiki/Gherkin">Gherkin syntax</a> is a great way for a developer to communicate with a non-technical employee, for example a product manager. This is because the Gherkin syntax is so close to English, that it doesn’t require any technical expertise to read or write it. It just has to be written in a consistent and known way, so that it can be interpreted into steps of executable code.</p><p>Many languages have great BDD Gherkin libraries, like Cucumber for Ruby and Behat for <a href="https://hackernoon.com/tagged/php">PHP</a>. The one that I think is best right now for the Elixir language is the <a href="https://github.com/meadsteve/white-bread">White Bread</a> library created by <a href="https://github.com/meadsteve">meadsteve</a>.</p><p>This article isn’t a getting started guide on White Bread, if you’re looking for that I’d recommend taking a look at the README.md of the White Bread project. This article is instead more of a tips and tricks guide to getting the best from White Bread (and Gherkin in general) based on my experiences.</p><p>The first recommendation is one that can be applied to writing Gherkin for any programming language. That is, to write your Gherkin steps in a reusable and explicit way. First, I’ll show you an example of what not to do, then explain how we can clean up the mess. Let’s start off with a feature file that looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8029ccbeb164e28e488b1dc6b85f52da/href">https://medium.com/media/8029ccbeb164e28e488b1dc6b85f52da/href</a></iframe><p>Now, each of these steps is written similarly but have slight differences and therefore require different implementations in the code. Let’s look at the context code that matches up with these steps:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f7c175c8ce180f2f207b3ddc5532858/href">https://medium.com/media/7f7c175c8ce180f2f207b3ddc5532858/href</a></iframe><p>I’ve omitted some of the steps from the context above, but you can already see how much repetition there is between similar steps. In order to get around this, the steps should be written in a reusable way, in which variables can be used, so that the same context step can be executed for each one, as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bd7b0804b6effac7eefab28dd1edbc0/href">https://medium.com/media/8bd7b0804b6effac7eefab28dd1edbc0/href</a></iframe><p>This allows the same steps to be used, even when the names used for the user name varies, as we can see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bcb50be6c375d900ac698cd914c1533/href">https://medium.com/media/2bcb50be6c375d900ac698cd914c1533/href</a></iframe><p>The steps above are using the power of Regex to capture the name between the two speech marks and set that as the name variable.</p><p>We can take the cleanup of this feature file even further. What if we wanted to write a step to change the email address of a user? That’s so close to changing the name, why use two different steps?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5c17d044c65d24c5fd6918354573a38/href">https://medium.com/media/a5c17d044c65d24c5fd6918354573a38/href</a></iframe><p>This would allow the same step to be used, regardless of which property of a user is being changed.</p><p>What if I wanted to register a user, but didn’t care about giving them a specific name. I could come up with a default name (e.g. John) and then refactor the steps like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87da996ebf74878d93012c4bf894c6ef/href">https://medium.com/media/87da996ebf74878d93012c4bf894c6ef/href</a></iframe><p>The idea behind this refactoring is so that you can write as little code as possible and that you keep your code DRY (Don’t Repeat Yourself). But you can end up taking the refactoring too far and push the Gherkin syntax to a point where a non-technical person would not be able to understand it clearly, so keep that in mind when doing this sort of refactoring.</p><p>The second thing I’d recommend is that each feature file has its own context file. The way that I have set this up is to also have one suite per feature file, there is a context_per_feature configuration, but I found this cumbersome to use. So, my config file would look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23a33d4fc2417de1aa9766f808bc43d5/href">https://medium.com/media/23a33d4fc2417de1aa9766f808bc43d5/href</a></iframe><p>The reason I have done this is so that each feature can have its own entry point into all the different context modules you will be writing.</p><p>The third thing I’d recommend is that when you find yourself writing a step that can be reused for multiple features, put it in its own context! That way each feature can share this common step.</p><p>One step I often find myself needing is a step where nothing happens. This may sound silly at first, but the Gherkin languages requires that each feature has a Given, When and Then step and sometimes I don’t need any setup in the Given step. It looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/060e76822ddd05f518971e6126f59b64/href">https://medium.com/media/060e76822ddd05f518971e6126f59b64/href</a></iframe><p>In order to add this to another context I’d use subcontext which looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/395dd2d76f8548d74ee24cd49772343b/href">https://medium.com/media/395dd2d76f8548d74ee24cd49772343b/href</a></iframe><p>This way my contexts that are the entry points from the feature files remain small and will only have steps in them specific to the feature, it also helps keep the code DRY.</p><p>One final recommendation is to create a module with state helper functions.</p><p>White Bread allows you to pass on state between each step, which is required if, for example, in the first step you add a user and get their ID and then in the next step need that ID to make further modifications on the user.</p><p>The state is just a map, so adding data to it is easy, but its nice to encapsulate that logic in some helper functions, like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a560a359a2674f74ab6daa252f8ff192/href">https://medium.com/media/a560a359a2674f74ab6daa252f8ff192/href</a></iframe><p>Using these helper functions, our example from earlier would now look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66e7ee5776225756c5fe0b1f65b912f0/href">https://medium.com/media/66e7ee5776225756c5fe0b1f65b912f0/href</a></iframe><p>The benefit of doing this may not be apparent yet, but once you have 20+ context files all manipulating the state in possibly slightly different ways, the benefit will become apparent.</p><p>That’s it! Thanks for reading and I hope you found some of the tips and tricks above useful.</p><p>As a final word, I’d implore you to contribute to the White Bread project. Elixir is a language growing bigger every day and it needs a strong BDD Gherkin library and I think White Bread can become that.</p><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a>family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp;sponsorship</a> opportunities.</blockquote><blockquote>To learn more, <a href="https://goo.gl/4ofytp">read our about page</a>, <a href="http://bit.ly/HackernoonFB">like/message us on Facebook</a>, or simply, <a href="https://goo.gl/k7XYbx">tweet/DM @HackerNoon.</a></blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f9894e9ea18" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/tips-and-tricks-for-writing-elixir-bdd-gherkin-tests-with-white-bread-4f9894e9ea18">Tips and Tricks for Writing Elixir BDD Gherkin Tests with White Bread</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Another look at Elixir’s With]]></title>
            <link>https://medium.com/hackernoon/another-look-at-elixirs-with-cbd70ccd8ba4?source=rss-767e2f51ec6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbd70ccd8ba4</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[erlang]]></category>
            <category><![CDATA[logic]]></category>
            <category><![CDATA[model]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Steven Blowers]]></dc:creator>
            <pubDate>Wed, 23 Nov 2016 19:23:19 GMT</pubDate>
            <atom:updated>2019-05-15T09:17:07.174Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I wrote an article on using Elixir’s with syntax:</p><p><a href="https://medium.com/@shdblowers/using-elixirs-with-bccf39bac279">Using Elixir’s With</a></p><p>I ended that article saying that I was sure there was uses for with, but I was struggling to find them. As an update to that article I have found an excellent use for the with statement, <a href="https://hackernoon.com/tagged/model">model</a> sanitization!</p><p>Here is a flow diagram displaying the logic that will be written in multiple ways for this post:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*RfPtbybekjxnwGBA2WNJDw.png" /></figure><p>As you can see the logic branches off to two different final conclusions, either the parameters are valid and a user can be created, or there was an error which should be communicated to the user. What I’m looking for in the code is for this idea to be expressed as clearly and concisely as possible.</p><p>Below is an example of using with, it creates a user through the use of a struct, whilst sanitizing each <a href="https://hackernoon.com/tagged/parameter">parameter</a> in turn that comes in from the request:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aef95cb1886336ce3c6db2476a81a28/href">https://medium.com/media/0aef95cb1886336ce3c6db2476a81a28/href</a></iframe><p>Above I have defined the function create/1 which takes a map of user properties including &quot;Name&quot; and &quot;Email&quot; and returns a created User struct. With each parameter that is added, it is put through a validation function that will either return {:ok, property} or {:error, message}.</p><p>Using with these functions can be chained together, sharing a single else clause if something goes wrong. Also, the values produced from each function can be captured and all used in the do statement, as shown above.</p><p>Also note, the else clause is actually optional in the code above. Because the clause returns what it captures, that behaviour is maintained when the else clause is omitted.</p><p>Comparing the create/1 function to the flow diagram, it is clear to see that using with allowed that logic to be succinctly expressed. It clearly shows the happy path the logic wants to go down, with the resulting actions of whether it reaches the end of that path or not.</p><p>Let’s look at alternatives to with, as shown in the previous article they are to use functions or case. Having looked over both alternatives again, I cannot see that using functions alone is a legitimate alternative, as it cannot properly express the branching logic of what is going on.</p><p>Below is an example of the logic expressed using case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/863b81dacc2d6ebe46d731b4f51d7ba0/href">https://medium.com/media/863b81dacc2d6ebe46d731b4f51d7ba0/href</a></iframe><p>There are two crucial problems with the approach above. Firstly and most importantly, the most important line of code in create/1 function, the line that creates a User struct is hidden deep in nesting in the middle of the function. At the moment this is not very readable with 2 parameters, imagine if it had a more common amount of parameters, say 10? That would look horrific. The other problem is I’m having to redefine what to do with an error over and over again, rather than just having to specify it once for everything.</p><p>In closing, I take back what I said about the with syntax. Its an excellent bit of syntactical sugar and I look forward to finding more uses for it in the future.</p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd70ccd8ba4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/another-look-at-elixirs-with-cbd70ccd8ba4">Another look at Elixir’s With</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Elixir’s With]]></title>
            <link>https://medium.com/@shdblowers/using-elixirs-with-bccf39bac279?source=rss-767e2f51ec6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bccf39bac279</guid>
            <category><![CDATA[with]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Steven Blowers]]></dc:creator>
            <pubDate>Thu, 17 Nov 2016 12:52:43 GMT</pubDate>
            <atom:updated>2016-11-17T13:30:06.278Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a short article to show an example of using the with keyword in Elixir.</p><p>So, the starting point of the code is this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c25ac0f3e3fb13f9197a09a87e59dafa/href">https://medium.com/media/c25ac0f3e3fb13f9197a09a87e59dafa/href</a></iframe><p>Before, I used to think this bit of code was super cool.</p><p>I wanted to use a function that returns {:ok, response} inside some piping. So, I decided to use Kernel.elem(1) to get the response out of its tuple. Now, I realise this is bad as there is no code to handle if an error is returned by the API, nor is an exception thrown, the code just tries to carry on and I get weird errors if something goes wrong.</p><p>Using the with keyword, I can handle the error in a nice way:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f9c97a2c2ed5351bb9b36767d4c1257/href">https://medium.com/media/2f9c97a2c2ed5351bb9b36767d4c1257/href</a></iframe><p>What this code is saying is that if you can pattern match what is on the right of the &lt;- then execute what is under do, otherwise execute what is under else.</p><p>As an alternative to using with, here is the same thing with functional pattern matching:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4324d6eb1b7cecdc321f310120cf342/href">https://medium.com/media/e4324d6eb1b7cecdc321f310120cf342/href</a></iframe><p>Both solutions have their advantages and disadvantages, personally I find using functions a more readable solution, and on top of that getting to grips with the with syntax took a little time.</p><p>I will be looking out for possibilities for using with in the future, but for now, I’m sticking with functions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bccf39bac279" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>