<?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 Alice Wang on Medium]]></title>
        <description><![CDATA[Stories by Alice Wang on Medium]]></description>
        <link>https://medium.com/@blobbyblobfish?source=rss-7b99d7e93ee4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*U4oYYVSBVSognrsGs2IfRA.png</url>
            <title>Stories by Alice Wang on Medium</title>
            <link>https://medium.com/@blobbyblobfish?source=rss-7b99d7e93ee4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:31:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@blobbyblobfish/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[There Are (Not?) Thirty-Six Ways to Sort an Array]]></title>
            <link>https://medium.com/swlh/there-are-not-thirty-six-ways-to-sort-an-array-9bb6d25971f0?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bb6d25971f0</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[problem-sol]]></category>
            <category><![CDATA[whiteboarding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Sat, 10 Oct 2020 14:13:34 GMT</pubDate>
            <atom:updated>2020-10-17T04:12:25.750Z</atom:updated>
            <content:encoded><![CDATA[<h4>Comparison-Based Sorting Algorithms</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GIHdc6XUHSgdpc9-" /><figcaption>Photo by <a href="https://unsplash.com/@thetechnomaid?utm_source=medium&amp;utm_medium=referral">Sophie Elvis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Some interview questions might ask you to sort an array. But other interview questions might ask you to solve a less straightforward problem, with an answer that tests your knowledge of the performance and implementation of different array sorting methods.</p><p>This article is designed to give the reader an overview of what different array sorting algorithms are like, and why you would use them.</p><p><em>The implementation examples are written in JavaScript and are borrowed from App Academy with my own modifications and commenting. All mistakes are my own.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TF2sX0PuzGQyWx0QLVqguw.png" /><figcaption>Source: <a href="https://www.bigocheatsheet.com/">Big O Cheatsheet</a></figcaption></figure><h3>Comparison-Based Sorting Algorithms</h3><p>These straightforward algorithms operate by comparing pairs of elements and changing their order as needed. They are best used on relatively small arrays, where the time complexity is nearly negligible, or when the arrays are guaranteed to be nearly sorted.</p><p>The highlights of these algorithms are discussed below. The implementation examples reference a swap function, seen here.</p><pre>function swap(arr, index1, index2) {<br>  let temp = arr[index1];<br>  arr[index1] = arr[index2];<br>  arr[index2] = temp;<br>}</pre><p>Note: In JS ES6 swapping without use of a temporary variable is made possible with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">destructuring</a> (e.g. [arr[2], arr[1]] = [arr[1], arr[2]] ).</p><p>The worst case time-complexity of these four algorithms is <strong>O(n²)</strong>: Bubble Sort, Selection Sort, Insertion Sort, Quick Sort.</p><p>The worst case time complexity of these two algorithms is <strong>O(n log n)</strong>: Merge Sort, Randomized Quick Sort.</p><h4>Bubble Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*bQUYTtk_0uD6uvQf.gif" /><figcaption><a href="https://open.appacademy.io/learn/full-stack-online/data-structures-and-algorithms/bubble-sort-notes">Image Source</a> (Originally from Visualgo)</figcaption></figure><p>The inner loop checks every element against its neighbor and swaps them based on which is larger, while the outer loop keeps the inner loop running until the inner loop has made a pass through the whole array without any swaps.</p><pre>function bubbleSort(array) {<br>  let swapped = true;</pre><pre>  while(swapped) {<br>    swapped = false;</pre><pre>    for (let i = 0; i &lt; array.length - 1; i++) {  <br>      if (array[i] &gt; array[i+1]) { //if this condition is not met<br>        swap(array, i, i+1);<br>        swapped = true; //the outer loop exits when the inner&#39;s done<br>      }<br>    }<br>  }</pre><pre>  return array;<br>}</pre><h4>Selection Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*LTvPraEb2A0rY_z8.gif" /><figcaption><a href="https://open.appacademy.io/learn/full-stack-online/data-structures-and-algorithms/selection-sort-notes">Image Source</a> (originally from Visualgo)</figcaption></figure><p>The outer loop steps through the array one element at a time while the inner loop finds the smallest unsorted element (i.e. the smallest element to the right of i). When the inner loop finishes, the element it started with becomes the minimum value. The outer loop then begins another pass with the element at (i+1).</p><pre>function selectionSort(arr) {</pre><pre>for (let i = 0; i &lt; arr.length; i++) { <br>    let minIndex = i;</pre><pre>for (let j = i + 1; j &lt; arr.length; j++) {<br>      if (arr[minIndex] &gt; arr[j]) {<br>        minIndex = j;<br>      }<br>    }</pre><pre>    swap(arr, i, minIndex);<br>  }<br>  return arr;<br>}</pre><h4>Insertion Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*ZsKkshHAiPzhHf0e.gif" /></figure><p>Insertion sort is the most similar to the sorting technique I used at one of my first jobs, which was alphabetizing books on library shelves by author and title. Like selection sort, and unlike bubble sort, it works its way from left to right, moving elements by more than one place at a time into a sorted section. Unlike selection sort, however, the inner loop moves through the <em>sorted</em> portion of the array one at a time to find a place for the element being evaluated in the outer loop. The outer loop moves from left to right while the inner loop goes the other direction, shifting each element one to the right until it finds that the element being evaluated is not less than the next element to the left of it. It then saves the element being sorted into the space of the duplicate element.</p><pre>function insertionSort(arr) {<br>  for (let i = 1; i &lt; arr.length; i++) { // moves right<br>    let currElement = arr[i];</pre><pre>for (var j = i - 1; j &gt;= 0 &amp;&amp; currElement &lt; arr[j]; j--) {<br>      arr[j + 1] = arr[j]; // each element is shifted right<br>    } // starting from the right-most element of the sorted portion<br>      // so arr[i] becomes the right-most sorted element, etc.</pre><pre>arr[j + 1] = currElement; //when arr[j] &lt; element<br>  }</pre><pre>return arr;<br>}</pre><h4>Merge Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*d6ta7BSFLdiSIPtT.gif" /></figure><p>Merge sort is a divide-and-conquer recursive algorithm. For a basic example of recursion, you can check out <a href="https://medium.com/@blobbyblobfish/recursively-finding-the-nth-fibonacci-number-55ebb11c8bb6">my article on solving the Fibonacci problem</a>.</p><p>Divide-and-conquer is like solving multiple sub-problems, the result of which solves the original, larger problem. In divide-and-conquer, you break down the input until the smallest component: for example, breaking down a non-empty array until it only contains one element. In this case we will call the recursive function on the input until it reaches the base case, and return it so that the function “unwinds” and produces a sorted array.</p><pre>function mergeSort(array) {<br>    if (array.length &lt;= 1) {<br>        return array;<br>    }<br><br>    let midIdx = Math.floor(array.length / 2);<br>    let leftHalf = array.slice(0, midIdx);<br>    let rightHalf = array.slice(midIdx);<br><br>    let sortedLeft = mergeSort(leftHalf);<br>    let sortedRight = mergeSort(rightHalf);<br><br>    return merge(sortedLeft, sortedRight);<br>}</pre><p>The merge helper function takes the two sorted arrays and combines them by comparing the their first elements one-by-one.</p><pre>function merge(array1, array2) {<br>    let merged = [];<br><br>    while (array1.length || array2.length) {<br>        let ele1 = array1.length ? array1[0] : Infinity;<br>        let ele2 = array2.length ? array2[0] : Infinity;<br><br>        let next;<br>        if (ele1 &lt; ele2) {<br>            next = array1.shift();<br>        } else {<br>            next = array2.shift();<br>        }<br><br>        merged.push(next);<br>    }<br><br>    return merged;<br>}</pre><p>According to Visualgo:</p><blockquote>Contrary to what many other CS printed textbooks usually show (as textbooks are static), the actual execution of Merge Sort does <strong>not</strong> split to two subarrays <strong>level by level</strong>, but it will recursively sort the <strong>left</strong> subarray first before dealing with the <strong>right</strong> subarray.</blockquote><blockquote>That’s it, on the example array [7, 2, 6, 3, 8, 4, 5], it will recurse to [7, 2, 6, 3], then [7, 2], then [7] (a single element, sorted by default), backtrack, recurse to [2] (sorted), backtrack, then finally merge [7, 2] into [2, 7], before it continue processing [6, 3] and so on.</blockquote><p>Merge sort runs in O(n * log n) — the length of the input times how many recursive calls we need to make to halve it. Unlike the other sorting algorithms discussed above, which are all O(1), merge sort is not memory efficient. The space complexity is O(n) because we need to create a new array for every element.</p><h4>Quick Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*175lKeTXF8y12EPI.gif" /></figure><p>Quick sort, like merge sort, is a divide-and-conquer algorithm that splits an input array into sorted arrays and combines them. The difference in implementation is that quick sort doesn’t split the array in half by their index but by the elements’ value relative to a pivot.</p><p>Elements less than the pivot go into the left array, and elements greater than the pivot to the right.</p><pre>function quickSort(array) {<br>    if (array.length &lt;= 1) {<br>        return array;<br>    }<br><br>    let pivot = array.shift();<br>    let left = array.filter(el =&gt; el &lt; pivot);<br>    let right = array.filter(el =&gt; el &gt;= pivot);<br><br>    let leftSorted = quickSort(left);<br>    let rightSorted = quickSort(right);<br><br>    return leftSorted.concat([pivot]).concat(rightSorted);</pre><pre>    // in ES6 you can use the spread operator:<br>    // return [ ...leftSorted, pivot, ...rightSorted ]</pre><pre>}</pre><p>The sorted arrays are then combined and returned. If in the worst case you pick the least optimal pivot, the runtime complexity will be O(n²) due to the recursive calls to filter (which is O(n) or in this case O(2n)).</p><p>The implementation of quick sort shown here is O(n) space complexity, because like merge sort we are creating a new array for every element in the input, but if you swap the elements in-place the space complexity is O(log n).</p><h4>Randomized Quick Sort</h4><p>If you know your input arrays are already mostly sorted, running them through the quick sort implementation we defined above is not a good idea. The first element will be one of the smallest and so you will be stuck sorting a long array. Picking a random pivot solves this problem.</p><h3>And that’s not all…</h3><p>Non comparison-based sorting algorithms will be covered in a future article. They are faster than comparison-based sorting algorithms. The worst case time complexity for counting sort is O(n+k) and O(w *(n+k)) for radix sort.</p><h3>Further Resources</h3><ul><li><a href="https://visualgo.net/en/sorting?slide=1">VisuAlgo - Sorting (Bubble, Selection, Insertion, Merge, Quick, Counting, Radix)</a></li><li><a href="https://open.appacademy.io/learn/full-stack-online/data-structures-and-algorithms/big-o-notes">App Academy Open</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bb6d25971f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/there-are-not-thirty-six-ways-to-sort-an-array-9bb6d25971f0">There Are (Not?) Thirty-Six Ways to Sort an Array</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arrays and Linked Lists: pros & cons]]></title>
            <link>https://medium.com/@blobbyblobfish/arrays-and-linked-lists-pros-cons-b763b383955b?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b763b383955b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Sat, 03 Oct 2020 01:57:18 GMT</pubDate>
            <atom:updated>2020-10-03T01:57:18.175Z</atom:updated>
            <content:encoded><![CDATA[<h4>What are the advantages and disadvantages of these two common data structures?</h4><h3>Introduction</h3><p>Arrays and linked lists are both data structures which store a linear collection of data. What are the differences between the two, and what should you consider when implementing them?</p><h3>Arrays</h3><p>Items in arrays are always indexed in a continuous order. The computer stores the array’s items at a memory location where contiguous places are available.</p><p>If you try to write an additional element and there is no space in the array, you have to find space for the entire array somewhere else.</p><p>Some languages like C ask for you to specify the number of elements and type of data contained when the array is created.</p><p>Arrays have easy reads and allow for random access: knowing the index of the item in the array, you can immediately access that place in memory.</p><p>But inserting items into arrays is harder.</p><p>If adding the new item will exceed the amount of space available for the array, the computer has to find another location in memory for the entire array.</p><p>If the item is added to a place other than the end of the array, all of the items succeeding it will have to shift.</p><p>When deleting an item, you have the need to shift all of the items that come after it, but there are no potential issues with running out of memory.</p><h3>Linked Lists</h3><p>In linked lists, items are stored in noncontiguous places in memory, and each item contains a reference to the next place in the list.</p><p>Linked lists are better at inserts than arrays. To add an item to a list all you have to do is find any place in memory for it and change the item at the right place in the list to point towards the new item.</p><p>Even so, linked lists are worse for reads because they can only be read in sequential order.</p><p>Once an item is found, however, deletion easy — if the item is removed the previous one can then just point to the next one.</p><h3>Performance</h3><p>Arrays are up-to O(N) inserts and O(1) reads. Linked Lists are O(1) inserts and O(N) reads. Both are worst-case O(N) deletes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b763b383955b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stacks and Queues]]></title>
            <link>https://medium.com/@blobbyblobfish/stacks-and-queues-2bf23f1d2ec1?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bf23f1d2ec1</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[whiteboarding]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 15:45:56 GMT</pubDate>
            <atom:updated>2020-09-27T15:45:56.855Z</atom:updated>
            <content:encoded><![CDATA[<h4>What’s the difference?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aiSpl_5hXVCGYKIn.png" /><figcaption><a href="https://medium.com/omarelgabrys-blog/stacks-and-queues-d96c6f35fae3">Image Source</a></figcaption></figure><p>You might have heard the terms stacks and queues before. What do they mean?</p><p>To begin, both stacks and queues are ordered collections. The key difference is in how items are added and removed.</p><p>Stacks are Last-In First-Out (LIFO). Queues are First-In First-Out (FIFO).</p><h3>What Are Stacks?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-dVwoorB_dJ0alP0" /><figcaption>Photo by <a href="https://unsplash.com/@kaimantha?utm_source=medium&amp;utm_medium=referral">Claudia Wolff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The first time I learned about stacks, I was told to think about a stack of books.</p><p>The first book you grab off of the stack is the last book that went onto the stack.</p><h4>When are stacks used?</h4><p>In <a href="https://leetcode.com/problems/remove-outermost-parentheses/">this LeetCode problem</a>, you have to remove the outer-most set of parentheses in a string containing only valid sets of parentheses that can be nested any levels deep. By putting each “(” in a stack and removing the most recent one when the algorithm finds a “)”, you eventually work backwards to find all of the outer sections of parentheses. Adding only the inner characters to a new results string allows us to find the answer. (Link to <a href="https://github.com/blobbyblobfish/algo-playground/blob/master/stacks/RemoveOuterParentheses.js">my solution</a>.)</p><h3>What Are Queues?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7GCgZ9rwIaT8nMpZ" /><figcaption>Photo by <a href="https://unsplash.com/@john_cameron?utm_source=medium&amp;utm_medium=referral">John Cameron</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Queues are as straightforward as their name suggests: in a queue, items line up or are “enqueued.” They are “dequeued” according to which entered the queue first. Just like an orderly group of people.</p><h4>When are queues used?</h4><p>In this <a href="https://leetcode.com/problems/number-of-recent-calls/">infamously disliked problem</a>, you have to count the number of requests received in a “recent” timeframe. A solution could involve using a queue to keep track of requests and to dequeue requests that are no longer considered recent when new requests come in. The reason to use a queue instead of a stack is to preserve the order in which the requests were received.</p><p>I also recently encountered a systems design question about handling spikes in POST requests. Let’s say you have an app similar to Instagram, and when a user like Beyonce posts you expect a number of “likes” that exceeds the amount that your server can handle. How do you handle Beyonce’s activity while not slowing down the activity of other users? A solution involved making a queue to asynchronously handle requests to “like” Beyonce’s photo, and a queue to asynchronously handle everyone else.</p><h3>Resources</h3><p><a href="https://leetcode.com/problemset/all/?topicSlugs=stack%2Cqueue">Problems - LeetCode</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf23f1d2ec1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief Guide to Retrieving Data with SQL]]></title>
            <link>https://medium.com/@blobbyblobfish/a-brief-guide-to-retrieving-data-with-sql-3a4607e070ab?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4607e070ab</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Sun, 13 Sep 2020 16:19:39 GMT</pubDate>
            <atom:updated>2020-09-13T16:19:39.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Hduar0k0kFjVlmXY" /><figcaption>Photo by <a href="https://unsplash.com/@jankolar?utm_source=medium&amp;utm_medium=referral">Jan Antonin Kolar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>SQL (Structured Query Language) is a language for accessing and manipulating records in a database and is a standard language for relational database management systems.</p><p>This article is utilizes two simple examples of retrieving filtered and aggregated data and is meant to serve as a quick reference guide to basic SQL queries for anyone who is new to SQL.</p><p>In these examples, we have a relational database where records in the Pages table may reference a row in the Chapters table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLizr_XEWCXooZRv7xvrXA.png" /></figure><p>The code is written in the SQLite dialect of SQL.</p><h3>Example #1 — Number of Pages Per Chapter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*3uityJ3taPU3y_jVSzX7tg.png" /></figure><pre>SELECT COUNT (page_id) AS page_count, name<br>FROM Chapters<br>LEFT JOIN Pages on Pages.chapter_id = Chapters.chapter_id<br>GROUP BY name;</pre><h4>SELECT</h4><p>Returns a result table with the column names specified by the select statement. (Note: the wildcard ‘*’ returns all values.)</p><h4>COUNT</h4><p>Returns the number of rows matching the specified criterion. Not to be confused with SUM, which returns the total values of a numeric column.</p><h4>LEFT JOIN</h4><p>Returns all values from the first table, and any matching values from the second table. (In this example, the page with the id 4 will not be returned.)</p><h4>GROUP BY</h4><p>Groups records sharing the same value into one row.</p><h3>Example #2 — Finding Chapters With Pages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*7hsPz_aF37Yra02tw6rblQ.png" /></figure><pre>SELECT name, text<br>FROM Chapters<br>INNER JOIN Pages ON Pages.chapter_id = Chapters.chapter_id;</pre><h4>INNER JOIN</h4><p>Returns the rows from both tables where there is a match between the columns. (In this case, only returning chapters with pages.)</p><p>-or-</p><pre>SELECT name, text<br>FROM Chapters<br>LEFT JOIN Pages ON Pages.chapter_id = Chapters.chapter_id<br>WHERE page_id IS NOT null;</pre><h4>WHERE</h4><p>Filters records based on the specified condition. This is replaced by HAVING when used with aggregate functions.</p><h3>References</h3><p><a href="https://www.w3schools.com/sql/default.asp">W3Schools.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4607e070ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recursively Finding the Nth Fibonacci Number]]></title>
            <link>https://medium.com/weekly-webtips/recursively-finding-the-nth-fibonacci-number-55ebb11c8bb6?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/55ebb11c8bb6</guid>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 00:16:03 GMT</pubDate>
            <atom:updated>2020-09-27T03:10:13.806Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finding the Nth Fibonacci number</h3><h4>Recursion &amp; memoization</h4><figure><img alt="Finding the Nth Fibonacci number" src="https://cdn-images-1.medium.com/max/700/0*mxCanTxOEoc_mI5o.jpg" /><figcaption><a href="https://cdn.insteading.com/wp-content/uploads/igm/b/nautilus-shell.jpg">Image Source</a></figcaption></figure><p>The Fibonacci sequence is the series of numbers starting from 0, 1 where each consecutive number N is the sum of the two previous numbers.</p><p>It goes…</p><blockquote>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 31781…</blockquote><p>Given a place in the sequence, how can we find the value of N?</p><h3>This is Where Recursion Comes In</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*gxiP4yysToQ5mGoe.jpg" /><figcaption><a href="https://www.goldencockerel.com/product/110305/zoom_110305.jpg">Image Source</a></figcaption></figure><p>Recursion is a programming paradigm in which a function calls on itself. Here is an example of a recursive function.</p><pre>function factorial(n) {<br>  if (n === 0) return 1<br>  return n * factorial(n - 1)<br>}</pre><pre>// factorial(5) =&gt; 5 * 4 * 3 * 2 * 1</pre><p>As you might expect, recursive functions are usually written with a “base case” (n === 0) at which the function stops calling on itself.</p><h3>We Can Find (N) Recursively</h3><p>As we said before, the value of a number in the Fibonacci sequence is equal to the sum of the previous two numbers. The only exceptions are the first two numbers, because they are proceeded by 1 or fewer numbers.</p><p>We can write an algorithm that finds N iteratively (by starting from 0 and following this pattern until reaching N and returning its value), but, for the sake of this example, let’s try our first recursive function.</p><pre>function fibonacci(N) {<br>    if (N &lt; 2) {<br>        return N<br>    }<br>    <br>    else {<br>        return fibonacci(N-1) + fibonacci(N-2)<br>    } <br>}</pre><p>When we call fibonacci(4), the return value we evaluate is fibonacci(3) + fibonacci(2).</p><pre>fibonacci(4) returns (fibonacci(3) + fibonacci(2))<br>fibonacci(3) is fibonacci(2) + fibonacci(1)<br>fibonacci(2) is fibonacci(1) + fibonacci(0)<br>fibonacci(1) is 1.<br>fibonacci(0) is 0.</pre><p>The return statement can be simplified to (1 + 1) + (1 + 0) = 3, or, when N = 4, the number 3 is the Nth number from 0 in the Fibonacci sequence.</p><h3>Memoization Can Make Our Solution More Memory Efficient</h3><p>Even in the above example, for N=4, we computed the same value more than once. We can reduce the amount of computations our program needs to make by caching the values.</p><p>Memoization is when a computation caches its results in an object for future reference.</p><p>In this example, I will use an object to store Fibonacci numbers that have already been computed. This allows our function to run in O(n) time, because every possible number needs only to be calculated once.</p><pre>let fibonacciSequence = {}</pre><pre>function fibonacciOptimized(N) {<br>    let val<br>    <br>    if (fibonacciSequence[N]) {<br>        val = fibonacciSequence[N]<br>    }<br>    <br>    if (N &lt; 2) {<br>        val = N<br>    }<br>    <br>    else {<br>        val = fib(N-1) + fib(N-2)<br>    }<br>    <br>    fibonacciSequence[N] = val<br>  <br>    return val<br>};</pre><h3>Should You Use Recursion?</h3><p>Just because a function can be written recursively doesn’t mean it <em>should</em> be. <a href="https://levelup.gitconnected.com/a-second-thought-on-recursion-6575efeb2934">This article</a> goes into further detail about the performance of recursive vs. iterative functions, including recursive tail call and trampoline optimizations.</p><h3>Resources</h3><p>For further reading and practice.</p><ul><li><a href="https://codeburst.io/learn-and-understand-recursion-in-javascript-b588218e87ea">Learn and Understand Recursion in JavaScript</a></li><li><a href="https://www.freecodecamp.org/news/how-recursion-works-explained-with-flowcharts-and-a-video-de61f40cb7f9/">How Recursion Works - Explained with Flowcharts and a Video</a></li><li><a href="https://leetcode.com/problems/fibonacci-number/">Fibonacci Number - LeetCode</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55ebb11c8bb6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/weekly-webtips/recursively-finding-the-nth-fibonacci-number-55ebb11c8bb6">Recursively Finding the Nth Fibonacci Number</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[The REACT-O Technical Interview Framework]]></title>
            <link>https://blog.devgenius.io/the-react-o-technical-interview-framework-17144e6ede06?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/17144e6ede06</guid>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[whiteboarding]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 01:18:52 GMT</pubDate>
            <atom:updated>2020-08-28T23:44:19.961Z</atom:updated>
            <content:encoded><![CDATA[<h4>Six Steps for Solving Whiteboarding Questions</h4><figure><img alt="Woman smiling next to whiteboard." src="https://cdn-images-1.medium.com/max/1024/0*Cro5Yk7iloaqMlng" /><figcaption>Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=medium&amp;utm_medium=referral">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last night I attended a virtual meetup of software engineers who get together to practice data structures and algorithm problems. I was almost a total beginner at whiteboarding, so I was quite nervous going in.</p><p>However, I used a six-step framework to help me work through the problem, and have fun while doing it!</p><p>This article is for anyone who is getting started with technical interviews, or wants to learn more about whiteboarding.</p><h3>Example: Comparing Binary Trees</h3><figure><img alt="Two distinct binary trees, both with a leaf value sequence of 6, 8, 5." src="https://cdn-images-1.medium.com/max/654/1*G1AAhlRpAAASiXuwHdeQwg.png" /><figcaption>Tree 1 and Tree 2 have the same leaf value sequence: 6, 8, 5.</figcaption></figure><blockquote>Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.</blockquote><blockquote>Two binary trees are considered leaf-similar if their leaf value sequence is the same.</blockquote><blockquote>Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar.</blockquote><h3>Step 1- Reiterate</h3><p>Verbalize your understanding of the problem — this is your chance to check your understanding of the question.</p><p>Make sure you agree on what you should be outputting. In this case, the goal is to write a function that takes in two tree roots and returns <em>true</em> if the both trees contain the same leaves (childless nodes) in the same order.</p><p>Ask what constraints you’re working with. For example, you might ask the interviewer what this function should return if the trees are empty, and they would might say to assume that you should assume that all trees will have at least one node.</p><h3>Step 2- Examples</h3><p>Come up with examples that represent data that will pass through your problem set, and try to include any tricky edge cases. This will orient you towards the code that you need to write in order to return the right results.</p><p>For example, in my mock interview we went with the example pictured above, which allowed us to see that we needed to go for a Depth First Search rather than a Breadth First Search.</p><h3>Step 3- Approach</h3><p>Verbalize and write down the steps you want to take and your reasoning behind them. This helps your interviewer get to know how you think and jump in with you where it’s appropriate. Pseudocode.</p><h3>Step 4 and 5- Code &amp; Test</h3><p>This is where you translate the approach you’ve thought out into working code.</p><p>A few interviewers mentioned that coming up with a correct approach and writing the code for it don’t necessarily go hand-in-hand — you need to practice both.</p><p>Ideally while you’re coding your solution out you are also testing that it is performing the way you expect. This will help you catch any syntactical errors or leaps of logic that you’ve made.</p><p>Running examples through your solution verifies that it’s working, or if you have more work to do.</p><h3>Step 6- Optimize</h3><p>A brute-force method can solve the problem, but try to optimize your work and reduce its space-time complexity if there is any remaining time. Some interviewers expect you to look through your solution and use Big-O notation to identify its performance.</p><h3>Conclusion</h3><p>That’s the REACT-O framework: Reiterate, come up with examples, work out an approach, code, test, and optimize.</p><p>Here are some other tips that were passed on to me — Practice solving problems in as many ways as you can think of. It will strengthen your ability to come up with solutions you’ve never seen before, and demonstrate your mastery over what you’ve learned. Think about your algorithm as if it was a child; you need to clearly and simply explain what you want it to do so it can follow your instructions. And lastly, don’t rely on memorizing convenience methods to get the job done. Practice writing functions that combine simple methods.</p><h3>Acknowledgments</h3><p>I learned the REACT-O interview framework from Caryn McCarthy and got additional whiteboarding advice from Jeff Green.</p><p><a href="https://www.meetup.com/shescoding-seattle/">She’s Coding Seattle</a> is the meetup group I attended. They host weekly, beginner-friendly whiteboarding practice sessions for people in tech who identify as women and non-binary.</p><p>The binary tree comparison problem came from them, and the example was created by Dianna Tingg.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17144e6ede06" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/the-react-o-technical-interview-framework-17144e6ede06">The REACT-O Technical Interview Framework</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Many Ways to Write JavaScript Functions]]></title>
            <link>https://levelup.gitconnected.com/the-many-ways-to-write-javascript-functions-f5e42be0a30c?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e42be0a30c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functions-in-javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 02:48:37 GMT</pubDate>
            <atom:updated>2020-07-01T16:54:30.903Z</atom:updated>
            <content:encoded><![CDATA[<p>A function might be a staple object in programming, but you might see them written many different ways in JavaScript, even within the same code base — this is because functions have different properties depending on how they were defined.</p><p>This is a field guide to the different types of functions you might encounter on your JavaScript programming journey, derived from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions#Defining_functions">documentation from the MDN Web Docs</a>.</p><h3>Overview</h3><p>The syntax a function is written in determines these properties: whether or not it is hoisted, named, has an implicit return, or lexically binds the value of the this keyword.</p><p>I made this graph to summarize what we’re working with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cz7cauHdXcTG1Egid2ru1g.png" /><figcaption>Note: Both Functions and Generator Functions can be created using their respective object constructors, but this is not recommended.</figcaption></figure><h3>Function Declarations</h3><p>I have found this to be the most common way functions are written in plain ol’ vanilla JavaScript. Here is an example:</p><pre>cow() //=&gt; &quot;moo&quot;</pre><pre>function cow() {return &quot;moo&quot;}</pre><p>Note that the function can be invoked before it is declared because its definition is put into memory during compilation, before the code is executed.</p><p>For function declarations, as well as all of the other types of functions except arrow functions, the value of the this keyword changes depending on its execution context. In ES2015 the .bind(someObj)method allows you to permanently set the value of this as the object passed into .bind.</p><pre>function f() {<br>  return this.a;<br>}<br><br>var g = f.bind({a: &#39;azerty&#39;});<br>console.log(g()) //=&gt; azerty<br><br>var h = g.bind({a: &#39;yoo&#39;}); // bind only works once!<br>console.log(h()) //=&gt; azerty<br><br>var o = {a: 37};<br>console.log(o.a, o.f(), o.g(), o.h()) //=&gt; 37,37, azerty, azerty</pre><p>(modified from: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this</a>)</p><h3>Function Expressions</h3><p>Function expressions, unlike function declarations, do not have to be named and are not hoisted.</p><p>Unnamed, or <em>anonymous</em> functions, are popularly used as callbacks because they are immediately invoked. However, the MDN Web Docs notes that it is still useful to name your functions to make it easier to trace them in your call stacks.</p><pre>const dog = function() { return &quot;bark&quot; }</pre><pre>dog() //=&gt; &quot;bark&quot;</pre><pre>(function() {return &quot;meow&quot;})() //=&gt; &quot;meow&quot;</pre><p>You cannot reuse immediately invoked functions even if they are named.</p><pre>(function sheep() { return &quot;baa&quot; })() //=&gt; &quot;baa&quot;</pre><pre>sheep() //=&gt; ReferenceError: sheep is not defined</pre><h3>Function* Declarations</h3><p>Using the function* keyword defines a special type of function known as a generator function.</p><p>Unlike regular functions, which execute all the way through when called, generators are functions that can be exited and later re-entered at different points. This allows them to change the values they return even when called with the same parameters.</p><pre>function* yieldAndReturn() {<br>  yield &quot;Yield&quot;<br>  return &quot;Return&quot;<br>  yield &quot;unreachable&quot;<br>}</pre><pre>const gen = yieldAndReturn()</pre><pre>console.log(gen.next()) //=&gt; { value: &quot;Yield&quot;, done: false }</pre><pre>console.log(gen.next()) //=&gt; { value: &quot;Return&quot;, done: true }</pre><pre>console.log(gen.next()) //=&gt; { value: undefined, done: true }</pre><p>(modified from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*</a>)</p><p>When invoked, generator functions return a Generator object with three instance methods: .next , .return , and .throw . Calling .next() returns an object with a key value — which points to the yield, and done — which points to a boolean indicating whether or not the generator function has reached the end of its body.</p><p>Generator functions, along with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function">async functions</a> , are used in asynchronous programming.</p><h3>Function* Expressions</h3><p>Generator functions can also be written as expressions. Function* definitions are hoisted while function* expressions are not.</p><pre>const foo = function* () {<br>  yield 10<br>  yield 20<br>}</pre><pre>console.log(foo().next()) //=&gt; { value: 10, done: false }<br>console.log(foo().next()) //=&gt; { value: 10, done: false }</pre><p>(modified from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*</a>)</p><p>Note that (for both function* declarations and expressions) you have to save the generator object returned by the function in a variable in order to use .next() to step through the function.</p><pre>const foo = function* () {<br>  yield 10<br>  yield 20<br>}</pre><pre>const gen = foo()</pre><pre>console.log(gen.next()) //=&gt; { value: 10, done: false }</pre><pre>console.log(gen.next()) //=&gt; { value: 20, done: false }</pre><pre>console.log(gen.next()) //=&gt; { value: undefined, done: true }</pre><p>Each time the function is called a new generator object is returned.</p><pre>const foo = function* () {<br>  yield 10<br>  yield 20</pre><pre>}</pre><pre>const gen = foo()<br>const bar = foo()<br>console.log(gen === bar) //=&gt; false</pre><h3>Arrow Functions</h3><p>Lastly, arrow functions are a unique, non-named way of writing functions. They are not hoisted.</p><pre>const arrowFn = () =&gt; &quot;hi&quot;<br>arrowFn() // =&gt; &quot;hi&quot;</pre><pre>(() =&gt; &quot;hi&quot;)() //immediately invoked arrow function</pre><p>Arrow functions implicitly bind the value of this to its lexical context when it is <em>defined</em>.</p><p>Syntactically, there is some variation in arrow functions. The opening parentheses are optional if there is one argument, but needs to be present if there are zero or two or more. The braces around the body the function are also optional if there is only one expression but you need to parentheses if you are returning an object.</p><pre>param =&gt; expression <br>(param) =&gt; { return expression }</pre><pre>// these two are equivalent</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e42be0a30c" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/the-many-ways-to-write-javascript-functions-f5e42be0a30c">The Many Ways to Write JavaScript Functions</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time-Saving VS Code Shortcuts]]></title>
            <link>https://medium.com/swlh/time-saving-vs-code-shortcuts-ea2dda726662?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea2dda726662</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-tips]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Fri, 12 Jun 2020 23:06:07 GMT</pubDate>
            <atom:updated>2020-06-14T17:28:08.123Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you ever watch experienced programmers perform magic tricks in their text editors and wonder how they did it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*PVfKq9LqYohc5_A9.jpg" /></figure><p>Me too. That’s why I compiled this list of VS Code keyboard shortcuts you need to know. You’ll be shaving seconds off of every line you code.</p><h3>View &amp; Edit Shortcuts</h3><p>Press ⌘K ⌘S to open up keybindings. You can easily browse or search for the command to view a helpful reference to its shortcut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kGhhfz-3KCV9J4fJ.png" /></figure><p>You can also add / edit / remove commands and their shortcuts using this <a href="https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference">guide</a>.</p><h3>Add Cursors</h3><p>Using the mouse: option + click</p><p>Using the keyboard: command + option + up or down</p><h3>Duplicate Line / Selection</h3><p>Have your cursor on the line you want or select the lines and press shift + option + up or down. Both will create a new copy of the targeted line(s) of code underneath the selection.</p><h3>Multi-Select</h3><p>Select next instance of the word your cursor is on / phrase you have selected: command + d</p><p>Select all instances: command + shift + l</p><h3>Global Search &amp; Replace</h3><p>Open up the search panel with command + shift + h</p><p>When you do this it automatically populates the search input area with your cursor, so you can immediately start typing your search term.</p><p>Press tab and type your replacement term and press option + command + enter</p><p>Press enter again to confirm and press command + b to close the panel.</p><p>Note: You can exclude files or instances of the search term from being replaced or specify which files to target using the controls in the panel.</p><h3>Cursor Jumping &amp; Selection</h3><p>Jump cursor word-by-word: option + left or right</p><p>Expand selection word-by-word: option + shift + left or right (NOT up or down — this will cause the selection to be duplicated).</p><p>Expand selection line-by-line: function + shift + left, right, up or down</p><h3>Move Lines</h3><p>Move line(s) up or down in your file: option + arrow up or down</p><h3>Easy Formatting</h3><p>To tab the whole file: option + shift + f</p><p>Only selected code: (⌘K ⌘F)</p><p>VS Code has default formatters for JavaScript, TypeScript, JSON, and HTML, and you can download <a href="https://marketplace.visualstudio.com/search?target=VSCode&amp;category=Formatters&amp;sortBy=Relevance">extensions to support additional languages</a>.</p><h3>Keymaps</h3><p>Press (⌘K ⌘M) to search for and install emulators to bring keyboard shortcuts from other text editors to VS Code.</p><h3>Toggle Terminal</h3><p>If your cursor is in the editor, control + backtick will jump the cursor to the terminal and open a terminal if it’s not already open. If the cursor is in the terminal, control + backtick will close the terminal and return the cursor to its last position in the code file.</p><h3><strong>Conclusion</strong></h3><p>And that’s only scratching the surface! Feel like a l33t h@cker yet? Share your favorite VS Code tricks in the responses.</p><h3>Additional Resources</h3><p><a href="https://www.vscodecandothat.com/">VS Code Can Do That?!</a></p><p>VS Code’s official condensed keyboard shortcut guide for <a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf">Mac</a>, <a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf">Windows</a>, and <a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf">Linux</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fule4vhcY1xEKQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactionseditor-cat-typing-ule4vhcY1xEKQ&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fule4vhcY1xEKQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/553a3ede4d7220aeb9d7d0dcb337bb12/href">https://medium.com/media/553a3ede4d7220aeb9d7d0dcb337bb12/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea2dda726662" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/time-saving-vs-code-shortcuts-ea2dda726662">Time-Saving VS Code Shortcuts</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ouch, JavaScript Is Killing Me]]></title>
            <link>https://medium.com/better-programming/ow-javascript-is-killing-me-8aa0600e049b?source=rss-7b99d7e93ee4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aa0600e049b</guid>
            <category><![CDATA[healthy-lifestyle]]></category>
            <category><![CDATA[lifestyle]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[erognimics]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alice Wang]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 22:41:40 GMT</pubDate>
            <atom:updated>2020-06-08T08:31:11.646Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ergonomics and how you can set up a healthy workstation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aueT5ztVDO3qz1wO" /><figcaption>Photo by <a href="https://unsplash.com/@samule?utm_source=medium&amp;utm_medium=referral">Samule Sun</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Many of us spend hours at a time on the computer, squinting at code. It doesn’t take long to develop aches and pains. I started to wonder if our computer habits could be permanently damaging our bodies.</p><p>I did some research on the risks associated with spending long hours on the computer. This article discusses what to watch out for and ways to stay healthy while programming.</p><h3>Neck and Back</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*NoxdAW1ih_Ty8-W9" /><figcaption>Source: <a href="https://gunnar.com/blog/what-is-digital-eye-strain/#">Gunnar, “What Is Digital Eye Strain?”</a></figcaption></figure><p>Long hours of sitting, especially in postures that are bad for the spine, can cause chronic pain. The best way to cope with this problem is to prevent the pain in the first place.</p><p>The <a href="https://www.uclahealth.org/spinecenter/ergonomics-prolonged-sitting">UCLA Spine Center</a> recommends standing up, stretching, and walking for 1-2 minutes for every 30 minutes of sitting in order to loosen up muscles, joints, ligaments, and tendons.</p><p>In addition, it’s important to maintain a neutral, upright spine while sitting. Sit in a natural, upright position, and look straight ahead — avoid tilting your head up or down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*v_RGUN91yNNXvks1" /><figcaption>Source: <a href="https://mollysportsmassage.com/2020/01/15/tech-neck/">Molly Sports Massage, “Tech Neck”</a></figcaption></figure><blockquote>“When you look straight ahead, the weight of your head is between 10 and 12 pounds. Even if you only bend your neck forward 15 degrees to look at your phone, it doubles the weight of your head, making your head weigh around 27 pounds. Imagine bending your neck at 45 degrees — that’s almost 50 pounds of weight your neck muscles, upper back and shoulders are supporting.”</blockquote><blockquote>— <a href="https://spineina.com/blog/all-about-tech-neck/">Spine Institute of North America</a></blockquote><p>Any time our carriage is misaligned, some muscles have to strain themselves to support the load, while others become weakened. Overworked muscles can become inflamed, causing arthritis in nearby joints.</p><p>Strengthening the muscles that hold the body upright is an effective way to correct and prevent posture-related pain. The <a href="https://health.clevelandclinic.org/poor-posture-hurts-your-health-more-than-you-realize-3-tips-for-fixing-it/">Cleveland Clinic</a> recommends trying these muscle-strengthening exercises:</p><ul><li><strong>Superman.</strong> Lie on your stomach, and simultaneously raise your arms and legs just a couple inches off the ground. Hold, relax, and repeat.</li><li><strong>Core.</strong> Crunches, planks, and leg extensions all help strengthen your core muscles.</li><li><strong>Neck extension. </strong>Sit comfortably, and press your head firmly backward into your chair (or car) headrest or into your hands. Hold for 30 seconds multiple times to build strength.</li><li><strong>Shoulder blades.</strong> Work your trapezius and rhomboid muscles to help pull your shoulders back. Hold an exercise band in front of you at shoulder height, then stretch it across your chest, bending your arms slightly. Return to the starting position, and repeat.</li></ul><p>If you are looking for corrective exercises, this <a href="https://www.nhs.uk/live-well/exercise/common-posture-mistakes-and-fixes/">UK National Health Service’s list</a> supplies ways to fix common bad habits.</p><h3>Eyes</h3><p>Our eyes are a delicate part of our body. Staring at a screen for too long can lead to tired eyes. This is due to two factors: (1) drying up the surface of the eye, (2) tiring the muscles that hold the eyes in place and contract the eye lens when looking at objects at a close distance.</p><p>I’ve long wondered if I’ve been wearing down my eyes permanently each time I look at something for too long. The good news is that <a href="https://www.aao.org/eye-health/diseases/what-is-eye-strain">according to the American Academy of Ophthalmology</a>, eye strain doesn’t lead to permanent damage.</p><p>It’s important to remember to blink while using computers because blinking recoats the eye in a tear film that keeps it hydrated. It’s also good to alternate looking at further distances.</p><p>The most consistent piece of advice I found is the 20–20–20 rule: Every 20 minutes, take a 20 second break and look at something 20 feet away. This will help prevent eyestrain.</p><p>I was considering getting a pair of blue-light glasses, <a href="https://www.webmd.com/eye-health/news/20191216/do-blue-light-glasses-work">but there’s conflicting evidence on whether or not they help</a>, though any antireflective glasses can reduce harsh glare.</p><h3>Arms and Wrists</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mc3tIteUX9DsJrbP.jpg" /></figure><p>Repetitive strain injury (RSI) is a catchall term used to describe conditions like tendonitis and carpal tunnel syndrome, in which there’s a gradual buildup of damage to muscles, tendons, and nerves from repeating the same motion over time. Symptoms of RSI include swelling, tingling, numbness, stiffness, weakness, and sensitivity to cold or heat.</p><p>Just by doing a brief online search, I found stories of <a href="https://medium.com/@monroemann/some-tips-to-avoid-wrist-hand-pain-while-typing-9537c75545ab">three</a> <a href="https://medium.com/@mrmrs_/i-got-rsi-and-what-happened-next-wasnt-surprising-at-all-63ddb58b5e3f">different</a> <a href="https://blog.evanweaver.com/2012/09/05/a-programmers-guide-to-healing-rsi/">programmers</a> suffering from arm and wrist pain. I learned that overtaxing one’s wrists can lead to potentially career-ending pain:</p><blockquote>“I reduced my computer interaction but I kept trying to do work. The pain in my arms continued to get worse. What started out as some wrist pain while I worked, evolved into what felt like a sunburn down both of my arms. It hurt to pick up or use my phone. It hurt to touch a computer.</blockquote><blockquote>At this point I would describe myself as in a state of “very freaked out” My career was largely centered around designing through writing on a computer. My internal perceived value was tied to my ability to manipulate, produce, and delete code. Would I need to change careers? Could I use some dictation software to code? What am I going to do? What careers involve no computering? My head was filled with stressful questions.”</blockquote><blockquote>— <a href="https://medium.com/u/47ae71ef6ae9">mrmrs,</a> “<a href="https://medium.com/@mrmrs_/i-got-rsi-and-what-happened-next-wasnt-surprising-at-all-63ddb58b5e3f">I Got RSI and What Happened Next Wasn’t Surprising At All</a>”</blockquote><p>Taking regular breaks is important in preventing RSI. According to the <a href="http://www.rsi.deas.harvard.edu/minor.html">Harvard RSI Action group</a>, if you have mild symptoms of RSI, you can continue typing as long as you find out how long you can type without symptoms and take a break 10 minutes before reaching that point so as to prevent the build-up of tissue damage that can lead to permanent pain.</p><p>It’s also important to keep your hands in a natural position while typing. I learned in elementary school that I shouldn’t rest my wrists on my keyboard while typing because this puts pressure on the carpal tunnel nerve, but typing this article was the first time I noticed that my hands splay out and my wrists curve inward while typing.</p><p>I often have my computer on my lap, and I have to do a T-Rex thing with my arms because my elbows drop below the level of my keyboard. Simply fixing my posture so that my forearms run parallel to the keyboard and my wrists are straight while typing took away the tingling I was feeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*DBXvQSpOSaObJDVq" /><figcaption>Source: <a href="https://www.thewindowsclub.com/be-aware-of-the-carpal-tunnel-syndrome/">TheWindowsClub, “Intensive Mouse users, be aware of the Carpal Tunnel Syndrome!”</a></figcaption></figure><p>Lastly, a few sources recommended regular preventative stretching. This simple stretch can be helpful for both preventing and alleviating RSI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/0*R4CyiVX7ZgnAXWdX.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/0*O9nXANi0Q-VJjCPH.gif" /><figcaption>(1) Prayer Position. (2) Push fingers to the left. Then the right. (3) Rotate fingers towards the body. (4) Point fingers away from the body. (5) Point downwards. Hold for 15-30 seconds each. Don’t overdo. Source: <a href="http://www.rsi.deas.harvard.edu/preventing.html">Harvard RSI Action</a></figcaption></figure><h3>Conclusion</h3><p>It’s important to take care of your health while programming.</p><p>The best medicine is preventative medicine. Take breaks, stretch, exercise, and go easy on your eyes and wrists. If you’re experiencing chronic back pain or symptoms of RSI, see a physical therapist and take action now to stop the buildup of damage to your body.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aa0600e049b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/ow-javascript-is-killing-me-8aa0600e049b">Ouch, JavaScript Is Killing Me</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>
    </channel>
</rss>