<?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 Micaiah Wallace on Medium]]></title>
        <description><![CDATA[Stories by Micaiah Wallace on Medium]]></description>
        <link>https://medium.com/@micaiah-wallace?source=rss-5534595ced5b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SD0iIKM8dh4OZX0xHXx7Nw.jpeg</url>
            <title>Stories by Micaiah Wallace on Medium</title>
            <link>https://medium.com/@micaiah-wallace?source=rss-5534595ced5b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:00:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@micaiah-wallace/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[Making a Web Scraper in Node + TypeScript]]></title>
            <link>https://medium.com/weekly-webtips/making-a-web-scraper-in-node-typescript-6735f869b724?source=rss-5534595ced5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6735f869b724</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[programming-tutorials]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[utilities]]></category>
            <dc:creator><![CDATA[Micaiah Wallace]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 09:14:13 GMT</pubDate>
            <atom:updated>2022-01-28T09:14:13.037Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6vB8y5XuIQ3Ml8co" /><figcaption>Photo by <a href="https://unsplash.com/@sapeksh?utm_source=medium&amp;utm_medium=referral">Sapeksh Singh Siwach</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>An exciting way to browse the web</h4><p>In my career, there have been times when I was tasked with creating a new solution to optimize or boost productivity for an existing legacy business process by implementing smarter technology.</p><blockquote>Automation is essential in every business.</blockquote><p>I always have a bent towards automation whenever possible in creating software solutions. This often means consuming various APIs to interact with data sources or data management systems as a part of the solution. However, quite frequently, I’m presented with a source that provides little or even no usable APIs to access the data!</p><p>For this reason, I’ve decided to write this web scraping tutorial and hopefully provide some useful insight to things I’ve learned developing my own scrapers.</p><h3>Design Preparation</h3><p>In order to create effective, reusable and scalable web scraper code, there are a few concepts and details you must consider before hand to properly design your software architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AP1lUvu7hfMqZrlw" /><figcaption>Photo by <a href="https://unsplash.com/@d_mccullough?utm_source=medium&amp;utm_medium=referral">Daniel McCullough</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Create a reusable module, not a one-off script.</strong></h4><p>Often times, I’ve caught myself trying to quickly put a scraper together to accomplish a task for a given project. Come to find out later, I end up writing very similar structural code in the next project wasting time rewriting boilerplate setup. Save yourself some time and generalize your scraper so it can be reused in future projects (also check out my article: <a href="https://medium.com/geekculture/why-i-over-engineer-c251beab5a04">why I over-engineer</a>). Who knows, maybe you’ll end up publishing an open-source project out of it!</p><h4>Scan over the architecture used by the website.</h4><p>This means looking at all authentication methods being used, whether the content is dynamically generated or statically served with API generated content. If there is an undocumented API being used by the web application, this can save you a ton of time if utilized correctly over the alternative markup scraping methods. Any details you can gather about the website will help you determine what frameworks and methods you might need to use to extract the data.</p><h4>Who (or What) will consume your findings? And How?</h4><p>Sometimes you are building a scraper to simply generate a CSV or PDF report file. Or maybe it is being used as a component in a larger web application which will be consumed by it’s own web clients over an API. Leaving the choice open ended will help keep your code generic enough to be used in your next project (or the same one if requirements change a few months in!)</p><h3>Scraping Node Blog</h3><p>For our sample scraper, we will be scraping the Node website’s blog to receive updates whenever a new post is released. We will be creating this scraper in the form of a command line utility, with the option to be used as an importable module. In this example, the consumer of the data will be a cell phone via SMS by using the Twilio messages API.</p><p>We start by analyzing the website data structure to determine which of the scraping methods we will need to use. After opening <a href="https://nodejs.org/en/blog/">https://nodejs.org/en/blog/</a> and opening View Source in the browser, we can see that the data received from the server is a simple html file that can be easily parsed without a javascript engine by scrolling down till you find the &lt;ul class=&quot;blog-index&quot;&gt; section which contains the actual blog posts. This means we will use a library called <strong>Cheerio</strong> to parse the html markup for the data we need. While we are here, we capture the structure of blog post as well:</p><pre>&lt;ul class=&quot;blog-index&quot;&gt;<br>  &lt;li&gt;<br>    &lt;time datetime=&quot;2022-01-11T00:50:00+0000&quot;&gt;11 Jan&lt;/time&gt;<br>    &lt;a href=&quot;...&quot;&gt;...&lt;/a&gt;<br>    &lt;div class=&quot;summary&quot;&gt;<br>      &lt;p&gt;...&lt;/p&gt;<br>    &lt;/div&gt;<br>  &lt;/li&gt;<br>  ...<br>&lt;/ul&gt;</pre><p>We also capture the structure for the navigation section we will need to use to follow to older pages to ensure we capture all posts.</p><pre>&lt;nav aria-label=&quot;pagination&quot; class=&quot;pagination&quot;&gt;<br>    &lt;a href=&quot;/en/blog/year-2021/&quot;&gt;Older &amp;gt;&lt;/a&gt;<br>&lt;/nav&gt;</pre><h4>The Project</h4><p>I have uploaded the project code to my Github at the following link, so feel free to look there to get the full picture as I will only summarize key points to keep the article to the point.</p><p><a href="https://github.com/micaiahwallace/medium-node-blog-scraper">https://github.com/micaiahwallace/medium-node-blog-scraper</a></p><p>The directory structure looks like this:</p><p><strong>src/coordinators</strong> — Combines logic, services and other coordinators to organize a logical action<br><strong>src/services</strong> — access resources outside of the program memory such as filesystem IO or network requests<br><strong>src/logic</strong> — business logic containing usually synchronous pure functions that are just making decisions and returning modified values<br><strong>src/run.ts</strong> — entry point for the sample application</p><h4>Scrapers</h4><p>We will create 2 separate functions to contain the scraping logic that will fetch the blog posts and the next page navigation links. This is where we will be loading in the html source string into the cheerio runtime for markup parsing.</p><p><strong>extractNodeBlogPosts.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ed4ce66f90c084f727fdcd09f815af6/href">https://medium.com/media/7ed4ce66f90c084f727fdcd09f815af6/href</a></iframe><p><strong>extractNodeNextPage.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3f8529f1bd699195ad0af4c5cd1b33b/href">https://medium.com/media/f3f8529f1bd699195ad0af4c5cd1b33b/href</a></iframe><p>We will need a service function to fetch the html string data that will feed the scraper functions. For this function we will perform the http request using a library called <strong>axios</strong>.</p><p><strong>ioFetchUrlText.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47adb6154cfa13c8deb1fb94c6c7f7e5/href">https://medium.com/media/47adb6154cfa13c8deb1fb94c6c7f7e5/href</a></iframe><p>To tie the pieces together, we will create a coordinator function to encapsulate the logic. This function will be recursively calling itself in order to collect all the posts from every page on the blog.</p><p><strong>fetchNewBlogPosts.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e447da683a6ad562a99e771d32b7eaa/href">https://medium.com/media/1e447da683a6ad562a99e771d32b7eaa/href</a></iframe><p>Now that we have a coordinator to fetch new blog posts, we will need one to fetch the locally cached blog posts to know which posts we’ve already looked at before.</p><p><strong>fetchCachedBlogPosts.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e81471737a7daea6358e082fa4746280/href">https://medium.com/media/e81471737a7daea6358e082fa4746280/href</a></iframe><p>As you see in the above function we reference another service function <strong>ioGetFileJsonArray</strong>, we will also want a function to write the posts back to the cache file once we get an updated list called <strong>ioWriteFileJson</strong>. I won’t go into these here since they are fairly simple. However, I will call out a function we will use to validate the data we ingest from the cache file to validate it since it’s coming from an untrusted source.</p><p><strong>validateBlogPost.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9edc99b007b3ec0b3872259cb3dea863/href">https://medium.com/media/9edc99b007b3ec0b3872259cb3dea863/href</a></iframe><p>Now we want to have a function that compares the old and new lists of blog posts and returns the ones we are interested in using to send out notifications.</p><p><strong>findNewBlogPosts.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f53a8a268581592fbba82048abfe224d/href">https://medium.com/media/f53a8a268581592fbba82048abfe224d/href</a></iframe><h4>The main coordination</h4><p>We will now look at the coordinator that ties all of these logical functions together in our core action of fetching blog posts, comparing with what we have and sending out notifications. We will generalize this function to allow the pattern to be used for other future projects</p><p><strong>watchListAndNotify.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e72395dd3f6f8044d8842808fb25489/href">https://medium.com/media/4e72395dd3f6f8044d8842808fb25489/href</a></iframe><p>We can now create a more specific function to add in the specific functions used for our example application.</p><p><strong>scrapeNodeBlog.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18446c39f6304150ea110a2412acb712/href">https://medium.com/media/18446c39f6304150ea110a2412acb712/href</a></iframe><p>We left a few parameters to be resolved by the caller so we can specify them in our main run file such as how to handle caching and sending out notifications, also configuration constants such as the entry point for the node blog and maximum post notifications will be specified here as well.</p><p><strong>run.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27bafaa721c8b4a244b514e60cda8bc7/href">https://medium.com/media/27bafaa721c8b4a244b514e60cda8bc7/href</a></iframe><h4>Finally… Run it!</h4><p>Well almost, if you would like to see the fancy twilio integration, then you will need to head to twilio.com to setup an account with an auth token and a phone number, otherwise you can replace the sendTwilioMessage call with a console.log to see how it would function without all the overhead. After you configure your environment variables properly (if using twilio) based on the env.sh.template file into a new file called env.sh and load it into your current shell with source env.sh you can finally run npm run build then npm start to see it in action!</p><p>After the first run, you will see up to MAX_NOTIFICATIONSnumber of posts in your console (and possibly messages app!) then any consecutive runs will result in no new posts showing up, until a new post has actually been posted to the blog.</p><p>This has been a lot of code and information, so feel free to ask any questions or post any thoughts you have about this post or the general subject of scraping the internet. Oh… and… congrats for making it to the end!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BaBzIEAJJSB98Y_2" /><figcaption>Photo by <a href="https://unsplash.com/@ingle_jake?utm_source=medium&amp;utm_medium=referral">Jake Ingle</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6735f869b724" width="1" height="1" alt=""><hr><p><a href="https://medium.com/weekly-webtips/making-a-web-scraper-in-node-typescript-6735f869b724">Making a Web Scraper in Node + TypeScript</a> was originally published in <a href="https://medium.com/weekly-webtips">Webtips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I over engineer.]]></title>
            <link>https://medium.com/geekculture/why-i-over-engineer-c251beab5a04?source=rss-5534595ced5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c251beab5a04</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[startup-lessons]]></category>
            <dc:creator><![CDATA[Micaiah Wallace]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 17:32:42 GMT</pubDate>
            <atom:updated>2022-01-22T17:32:42.848Z</atom:updated>
            <content:encoded><![CDATA[<p>or why I shouldn’t…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*goHaC3ztiW3Ekeqj" /><figcaption>Photo by <a href="https://unsplash.com/@darshan394?utm_source=medium&amp;utm_medium=referral">Deva Darshan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve noticed there to be at least 2 schools of thought on this subject, and thought it might be an interesting topic to review and see the pros and cons of both sides of the debate.</p><p>Because I like to start with the more convicting side of the argument first, I’ll start out by discussing what I think are the biggest draw backs to over engineering.</p><h3>Draw backs</h3><h4>It will cost X (time, money, talent)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YUFM4z3te4Ltiga6" /><figcaption>Photo by <a href="https://unsplash.com/@jpvalery?utm_source=medium&amp;utm_medium=referral">Jp Valery</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Probably the most obvious point, is that most of the time you are being paid to write the code by someone else. Unless you have been hired under a different agreement, most of the time you have been hired to write code that most directly correlates to creating a valuable product. This often involves writing as little code as possible, with enough test coverage to satisfy the shipping a (hopefully) well defined software requirement specification so that you can move on to the next requirement as efficiently as possible.</p><p>Now, every company has different values and beliefs on code quality vs. project constraints (time, money, etc…), but for the most part, it’s safe to say you are getting paid to make a product.</p><h4>No direct value added</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hhPmBNE_v7UeRi5O" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This point is debatable on it’s own, but essentially if you are writing more code than is required to accomplish a task that could have been done in half the time, then all that extra time spent on creating a fantastic abstraction has now been “wasted” on what could have been the next deliverable feature to the product.</p><p>Now at this point, I will stop here because it’s safe to say that any further points will also somehow be related to spending of time, money or talent. So let’s move on to the benefits of over-engineering.</p><h3>Pros</h3><p>I will start this section by saying, along with each of these beneficial reasons for over-engineering comes a balance, but I’ll get more into that in the summary.</p><h4>Cleaner Code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l7-2orIw35q02w8d" /><figcaption>Photo by <a href="https://unsplash.com/@echaparro?utm_source=medium&amp;utm_medium=referral">Edgar Chaparro</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you are able to spend enough overhead time ensuring the design you choose for an implementation provides the right type of architecture and abstraction, it can be way easier to reason about a code base.</p><p>For me personally, it has some correlation to having a clean working space / desk area, in the sense that if you respect yourself you should also respect the areas you live and work in (including a code base). This can also provide an easier barrier to entry for new team members when on boarding into your system.</p><h4>Developer Experience</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I2m3XnlbQe-mYn7o" /><figcaption>Photo by <a href="https://unsplash.com/@pascal_habermann?utm_source=medium&amp;utm_medium=referral">Pascal Habermann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One of the easiest ways to gain true understanding of something is to dive in and experience it.</p><p>This applies to code design &amp; implementation in that you are forced to do the research and figure out how to do something (or how to do it better) when you take on improving or designing a new system. This is what my career has been built on, being given the opportunity to use many different software design paradigms and best practices in real code. Without the experiences I’ve had, I may not have truly understood why it’s better to use libraries for some things such as a web server. One of my earlier node projects, I made the mistake of writing an API server from scratch in node using a the tcp module and manually parsing http messages. Yes, it was a really dumb idea to take on, but now I have a true appreciation for modules such as express.</p><p>With the right mindset, you can take what you did and look back on it critically to say, what worked with this, what didn’t work and what am I going to do better next time.</p><h4>Re-usability &amp; Scalability</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LnpLkKyN8hU1XxH7" /><figcaption>Photo by <a href="https://unsplash.com/@jasmin_sessler?utm_source=medium&amp;utm_medium=referral">Jasmin Sessler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I leave this one for last because it’s the one that’s bit me in the butt the most in my experience.</p><p>This reasoning behind why over-engineering can be useful is that in the future, you can implement another like-designed feature with minimal effort due to the abstractions / modules / etc… you created earlier. The reason also goes, we may have huge surges in traffic or growth of customer base in the near future that will cause a huge panic if we don’t optimize this ahead of time.</p><p>This is the reason that in my opinion requires the most thought and care before taking it and running at your code editor. The reason being, this has a very valid reason, that could likely (or unlikely) happen in the future, but that’s the thing. It’s the future… meaning you don’t really know. My qualifications for invoking this reason for creating something is the following:</p><ul><li>Will it take a relatively small amount of time to implement?</li><li>Are there enough people available or is there enough time that couldn’t be spent creating actual value?</li><li>Is the weighed risk / probability high enough to need this implemented?</li></ul><p>If any of those are true, then it’s probably fair to say move forward with it given you have the proper go ahead to do it as well.</p><h3>Summary</h3><p>All things said, I still find many valuable reasons to spend time designing a thoughtful and well structured system and will likely lean towards that bias given the right circumstances. However, in certain situations or companies, there can be much more value derived by getting something created and shipped as quickly as possible (say for a startup MVP). The real answer is up to the specific situation at hand and some genuine critical thinking to decide what the best path forward is.</p><p>Now that I’ve dumped my thoughts on this topic… I’d love to hear anyone else’s thoughts / questions or disagreements with any of the points mentioned or any thoughts on this topic in general, so write them in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c251beab5a04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/why-i-over-engineer-c251beab5a04">Why I over engineer.</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Always a Developer]]></title>
            <link>https://micaiah-wallace.medium.com/always-a-developer-23aefb722149?source=rss-5534595ced5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/23aefb722149</guid>
            <category><![CDATA[my-story]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[passion]]></category>
            <category><![CDATA[about-me]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Micaiah Wallace]]></dc:creator>
            <pubDate>Fri, 08 Jan 2021 04:52:05 GMT</pubDate>
            <atom:updated>2021-01-08T04:52:05.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RU5iIZwS9_YpnNd_" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>(once a developer)</h4><p>Telling your own stories is a great way to reflect on how you got somewhere and share any value knowledge learned along the way. I began my journey in writing code probably much earlier than most. I took it all the way through childhood into my career. In fact, I can trace it back in my mind to a memory of me asking my parents about how a URL should be formatted to correctly pull up a website when I was about 9 years old.</p><p>I became fascinated with computers and I wanted to understand how they worked. I was only trying to understand computers for the sake of my own curiosity and then once I understood them I could move on to something else (little did I know how deep the rabbit hole would go). From there, my curiosity grew as my dad started down the journey of creating a dynamic website for his business clients to submit service requests. To be clear, he is not a software developer, but was able to learn enough of what he needed from books and the internet to make what needed to be made. I found the concept of creating a website to be so fascinating, the fact that you could just write some words into a text editor and that would somehow translate into a usable interactive application caught my attention.</p><p>Not long after my fascination grew, I remember my dad giving me his ColdFusion and HTML books and setting me up with my very first domain name and a basic hosting setup. From there, I took off quickly taking as much from these books as I could. I was in awe of the things I could create with some simple markup and inline styling typed into a text editor. Over the next few years, I would pick up bits and pieces of JavaScript as I tried to comprehend the concept of dynamic websites and how to make the markup react to user events such as clicking with a mouse. At this point I was just beginning to see the potential to create, that was unfolding in front of me. After learning enough of the basics to create some simple websites that did little more than change a background color or move a box across the screen, I shelved programming for a while. Here and there I would pick it back up to see if I could make something that came to my head, but for the most part the curiosity laid dormant until freshman year of high school.</p><h3>Intro to Web Technologies</h3><p>When it came time to enroll in my classes for the year, I came across two one semester classes called tech 20 and tech 30. I quickly signed up to take both that year, even though there was a prerequisite tech class which I had not taken. I hoped they wouldn’t make me sit through a class teaching me to use basic word processing and computer knowledge that most people had already been using for most middle school projects in the previous years. Ultimately they allowed me to skip the prerequisite course and continue my growth in JavaScript and begin to learn programming server side applications. These courses became my biggest foundations in taking off seriously learning the ins and outs of programming. It was during that year where I found that I really enjoyed developing the entire web application from the back end APIs to the front end interactive interface, except for the actual UI design itself. It came time to create the final project for tech 30 in which we were tasked with creating a rudimentary social network that could do simple tasks like register and login users, create posts, and view user profiles. I went all out on this project to make the best Facebook clone that I could. I called it MyCube and even hosted it under a subdomain off of my personal website. I took almost every aspect up a level from what was expected, using ajax requests rather than html forms and using jQuery to create dynamic user interfaces and animations.</p><h3>The Next Big Game</h3><p>It was since that project and year that I haven’t stopped dreaming up ideas for cool software projects to create. I ended up getting really interested in the idea of making an iOS app that would go viral. I had saved up enough money to buy a MacBook Pro and a year subscription to the Apple Developer portal. I learned quite a bit about Objective-C and developing really basic 2D games, but didn’t come to the point of realizing that dream. My interests instead took a twist towards the Jailbreaking community and tweaking my iPhone to it’s extremes. I even got so interested as to start developing my own iPhone hacks to utilize for myself. One of my favorite projects I created was an SMS Gateway, which essentially allowed me to process incoming text messages and reply to the message with some logic in the code. I ended up using it to create a basic rock paper scissors game, as well as blackjack.</p><h3>My First Job.</h3><p>A few years later I began my first job at my dad’s company with my role being a mix of IT and Software development, where six years later I am still employed. Though I learned a ton about software through my own creative outlet in high school, my real experience and skill sets began to grow massively as I learned and honed my skills 40 hours a week. I began to learn the value of using software libraries over developing everything from scratch. I learned different architectural design patterns, mostly by doing it the hard way first, before coming across better ways on forums or framework documentation sites. I even began learning more skills in the deployment and DevOps side of application development as my rudimentary local to ftp deployments became to risky (especially since at the time I wasn’t even using any versioning mechanisms, yikes!) My development practices got to the point where I was using containers, continuous integration, deployment channels, bundle optimizations and scalable server architecture. I hadn’t realized how fascinating the process of getting code from developers to the production servers could be until I started digging around all the services AWS had to offer and experimenting with them.</p><h3>What’s Next?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9zaku0uFz4T6Lc6k" /><figcaption>Photo by <a href="https://unsplash.com/@kalenemsley?utm_source=medium&amp;utm_medium=referral">Kalen Emsley</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Fast forward to now, I spend most of my free time either exploring new languages, frameworks or just new cool developer technology. I also try to find problems that don’t have any software solutions or that could be bettered with some form of automation or technology. My creativity especially gets sparked with my two kids. Dealing with the daily routines and struggles of having young children reveals endless new inventions that could be made to ease the life of parents. Point being made, it’s hard for me to be in most situations without finding a way to mentally bring technology into it. Be it psychological training or a deep rooted passion for creating, I feel like I will always be a developer, whether it remains in software or goes to something entirely different.</p><p>To all the software developers out there, what gives you your passion?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23aefb722149" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consuming a REST API with React Hooks (using design patterns)]]></title>
            <link>https://medium.com/weekly-webtips/implementing-a-rest-api-with-react-hooks-using-patterns-2ea1476e2a05?source=rss-5534595ced5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea1476e2a05</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-patterns]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Micaiah Wallace]]></dc:creator>
            <pubDate>Thu, 26 Nov 2020 14:24:35 GMT</pubDate>
            <atom:updated>2020-11-30T07:51:04.373Z</atom:updated>
            <content:encoded><![CDATA[<h4>Taking the basics, a bit further</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xkCVkSfZhjiwDbOV" /><figcaption>Photo by <a href="https://unsplash.com/@maximalfocus?utm_source=medium&amp;utm_medium=referral">Maximalfocus</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>As a software engineer, it is important to have a forward thinking mindset when designing the architecture for a web application. Sooner or later standards will change or better frameworks will be released (or even worse, currently used frameworks bite the dust). If sound business logic is in place, these changes won’t rock the boat too hard when trying to get new code back to a usable state.</p><p>This concept is a key one to grasp and use when developing react web applications. For the sake of this article we will simply focus on how it pertains to requesting data from an API and using it within the application. We will be looking at:</p><ul><li>The basic setup for consuming APIs with react hooks</li><li>Abstracting low level plumbing calls away</li><li>Further abstracting where it makes sense</li></ul><h3>Basic API Request Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hmFaN2z4HIN06YFt" /><figcaption>Photo by <a href="https://unsplash.com/@samthewam24?utm_source=medium&amp;utm_medium=referral">Samuel Sianipar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There are quite a number of articles available to read which aid in learning how to setup the basic plumbing to make a react app communicate with a REST api, usually something like so…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14274e647aace6c167745dcbe575ecd0/href">https://medium.com/media/14274e647aace6c167745dcbe575ecd0/href</a></iframe><p>Not bad, this will get your feet wet in the overall flow of requesting asynchronous data in the react ecosystem, however lacks quite a bit in practicality and here’s why.</p><ol><li>The component above is <strong>very tightly coupled</strong> to how the data is retrieved, rather than just the data.</li><li>It also doesn’t provide response <strong>error handling.</strong></li></ol><h3>Separation of Concerns</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O43CMwR8f2xVJqSV" /><figcaption>Photo by <a href="https://unsplash.com/@alexradelich?utm_source=medium&amp;utm_medium=referral">Alex Radelich</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A first step to improve this code would be to extract the bulk of the logic into a separate custom hook so that the consumer isn’t responsible for knowing how or where the data comes from, hence creating more separation of concern.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/073ee3212f6d63d217a6cac29291b472/href">https://medium.com/media/073ee3212f6d63d217a6cac29291b472/href</a></iframe><p>This provides us looser coupling in the TodoList, allowing the logic that retrieves the todos to be handled by a more focused, single purpose component.</p><h3>Abstract Low Level APIs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iDtse3apoK3bn6OE" /><figcaption>Photo by <a href="https://unsplash.com/@clintadair?utm_source=medium&amp;utm_medium=referral">Clint Adair</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The TodoList is starting to look better, but we still have a few problems with the way the request logic is working in our custom hook. It still requires knowing the plumbing of how to access the data, which should be moved to a lower level considering we are still operating in the business logic realm. Let’s start by abstracting the fetch call into another hook, and while we’re at it let’s add some error handling.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2b08d1bd7268150154763e67a027f2c/href">https://medium.com/media/d2b08d1bd7268150154763e67a027f2c/href</a></iframe><p>Let’s also create another file to store our request options for different requests, so that we don’t need to dig through a ton of files to change out request URLs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1e8f52e902b036541d06a99b1464342/href">https://medium.com/media/a1e8f52e902b036541d06a99b1464342/href</a></iframe><p>Then we modify the useTodos hook to implement the new request abstraction hook like so. Notice we add a useMemo call so that the request object becomes cached upon creation, thus returning the same reference to the request on every subsequent render. This serves the purpose of preventing extra unnecessary API calls from the useApiResult custom hook. The reason this works is because the useEffect hook will check the request variable for changes on every render. Since request is an object it will check for changes by reference rather than value.</p><blockquote>use the useMemo() hook to cache objects and prevent extraneous API calls</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a94e4633143840fe2d3f24f9bab09afa/href">https://medium.com/media/a94e4633143840fe2d3f24f9bab09afa/href</a></iframe><p>Now we can add the changes to display any request errors in the TodoList that come from the hook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5eac6181182760049678db0723f11d09/href">https://medium.com/media/5eac6181182760049678db0723f11d09/href</a></iframe><p>Finally we are starting to see a flow that allows room for change in the underlying plumbing while allowing the presentation and business logic to remain less affected. However, there is still another step that could be taken to abstract the plumbing just a bit further.</p><h3>Abstract even Further!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wsZXf-uLgKqcRbYE" /><figcaption>Photo by <a href="https://unsplash.com/@taliacohen?utm_source=medium&amp;utm_medium=referral">Talia Cohen</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s take the fetch call and wrap it with a unified request interface so that if we decide to use another request library, it will be easier to swap out later. We will then provide this function via a react context and a custom hook that wraps the useContext function. This will make it accessible to any component or hook wrapped within the context provider component. We will also add the context provider component to our app near the top of the component tree to ensure the components have access to the request context.</p><p>In short, here’s what we are going to do:</p><ol><li><strong>Create a</strong> <strong>new context</strong> and wrap the App with it’s provider</li><li><strong>Abstract</strong> <strong>context usage</strong> with a custom useRequest hook</li><li><strong>Create a request lib</strong> with a unified interface, pass into context’s value</li><li><strong>Use the hook</strong> wherever fetch call’s were being made</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd93fd5254cdb5e4c86bb972a00e96b6/href">https://medium.com/media/dd93fd5254cdb5e4c86bb972a00e96b6/href</a></iframe><h3>To Conclude…</h3><p>As you can see, it can be quite a bit of work initially to create separation between the business logic and the logic which performs underlying calls. However, it will payoff in the long run as the application grows and changes in the future.</p><p>I hope this information was useful and you’ve learned how to properly perform API requests within a react application, or at least ideas on how to improve your code base using abstraction and separation of concern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y7ynTIejofSnuV73" /><figcaption>Photo by <a href="https://unsplash.com/@ignitedit?utm_source=medium&amp;utm_medium=referral">Mark Basarab</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea1476e2a05" width="1" height="1" alt=""><hr><p><a href="https://medium.com/weekly-webtips/implementing-a-rest-api-with-react-hooks-using-patterns-2ea1476e2a05">Consuming a REST API with React Hooks (using design patterns)</a> was originally published in <a href="https://medium.com/weekly-webtips">Webtips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>