<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: SpencerLindemuth</title>
    <description>The latest articles on Forem by SpencerLindemuth (@spencerlindemuth).</description>
    <link>https://forem.com/spencerlindemuth</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F184098%2F431ab021-c685-4a5c-b391-a5a9860abfc9.jpeg</url>
      <title>Forem: SpencerLindemuth</title>
      <link>https://forem.com/spencerlindemuth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/spencerlindemuth"/>
    <language>en</language>
    <item>
      <title>Ref's can change the flow of the game. Don't overReact</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Fri, 22 Nov 2019 21:13:30 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/ref-s-can-change-the-flow-of-the-game-don-t-overreact-9eh</link>
      <guid>https://forem.com/spencerlindemuth/ref-s-can-change-the-flow-of-the-game-don-t-overreact-9eh</guid>
      <description>&lt;h2&gt;
  
  
  What are ref's?
&lt;/h2&gt;

&lt;p&gt;   Traditionally ref's are the the people in black and white striped shirts who blow whistles and get paid a lot of money to not understand what pass interference is. Ref's are also a really cool feature in React to help manage child component updates without using the traditional flow of updating state, passing props and triggering a re-render, but are also incredibly useful in creating concrete references to instances of components and DOM Nodes. &lt;/p&gt;

&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;  Finding and using data from DOM nodes is pretty straightforward in JavaScript and React. Use a &lt;code&gt;document.querySelector&lt;/code&gt; or &lt;code&gt;document.getElementById&lt;/code&gt; whenever you need to reference a node. But what happens when we need to reference a node all across the application? You end up writing a lot of query selectors because the reference usually only survives for the life of the function they are found in. Here is an example of a simple page that focuses the input on button click using query selectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;focusInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Please&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focusInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;Set&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;Field&lt;/span&gt; &lt;span class="nx"&gt;Focus&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Seems pretty simple. But what happens when we want to make it a controlled input?&lt;br&gt;
We need to reference the value of the target node's event on change. But let's get add another feature too, and add a button to clear the input field...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;focusInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;clearInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Please&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focusInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;Set&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;Field&lt;/span&gt; &lt;span class="nx"&gt;Focus&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clearInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Clear&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ok so we've added some state, some click listeners and we are referencing the input field value with the event target value and we clear the input by clearing the state value the input is tied to. But when we click the clear button, the input field loses focus! This isn't very intuitive. How can we refocus? We &lt;em&gt;would&lt;/em&gt; write another query selector and use the &lt;code&gt;.focus()&lt;/code&gt; method, but since we are such good programmers, we already have a focus method written for us, so we can just call that after setting state! Now our app is working flawlessly and it only took 42 lines! Nice!&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we improve on that?
&lt;/h3&gt;

&lt;p&gt;  Ref's provide a global access to the node or instance to be referenced or interacted with anywhere in the class and this node is then able to be passed around to be referenced and interacted upon by other components. Ref's are able to do this by being declared in the constructor with the &lt;code&gt;.createRef()&lt;/code&gt; method as seen here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createRef&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;clearInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name-input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Please&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;Set&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;Field&lt;/span&gt; &lt;span class="nx"&gt;Focus&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clearInput&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Clear&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;Field&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code does the same thing as the previous code but using Refs. It's 39 lines, which isn't a huge improvement, but a penny paid is a penny saved in my book. Let's break down what's changed. We create the ref in the constructor, so the input field is referenceable everywhere in out class. For example, in the &lt;code&gt;onClick()&lt;/code&gt; method of the focus button, we don't need to write an external function and a query selector. We simply reference the textInput ref and use the &lt;code&gt;.focus()&lt;/code&gt; method. Now in this code we only "find" the DOM node once, when it's built, versus 3 times in the previous code. In this code we also drop the &lt;code&gt;ev.target.value&lt;/code&gt; we used before and directly reference the current value of the input field. &lt;/p&gt;

&lt;h3&gt;
  
  
  Other advantages
&lt;/h3&gt;

&lt;p&gt;  Those were obviously crude examples where we didn't gain a large view of the advantage of refs, but it showed syntax and ease of implementation. So what are the larger scale advantages? One of the biggest is stepping away from HTML id's for locating elements, which can change, creating lots of "find and replace"-ing by referencing the instance of the node itself. Another advantage is readability and ease of access. For example, with form validations, if a user presses submit, but forgot to enter their address, it's very easy to highlight the error field, and focus the cursor there to intuitively point the error out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Things to note
&lt;/h3&gt;

&lt;p&gt;  Ref's don't work with functional components. This is because functional components do not have a &lt;code&gt;this&lt;/code&gt; context (aka they don't have an instance). So you cannot reference the functional component like a class component. You &lt;em&gt;can&lt;/em&gt; however use ref's &lt;em&gt;inside&lt;/em&gt; a functional component by declaring them at the top of the function as a global variable. Another note is that when referring to a node with a &lt;code&gt;ref&lt;/code&gt;, the node itself is stored in the &lt;code&gt;.current&lt;/code&gt; method as seen above in &lt;code&gt;this.textInput.current.focus()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;  Refs are a great tool providing easy access to DOM elements and passing nodes around, but at the end of the day, they are at risk of being overused. They take components and actions out of the traditional dataflow of React, avoiding the almighty rule that state changes should re-render components, which characterizes React as a framework. So be careful with all this newfound knowledge and use them only when necessary! Usually in the context of forms and accessibility. &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Realm Data Storage in React Native and Node.js</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Mon, 18 Nov 2019 00:11:15 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/realm-data-storage-in-react-native-and-node-js-c57</link>
      <guid>https://forem.com/spencerlindemuth/realm-data-storage-in-react-native-and-node-js-c57</guid>
      <description>&lt;p&gt;  I've been developing a React Native application recently that stores some highly confidential information and it really made me stop and think about storage solutions. I'm traditionally a React web developer and I hadn't really stopped to consider the differences between web and native application development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Differences
&lt;/h3&gt;

&lt;p&gt;  When you create a traditional web application or site, your data persistence is kept to the back-end, and when you need more information, or need to save some, you send HTTP requests back and forth with the server who will handle that with a database connection. If you have something more short term you need to store, like a user or session id, you have a handful of options such as cookies, session storage, and HTML 5 LocalStorage. This is a fine solution that has functioned elegantly for years and something we are all overly familiar with. But when it comes to mobile app development things can be a little trickier. In mobile app development come a new set of hurdles that users on desktops aren't faced with. Spotty connections, limited data plans, and slower network speeds. These sort of hurdles can present a large barrier in terms of application performance. If you need to gather a feed of photos, there is still no way around making a network request, using data, and relying on an internet connection. But what if there is data or pages a client uses frequently and are an integral part of the app whether the client is at home on wifi or across the world and roaming? Now we need a quick, reliable and safe place to save this data with a little more longevity than cookies. &lt;/p&gt;

&lt;h3&gt;
  
  
  Built in storage with React Native
&lt;/h3&gt;

&lt;p&gt;  React native comes with a built in storage solution that works across all platforms called AsyncStorage. Just like HTML 5's implementation of LocalStorage, it stores strings of data in a key - value pair, however AsyncStorage (as the name implies) stores data Asynchronously. The problem with AsyncStorage is that data can only be of the type "String" so data must constantly be converted back and forth, it cannot be reliably encrypted, and it can only store key - value pairs, which gets very complex for large data sets and the data can have no polymorphic relationships. &lt;/p&gt;

&lt;h3&gt;
  
  
  Enter Realm
&lt;/h3&gt;

&lt;p&gt;  Realm is a storage system built for all platforms that uses an object oriented approach to databases, and can interface with Java, Swift, Objective-C, JavaScript, and .Net. Realm is also handy in the fact that it dynamically encrypts data depending on environment, using &lt;code&gt;AES-256 standard encryption&lt;/code&gt; on an Android Device, the built in &lt;code&gt;CommonCrypto&lt;/code&gt; library in iOS and the &lt;code&gt;Crypto&lt;/code&gt; library included in Windows for native Windows applications. This means less code for you, and 200% more flawlessly running environments!&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use Realm
&lt;/h3&gt;

&lt;p&gt;  Getting started with Realm is easy. First create a new React Native project:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;react-native init &amp;lt;project-name&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Then install Realm:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save realm&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;and then link Realm to your native project:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;react-native link realm&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
So now we have a project created, lets see how to implement a super simple React Native App that utilizes Realm (from the Realm &lt;a href="https://realm.io/docs/javascript/latest/"&gt;docs&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Realm&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;realm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="c1"&gt;//Create a simple class component&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;project&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;//initialize a piece of state that we will also be persisting&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;componentWillMount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//open the realm database connection&lt;/span&gt;
    &lt;span class="nx"&gt;Realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="c1"&gt;//define the schema. &lt;/span&gt;
      &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}}]&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;realm&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;//here we create a new Realm "Dog" object as if it was a class&lt;/span&gt;
        &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Rex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="c1"&gt;//here we update state with the data from Realm&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;realm&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;realm&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Number of dogs in this Realm: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loading...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and here is a more in depth look at interfacing with Realm storage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Realm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;realm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Define your models and their properties&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CarSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;make&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;int&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PersonSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Person&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;cars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car[]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;picture&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// optional property&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;Realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;CarSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PersonSchema&lt;/span&gt;&lt;span class="p"&gt;]})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;realm&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Create Realm objects and write to local storage&lt;/span&gt;
    &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myCar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;make&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Honda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Civic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="nx"&gt;myCar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;miles&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Update a property value&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Query Realm for all cars with a high mileage&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;miles &amp;gt; 1000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Will return a Results object with our 1 car&lt;/span&gt;
    &lt;span class="nx"&gt;cars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; 1&lt;/span&gt;

    &lt;span class="c1"&gt;// Add another car&lt;/span&gt;
    &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myCar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;realm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;make&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ford&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Focus&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;miles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Query results are updated in realtime&lt;/span&gt;
    &lt;span class="nx"&gt;cars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; 2&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is important to note that Realm is also an &lt;em&gt;Asynchronous&lt;/em&gt; storage solution, like the built in AsyncStorage in React Native.&lt;/p&gt;

&lt;h3&gt;
  
  
  Relationships
&lt;/h3&gt;

&lt;p&gt;  Just like complex database storage solutions using a back-end server, Realm supports complex relationships such as to-one and to-many's. For a to-one relationship, simply set the &lt;code&gt;type&lt;/code&gt; of an object's property to the name of the related object, for example from the above code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PersonSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Person&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;car&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;picture&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// optional property&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The car property of the Person object (&lt;code&gt;Person.car&lt;/code&gt;) is set to 'Car', or a Car object, declaring the relationship, instead of "string" or "integer" type. For a to-many relationship, simply append a "[]" to the Object Property, defining it as a list. From the example above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PersonSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Person&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;cars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car[]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;picture&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// optional property&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Person.cars&lt;/code&gt; now return a list of Car objects, because &lt;em&gt;one&lt;/em&gt; Person has &lt;em&gt;many&lt;/em&gt; cars. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;If you are in need of a fast and secure storage solution in a mobile application that handles large sets of data in a locally stored, easy to digest manner, look no further than Realm. The documentation &lt;a href="https://realm.io/docs/javascript/latest/"&gt;here&lt;/a&gt; is extremely helpful, and describes all of the complex actions Realm can handle, including direct queries, advanced relationships, migrations, and encryption.&lt;/p&gt;

</description>
      <category>node</category>
      <category>react</category>
      <category>javascript</category>
      <category>realm</category>
    </item>
    <item>
      <title>Concurrent Mode and Suspense in React</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Fri, 08 Nov 2019 22:18:08 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/concurrent-mode-and-suspense-in-react-1e1p</link>
      <guid>https://forem.com/spencerlindemuth/concurrent-mode-and-suspense-in-react-1e1p</guid>
      <description>&lt;h1&gt;
  
  
  Concurrent mode and interruptible rendering
&lt;/h1&gt;

&lt;p&gt;  An experimental build of React was recently released that contained an exciting new feature, a way to fetch data and render UI elements with &lt;em&gt;concurrency&lt;/em&gt;. This means we no longer have to fetch data in a useEffect() or componentDidMount() function and wait for the fetch to complete while the user is faced with a blank state screen before the elements all pop in together when the promises are resolved and the map function has mapped. &lt;/p&gt;

&lt;h3&gt;
  
  
  How does it work?
&lt;/h3&gt;

&lt;p&gt;  With the old method, which is considered a &lt;em&gt;blocking render&lt;/em&gt;, as your app loads, it only loads the pieces it already has all the data ready for. Your navigation bars, backgrounds, and containers. What doesn't get loaded is the data inside the containers. The posts, pictures, avatars, and usernames. That is, until the necessary fetches complete and resolve and state is set. This is a problem because state, which updates asynchronously on the browser queue, can only set one item at a time. The order of events looks a lot like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; We request the users avatar and username&lt;/li&gt;
&lt;li&gt;We wait...&lt;/li&gt;
&lt;li&gt;We finish fetching the avatar and username&lt;/li&gt;
&lt;li&gt;We render the avatar and username components&lt;/li&gt;
&lt;li&gt;We start fetching the users posts and pictures&lt;/li&gt;
&lt;li&gt;We wait...&lt;/li&gt;
&lt;li&gt;We finish fetching the posts and pictures&lt;/li&gt;
&lt;li&gt;We render the posts and picture components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And to see it in action with a CodeSandbox from the React documentation (press the refresh button in the sandbox browser):&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/8huj6"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We can see that it first makes a request for the username, waits until it's complete while displaying "Loading profile...", waits until the username is loaded, displays it, and then begins fetching the posts. This is the &lt;em&gt;blocking render&lt;/em&gt;. It renders things in the order in which they are received, and once it begins rendering and awaiting the data, it can't be stopped. Another example of &lt;em&gt;blocking render&lt;/em&gt; is when typing in a dynamic search field. Say you have a search box for usernames, and after a user presses the "a" key, a state change is triggered, a fetch request for the usernames containing "a" is triggered, the results come in, the results are mapped to a collection of &amp;lt;SearchResult /&amp;gt; components, and they are displayed. Now that's a lot of steps... What happens when a user presses "b" halfway through? Well it triggers another state change... But state changes are asynchronous on the browser queue, so it has to wait for the fetch and render to finish before it can be changed, then we have to follow all of these steps again. This makes your input jumpy and laggy, especially with lots of results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Suspense - How does it work?
&lt;/h2&gt;

&lt;p&gt;  Suspense takes a new approach by utilizing &lt;em&gt;interruptible rendering&lt;/em&gt;, which is to say when new data is received, React determines the priority of the new addition to the queue and renders what it sees fit. In other words, if it is awaiting fetch requests to return data, in memory, it will build semi-constructed components and only render the pieces it has information for. So whenever a component has all the pieces it needs to be displayed, React pushes it to the top of the queue to be displayed next. The flow would look something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We start fetching&lt;/li&gt;
&lt;li&gt;We start rendering&lt;/li&gt;
&lt;li&gt;We finish fetching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that is a lot fewer steps and we never have to wait! We can again, see it in action here with a CodeSandbox from the React documentation (press the refresh button in the sandbox browser):&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/onr9j"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If we look closely, it begins rendering the username &lt;em&gt;and&lt;/em&gt; the post components, then displays them quickly as they come in. Much faster! If we revisit our case of dynamic search and are looking for usernames again, what's the flow with Suspense? A user hits "a", a state change is triggered, Suspense starts building result components, a fetch reque... oh wait the user typed 'b'! Ok we still have the components being constructed, but they don't have any data yet, so let's just throw the new data on them! Boom! Rendered.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use it?
&lt;/h3&gt;

&lt;p&gt;  So how do we use this new amazing feature to enrich our applications and improve user experience by reducing jumpy loading and wait times? Here is a code snippet from the React docs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fetchProfileData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ProfilePage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt; &lt;span class="nx"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;}&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ProfileDetails&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;}&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ProfileTimeline&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Suspense&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Suspense&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ProfileDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Try to read user info, although it might not have loaded yet&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;read&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ProfileTimeline&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Try to read posts, although they might not have loaded yet&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;read&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first thing we do is call a function that fires our fetch requests (in this case fetchProfileData()). Next in the return of our &amp;lt;ProfilePage /&amp;gt; functional component, we wrap both &amp;lt;ProfileDetails /&amp;gt; and &amp;lt;ProfileTimeline /&amp;gt; in &amp;lt;Suspense /&amp;gt; tags, and we provide it with a prop of "fallback". The fallback is simply what is loaded when the data isn't completely fetched yet and it can be an HTML element or another React component. The &amp;lt;Suspense /&amp;gt; magic behind the scenes starts building the &amp;lt;ProfileDetails /&amp;gt; and &amp;lt;ProfileTimeline /&amp;gt; components in memory and sees the &amp;lt;ProfileDetails /&amp;gt; component isn't complete yet, because the resource.user.read() function returned only a promise, so it displays the fallback element and it moves on and checks the resource.posts.read() return in the &amp;lt;ProfileTimeline /&amp;gt; component. This component isn't complete yet either, so it renders the fallback and moves back to the top of the list. Now the &amp;lt;ProfileDetails /&amp;gt; component &lt;em&gt;is&lt;/em&gt; complete so it renders it, and checks &amp;lt;ProfileTimeline /&amp;gt; again which is now complete too, so it renders it as well. So use is really simple. We have a resource object that contains all of our data, a &amp;lt;Suspense /&amp;gt; tag that tells React it will be rendering &lt;em&gt;concurrently&lt;/em&gt;, with a "fallback" function if the .read() function returns a promise instead of the response data. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Suspense and interruptible rendering are surprisingly easy to use and have a dramatic increase on load times, application speed, and user experience. Gone are the days of elements popping onto the screen unexpectedly and keyboard input being blocked by the render of elements. Gone are the days of keeping your users...... in &lt;em&gt;suspense&lt;/em&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  resources: &lt;a href="https://reactjs.org/docs/concurrent-mode-suspense.html"&gt;https://reactjs.org/docs/concurrent-mode-suspense.html&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>codesandbox</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>!Stacks &amp;&amp; Queues... Stacks || Queues!</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Fri, 01 Nov 2019 21:32:47 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/stacks-queues-stacks-queues-1ldp</link>
      <guid>https://forem.com/spencerlindemuth/stacks-queues-stacks-queues-1ldp</guid>
      <description>&lt;h1&gt;
  
  
  Stacks &lt;em&gt;and&lt;/em&gt; Queues
&lt;/h1&gt;

&lt;p&gt;  Stacks and Queues are sometimes verbally used interchangeably or together with an "and" and do somewhat of a similar things. They hold a series of values or data, in which you can add or remove a value and the order of each cannot be rearranged. They are actually very different structures however and have vastly different real world applications, so let's find out what they are!&lt;/p&gt;

&lt;h1&gt;
  
  
  Stacks
&lt;/h1&gt;

&lt;p&gt;  Stacks are a non-primitive data structure (or abstract data type) that have a few methods, .push() and .pop(), being the most used, but also have a .peek() to get the top element without removing it, .isFull() to check if it's full, and .isEmpty() to check if it's empty. Stacks work from the Last In First Out principle (LIFO), meaning the element that you .push() onto the stack is also the same element returned when you .pop() an item off. This can be seen in the diagram below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2c1k4vTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://techdifferences.com/wp-content/uploads/2017/07/Untitled-1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2c1k4vTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://techdifferences.com/wp-content/uploads/2017/07/Untitled-1.jpg" alt="stack diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This LIFO property is important for stacks and the largest difference between it and a queue which has a First In First Out property (FIFO). Imagine a stack like a pile of unorganized DVD's on the shelf when you are trying to watch a movie. To get to "Kindergarten Cop", which you haven't watched in years, you have to sift through all the other DVD's on top of it first. Another example would be, that you just bought and watched "Spider-man: Into the Spider-Verse" so you toss it on the top of the pile. Now tomorrow night when you want to watch it again, you don't have to sort through 150 scratched copies of 80's kung fu movies to get to it, you know it's right on top where you left it. Obviously this is a primitive example, so what are the real world applications when it comes to algorithms and programming?&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack Creation
&lt;/h2&gt;

&lt;p&gt;  First, to create a stack, we need a &lt;em&gt;list&lt;/em&gt; of organized data and we always need reference to the item at the top of the stack (or the &lt;em&gt;head&lt;/em&gt; if you will... bet you can guess where this is going). We can make a functional stack using a linked list! WOW! So meta... Using a linked list we can add elements to the head and remove them from the head at a constant time complexity (&lt;em&gt;O1&lt;/em&gt;) because we never need to iterate through the list, just update the pointer of the head. We can also add an instance variable for length so we never have to iterate for .isFull() or .isEmpty() either. &lt;/p&gt;

&lt;h2&gt;
  
  
  Stack algorithm
&lt;/h2&gt;

&lt;p&gt;  A very simple example of an algorithm where you would use a stack for efficiency is reversing a string. After all elements are added to the stack, you simply pop them off and they come out in reverse order (LIFO).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;reverseString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
    &lt;span class="c1"&gt;//initialize a new stack&lt;/span&gt;
    &lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;//iterate through the string adding each char to stack&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++){&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;charAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
    &lt;span class="o"&gt;};&lt;/span&gt;
    &lt;span class="c1"&gt;//initialize a new reversed string&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;reversedString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;//now push each char onto a new string&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;()){&lt;/span&gt;
        &lt;span class="n"&gt;reversedString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reversedString&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pop&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;};&lt;/span&gt;
    &lt;span class="c1"&gt;//return the reversed string&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;reversedString&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we don't have to create an Array, keep track of the end of it, or remember whether we are adding or grabbing characters from the right end of the array. &lt;/p&gt;

&lt;h1&gt;
  
  
  Queues
&lt;/h1&gt;

&lt;p&gt;  Queues are the same ordered list of elements that a stack contains but the elements get pulled off the opposite end of that they are added. To visualize, a line of cars entering a tunnel come out of the tunnel in the same order (barring we are actually in a fast and the furious film): &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KhzuGS3y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://techdifferences.com/wp-content/uploads/2017/07/queue.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KhzuGS3y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://techdifferences.com/wp-content/uploads/2017/07/queue.jpg" alt="queue diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Queues have two main functions as well but they are known as .enqueue() and .dequeue() instead of .push() and .pop() (because developers love making you type "q u e u e" to try and make you trip up) and also contain .peek() for seeing the element on the end of the queue, .isFull() and .isEmpty(). There are also different implementations of queues, including Priority Queue, Circular Queue, and Doubly Ended Queue. A priority queue is a queue where each element also has a "priority" value, and elements with a higher priority are served first. Circular Queue is where the tail or end of the Queue holds reference to the first element. Lastly a Doubly Ended Queue is a queue where elements can be both added and removed from either end of the queue. &lt;/p&gt;

&lt;h2&gt;
  
  
  Queue Creation
&lt;/h2&gt;

&lt;p&gt;   Queues are a &lt;em&gt;list&lt;/em&gt; of organized data where we need reference to the &lt;em&gt;head&lt;/em&gt; to add items to the queue and the &lt;em&gt;tail&lt;/em&gt; to remove items. Yup you guessed it, it &lt;em&gt;is&lt;/em&gt; a doubly linked list! This means adding and removing elements is constant (&lt;em&gt;O1&lt;/em&gt;) because to add we push at the head and add a pointer to the rest of the list and removing from the tail removes the pointer to and from the element behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Queue Algorithm
&lt;/h2&gt;

&lt;p&gt;  There are a lot of uses for queues in computing and telecom and we use them every day in person, at say the supermarket, where the first person in line to check out, gets checked out first. But where can we use them in computer science and improving algos? They are very handy at improving the complexity of Binary Search Tree operations and traversal, but we will talk more about that next week! A more simple problem to utilize a queue is a function takes requests from users and serves information back in the correct order using a standard queue. Say you have a game and want to ensure that a user presses the buttons in the correct order, the clicks or keypresses can be logged in a queue and analyzed with maintained order!&lt;/p&gt;

&lt;p&gt;Next week we will dive into the right time to use binary search trees!&lt;/p&gt;

&lt;h6&gt;
  
  
  references
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;a href="https://techdifferences.com/difference-between-stack-and-queue.html"&gt;https://techdifferences.com/difference-between-stack-and-queue.html&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>datastructures</category>
      <category>java</category>
      <category>data</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>When to actually use linked lists</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Thu, 24 Oct 2019 19:24:31 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/when-to-actually-use-linked-lists-dcf</link>
      <guid>https://forem.com/spencerlindemuth/when-to-actually-use-linked-lists-dcf</guid>
      <description>&lt;p&gt;  We've all learned in school or in our bootcamps about different complex data structures. Linked lists, hash maps, binary trees and search trees, stacks, queues, monotonic queues, etc... We've all also learned about how to write each one, how to traverse nodes, add nodes, and delete nodes. &lt;em&gt;But&lt;/em&gt; what good is knowing all this stuff if we don't actually know when to &lt;em&gt;use&lt;/em&gt; these data structures..&lt;/p&gt;

&lt;h3&gt;
  
  
  Linked Lists
&lt;/h3&gt;

&lt;p&gt;  As a brief recap, let's recall what linked lists are. Linked lists are a series of "nodes" containing a value as well as a pointer to the next node in the series. In a linked list you have access to the "head" of the list and all subsequent nodes are found by traversing through the list one by one. A doubly linked list has the same properties except a reference to the "tail" is kept as well and nodes also have a reference to the previous node, and the list can be traversed in reverse. Linked lists are usually compared to arrays as a similar data structure and although arrays are "primitive" data structures, they share similarities with linked lists. &lt;/p&gt;

&lt;h4&gt;
  
  
  Similarities
&lt;/h4&gt;

&lt;p&gt;  They both, for example, require traversal to access all elements in the structure and they both can be used to store linear data of similar types.&lt;/p&gt;

&lt;h4&gt;
  
  
  Differences
&lt;/h4&gt;

&lt;p&gt;  To really notice the differences you need to be programming in an older, compiled language such as C++, Java, or C# where arrays are of fixed length. &lt;br&gt;
&lt;/p&gt;
&lt;li&gt;This is because the memory for each array is allocated on compile, while linked lists get allocated on runtime. This is advantageous to link lists because they can be resized dynamically at runtime, while changing the size of an array involves creating a new array of longer length and using more memory, or you have to know the upper limit of the needed length beforehand, wasting memory space. This is less of an issue in JavaScript, Python, and Ruby where arrays can be dynamically resized using operations like .push() and .pop()&lt;/li&gt;


&lt;li&gt;The memory allocation however is more efficient with arrays than link lists because the data at each index is stored directly in the allocation for each index, whereas link lists have to store a value, as well as a pointer to the next (or previous and next in a doubly linked list) node.&lt;/li&gt;


&lt;li&gt;Arrays can also reference a particular element using an index, so to get the 5th element:

&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//initializes new array of strings with length 10&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;fifth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;//access the fifth element in the array (constant time) &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;and so on, while linked lists require access to the head, and then a loop to traverse the elements:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;LinkedList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;linkList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;LinkedList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
 &lt;span class="c1"&gt;//initializes a new linkList with type string. (no length specified)&lt;/span&gt;
 &lt;span class="n"&gt;linkList&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;search&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//then inside the linkList class:&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt; 
  &lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;next&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
      &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Here we are looking for the 4th element of linkList, so we have to iterate through the first three values to get the fourth. Since space time complexity is worst case scenario, the lookup of a value in a linked list is &lt;em&gt;O(n)&lt;/em&gt; because it is dependent on the length of the linked list as well as the index you are searching for. An array lookup on the other hand is a constant time-complexity ( &lt;em&gt;O(1)&lt;/em&gt; ) because it is a direct lookup to the memory location of an element at a specific index. &lt;/p&gt;


&lt;/li&gt;


&lt;li&gt;Linked lists (especially doubly linked lists) have a better space time complexity for adding and removing nodes at ends because inserting (or removing) the target element consists of simply changing the pointer(s) of the surrounding elements. To insert in the middle the complexity is still linear ( &lt;em&gt;O(n)&lt;/em&gt; ) in a singly linked list because you must traverse to the index and update the pointer. The advantage here over an array comes from it's space complexity where you must traverse to an index, insert the value, and then find something to do with the remaining elements to re-position them. This is done a few different ways but requires more memory regardless. &lt;/li&gt;
&lt;h4&gt;
  
  
  Use Cases
&lt;/h4&gt;

&lt;p&gt;  So looking at the key differences between arrays and linked lists we can see the advantages and disadvantages of each and start to draw conclusions about when to use each. Linked lists utilize their key characteristic, to keep things quick and ordered, to really shine. Real-world applications most commonly include use in &lt;em&gt;other&lt;/em&gt; complex data structures. Hash tables, graphs, stacks, queues, and dequeues all utilize linked lists internally. &lt;br&gt;
&lt;/p&gt;
&lt;li&gt;A linked list can be used as a stack by repeatedly adding and removing elements from the 'head' of the list.

&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// create stack linked list &lt;/span&gt;
  &lt;span class="nc"&gt;StackUsingLinkedlist&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StackUsingLinkedlist&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; 
  &lt;span class="c1"&gt;// insert Stack value at head of linked list&lt;/span&gt;
     &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
     &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
     &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
     &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task4&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;()){&lt;/span&gt;
    &lt;span class="c1"&gt;//execute the task at the top of the stack (head of linked list)&lt;/span&gt;
    &lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pop&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;





&lt;/li&gt;
&lt;li&gt;A doubly linked list can be used as a queue by adding to the 'head' of a linked list and removing from the 'tail'. 
&lt;/li&gt;
&lt;li&gt;Linked lists can also be the buckets on hash tables to prevent intersection. (If something is already at that hash location, add it to the end of the list). &lt;/li&gt;
&lt;li&gt;Other real world applications can include the back button on a browser, an undo button in photoshop, or the cycle of applications running on an operating system. 

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;There is a time and a place to use linked lists and most commonly it's when you want quickly add and remove elements from a container. Usually this occurs in stacks and queues with lower space time complexity over arrays or when you want to keep ordered data with more flexibility than arrays.&lt;/p&gt;

&lt;p&gt;Stay tuned next week for part 2 of practical applications: When to actually use stacks.&lt;/p&gt;

&lt;h6&gt;
  
  
  References:
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;a href="https://www.geeksforgeeks.org/linked-list-vs-array/"&gt;https://www.geeksforgeeks.org/linked-list-vs-array/&lt;/a&gt;
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;a href="https://www.quora.com/In-which-languages-are-arrays-automatically-resizable-and-in-which-are-they-a-fixed-length"&gt;https://www.quora.com/In-which-languages-are-arrays-automatically-resizable-and-in-which-are-they-a-fixed-length&lt;/a&gt;
&lt;/h6&gt;


&lt;/li&gt;

</description>
      <category>datastructures</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>java</category>
    </item>
    <item>
      <title>Make a better looking website the hard way</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Tue, 20 Aug 2019 22:31:19 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/make-a-better-looking-website-the-hard-way-5f20</link>
      <guid>https://forem.com/spencerlindemuth/make-a-better-looking-website-the-hard-way-5f20</guid>
      <description>&lt;p&gt;    In &lt;a href="https://dev.to/spencerlindemuth/make-a-better-looking-website-the-easy-way-28dp"&gt;part one&lt;/a&gt; we covered the fundamental concepts to making a better designed website and some tools to use to do it. Now that you know how to make consistent color schemes, and know that everything on the page craves uniformity, &lt;em&gt;how do we make it all uniform?&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Compartmentalization
&lt;/h4&gt;

&lt;p&gt;    This is more of a concept that a concrete idea and also applies to all of coding more than just web design, but the principle is important and I'll cover it to reiterate the importance. The easiest way to make every button on the page look the same is to &lt;em&gt;use&lt;/em&gt; the same button on every page. It can have a different action on every page, but using the same component in React, or the same CSS class in vanilla JS on every similar button on a site inherently makes it uniform because there is no room for variation in the same code. Since this is a CSS and design based series, I'll skip the React component approach and focus on CSS classes.&lt;br&gt;
   The general rule of thumb in CSS is that every element on the page has a unique ID tag, but classes are helpful to spread style along many different elements on a page. To give elements a class in HTML simply say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;Prev&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;Next&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To style these button in CSS use the "." identifier followed by the class name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.generic-button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fit-content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Which yield these generic buttons:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BamGFDVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/D39aOTz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BamGFDVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/D39aOTz.jpg" alt="buttons"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;   So now any button on our page can still be singled out with a unique ID to have special actions, but given this class will now, without any extra effort, be styled the same as &lt;em&gt;every&lt;/em&gt; button on the page upon its first render regardless of functionality. &lt;/p&gt;

&lt;p&gt;   But what happens when we want the submit button to have some different properties than the other two, while still maintaining the existing style? We could copy and paste the code into a different class, &lt;em&gt;or&lt;/em&gt; we can chain classes together with spaces... Let's see it in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;Prev&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"generic-button"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;Next&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All we did now is add a space in the class field, so now it's "generic-button submit". If we add another class style in the css:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.generic-button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fit-content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.submit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We get the results: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lqN3dh1Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/fn4Jfzm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lqN3dh1Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://imgur.com/fn4Jfzm.jpg" alt="buttons 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;    How did the button turn green &lt;em&gt;and&lt;/em&gt; maintain the border radius and font color?!?!&lt;/p&gt;

&lt;p&gt;   Well the answer is in the name of the language. It's a &lt;em&gt;Cascading&lt;/em&gt; Style Sheet (CSS). This means that we start at the top applying a rule and then we apply more rules and overwrite existing rules (also using specificity rules) as we read further through the file. So now we can add multiple classes to a single element, to set a base style, then sprinkle extra on top to add small unique touches to match functionality and improve flow.&lt;br&gt;
  The takeaway here is &lt;em&gt;write less lines of code&lt;/em&gt;, and keep things consistent by compartmentalizing classes in CSS to apply just as much style as necessary to keep it usable on as many elements as possible without ever rewriting the same code. &lt;/p&gt;
&lt;h4&gt;
  
  
  Dynamic spacing
&lt;/h4&gt;

&lt;p&gt;    This section is the bane of every web developers existence. How to keep a website looking consistent on every device in a world of thousands of screen resolutions. Before making any styling decisions establish what client you are dealing with, since it's a mobile world now. In javascript you can find client-type by using a function similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;getDeviceType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userAgent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/mobile/i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mobile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userAgent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/iPad|Android|Touch/i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Tablet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Desktop&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And using CSS you can use @media queries like screen width to determine the device being used &lt;a href="https://medium.com/@marukohao/responsive-web-design-229350f36844"&gt;(see more on mobile formatting here)&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*Mobile styles here for devices less than 600px wide*/&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that we have device type established we can start making layouts that scale correctly across all the devices on the web, but how?&lt;/p&gt;

&lt;p&gt;Using dynamic spacing! This means that setting the height of your menubar to 200px is a no go. Because 200px is a much different percentage of your MacBook pro display than it is an of a Nexus 4 phone. &lt;em&gt;But this is an easy fix, because CSS has a handy Percent% unit to fix this!&lt;/em&gt; CSS actually has &lt;em&gt;15&lt;/em&gt; different units used to size things. 6 absolute units (units that never change or scale regardless of device)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;Conversions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cm&lt;/td&gt;
&lt;td&gt;centimeters&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mm&lt;/td&gt;
&lt;td&gt;millimeters&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;in&lt;/td&gt;
&lt;td&gt;inches&lt;/td&gt;
&lt;td&gt;1 in = 96px = 2.54cm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;px&lt;/td&gt;
&lt;td&gt;pixels&lt;/td&gt;
&lt;td&gt;1px = 1/96th of an inch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pt&lt;/td&gt;
&lt;td&gt;points&lt;/td&gt;
&lt;td&gt;1pt = 1/72 of an inch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pc&lt;/td&gt;
&lt;td&gt;picas&lt;/td&gt;
&lt;td&gt;1pc = 12pt&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And 9 relative units &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;em&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relative to the font-size of the element (2em means 2 times the size of the current font)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ex&lt;/td&gt;
&lt;td&gt;Relative to the x-height of the current font (rarely used)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ch&lt;/td&gt;
&lt;td&gt;Relative to width of the "0" (zero)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rem&lt;/td&gt;
&lt;td&gt;Relative to font-size of the root element&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;vw&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relative to 1% of the width of the viewport*&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;vh&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relative to 1% of the height of the viewport*&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vmin&lt;/td&gt;
&lt;td&gt;Relative to 1% of viewport's* smaller dimension&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vmax&lt;/td&gt;
&lt;td&gt;Relative to 1% of viewport's* larger dimension&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relative to the parent element&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These units make the elements different sizes depending on the screen size (viewport) and propagates down to change the size of children who rely on parent size (percent%) so now on every device the elements will all fit perfectly and scale as you use your phone on change resolution on pc. &lt;/p&gt;

&lt;p&gt;(Quick aside about scaling. People with vision impairment rely on the zoom feature to better see your site and read its text so don't set things like font size to things like viewport height because they will always remain the same size regardless of zoom).&lt;/p&gt;

&lt;p&gt;    Now you have to tools to build sites that display evenly on different devices, while maintaining consistent styling and keeping functionality! All that's left for you to do is come up with a great idea and implement it! Easy!&lt;/p&gt;

&lt;p&gt;Resources: &lt;a href="https://www.w3schools.com/cssref/css_units.asp"&gt;w3 schools CSS units&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>design</category>
      <category>uxui</category>
      <category>react</category>
    </item>
    <item>
      <title>Make a better looking website the easy way</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Thu, 08 Aug 2019 20:56:26 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/make-a-better-looking-website-the-easy-way-28dp</link>
      <guid>https://forem.com/spencerlindemuth/make-a-better-looking-website-the-easy-way-28dp</guid>
      <description>&lt;h2&gt;
  
  
  Good looking websites
&lt;/h2&gt;

&lt;p&gt;    A "good looking website" can mean a lot of different things. Every site or company has its own design language. For example Google apps have &lt;em&gt;Material Design&lt;/em&gt;, Microsoft uses &lt;em&gt;Fluent Design&lt;/em&gt;, and Apple uses their own &lt;em&gt;Apple Design Guidlines&lt;/em&gt;. They also use their own fonts, logos, color schemes, and all look totally different and function differently as well. So which language provides the best looking website? Well that's different from person to person. While they all look substantially different they &lt;strong&gt;do&lt;/strong&gt; all have one thing in common. &lt;em&gt;A consistent user experience&lt;/em&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency
&lt;/h3&gt;

&lt;p&gt;    If you could have one take away from reading this blog, please let it be the importance of &lt;em&gt;consistent site design&lt;/em&gt;. If some of your buttons are rounded while some are square, your nav bar changes thickness on every page, page elements shift 2 pixels when you render a new div, or menu items are in a different order on half of the pages, you are delivering a subtly (or not so subtly) uncomfortable UX. Visitors might not be able to pick out flaws and tell you what they don't like, but they will have a &lt;em&gt;feeling&lt;/em&gt; on your page. A &lt;em&gt;feeling&lt;/em&gt; that they'd rather be on Instagram or Amazon. Even if you don't follow a particular design language created by an established company, a fully consistent interface will be &lt;em&gt;your&lt;/em&gt; design language. A design language to be proud of. So what makes a &lt;em&gt;consistent&lt;/em&gt; interface?&lt;/p&gt;

&lt;h4&gt;
  
  
    Color
&lt;/h4&gt;

&lt;p&gt;    Color is everywhere. Color is the thread making up everything we see. If we don't wear clothes that don't match, why would we make a website that doesn't? One of the first things I do before placing any elements on the page is pick a color scheme. Whether I have a color picked before-hand or I find one on the spot, having a base color makes envisioning your future product much more productive and helps get the creative juices flowing. If I have a base color in mind already I'll head to the &lt;a href="https://color.adobe.com/create/color-wheel/" rel="noopener noreferrer"&gt;Adobe Color Wheel&lt;/a&gt; website (also known as Kuler) and find the perfect color. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F1Kl4qNn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F1Kl4qNn.jpg" alt="Kuler"&gt;&lt;/a&gt;&lt;br&gt;
This involves dragging around little sliders until the shade is just right to find the hex color code to use in the css. The perfect color is subjective, but there's a few guidelines I like to adhere to. Your &lt;em&gt;base&lt;/em&gt; color is the focal point of your site. This is the color that every element on the page compliments. Usually this is the background color or a menu bar color. For a background color you want something soft and cool that text looks good on top of. Text is always easier to read black on light, and easy to read text is important to enhance your user experience. Menu bar colors should be bold and dark but of the same hue as the background color. Some examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fr5GGj6M.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2Fr5GGj6M.jpg" alt="facebook"&gt;&lt;/a&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FFgDEsFT.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FFgDEsFT.jpg" alt="amazon"&gt;&lt;/a&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F37JIUdF.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2F37JIUdF.jpg" alt="github"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are all nice, even pages to look at, with no eye jar when you open them. Notice where your eyes are drawn to on each page. First to the lighter sections with the easy to read dark text, then slowly scanning to the darker sections. If we take all the colors on the facebook page, and put the values in Kuler we get a wheel that looks like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FxYCQE4H.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FxYCQE4H.jpg" alt="facebook-colors"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look at the spread of the sliders. All of the main colors of the page are in a straight line from darker to lighter meaning they are all &lt;em&gt;shades&lt;/em&gt; of the same color, with the background being the light in the middle, the contrasting menu bar color being the dark blue on the left, and all the accents contrasting the background &lt;em&gt;complimentarily&lt;/em&gt;. It may not be an absolutely riveting design, but it's consistent and nice on the eyes, while only using 5 colors. Your page shouldn't be a rainbow of color to make it more exciting. The content on your page should be the exciting part because that's why the user is there! A great resource I use for picking colors schemes is &lt;a href="https://coolors.co" rel="noopener noreferrer"&gt;coolors.co&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/RMwTx1CUkbY22vKluD/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/RMwTx1CUkbY22vKluD/giphy.gif" alt="coolors.co"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
    Layouts - The bigger picture
&lt;/h4&gt;

&lt;p&gt;  This section is about the general layout and &lt;em&gt;flow&lt;/em&gt; of the site. There are a lot of subtleties in the bigger picture, and some that Ad companies would pay large amounts of money to understand better, but they are left up to you when designing your site. If you refer back to the pictures of Facebook, Amazon, and Github from earlier, we covered where your eyes are naturally drawn to, but skipped over &lt;em&gt;why&lt;/em&gt; our eyes are drawn there, or more specifically &lt;em&gt;why&lt;/em&gt; those elements were placed there, containing the information that they contain. Was it an accident? Pure happenstance? Of course not! As developers nothing happens on accident! Those elements were placed there, using those specific colors to establish the &lt;em&gt;flow&lt;/em&gt; of the webpage. On Amazon, your eyes are immediately drawn to the &lt;em&gt;deals&lt;/em&gt;, and Github pulls you right to the sign-up form. There is no guessing what's going on when you get to the page. No scanning looking for a sign-up button and no wondering how to find products on Amazon. These things are designed to take the guess work out for you, putting you exactly where they want you to be on the page. Amazon may have an entire design and psychology team deciding how to increase sales off the home page alone, but the concept still remains the same. Use thoughtful layouts to gently guide your users along to the information you want to show them, and they came to see. &lt;/p&gt;

&lt;h4&gt;
  
  
    Styling - Sweat the small stuff
&lt;/h4&gt;

&lt;p&gt;  Styling in this regard is using shapes, colors, and sizes to create your own design language. These are the small pieces that bring the site together and give it personality, and theme making it a &lt;em&gt;product&lt;/em&gt; you can sell people on. Making all these 1's and 0's into something tangible people want to &lt;em&gt;feel&lt;/em&gt;. This is the section that really brings &lt;em&gt;consistency&lt;/em&gt; together. The styling we are talking about here is &lt;strong&gt;making everything on the page look the same on every page!&lt;/strong&gt;&lt;br&gt;
Every feature should be styled the same. Every item show page should have the same attributes displayed in the same manner! Every logo should bring you back the home page! Users love predictability and are frustrated by changes to convention. Underlined text is traditionally clickable. If you underline a username at the top of an Instagram profile, people click on it, and it does nothing, you're going to have a lot of frustrated Instagrammers. This is literal predicability. Predicting things by the convention for which they were created. Just as underlined text represents a link, a submit button is clearly used to send your information to a server, and the back button brings the user back to the previous page. If the back button always brings you to the home page... &lt;em&gt;frustrating&lt;/em&gt;. But these are easy rules to adhere to because we use them all the time and the browser actually handles most of them for us. &lt;em&gt;Implied predictability&lt;/em&gt; is where we come in. This is creating clickable images to make them larger, logos that redirect to the home page, and clicking a username to see the user profile. There is no text anywhere stating these rules exist, but they tie in directly with your layout to enhance the flow of your website. The best way to build this is simply by using your site, and noticing the shortcuts you want to take. When you build the shortcut however really stop and think if this is a &lt;em&gt;conventional&lt;/em&gt; action that a user would be aware to try. If not, you may want to lend a little guidance, and maybe set the color of your text to a different font color to represent a link.&lt;/p&gt;

&lt;p&gt;Clean and clear websites benefits everyone. Your users will thank you, job recruiters will be impressed, and even your grandma can check out your site out if you follow these guidelines. Now that you have a better conceptual understanding of design, tune in next week as I dive into the CSS to help make your sites more &lt;em&gt;consistent&lt;/em&gt;.&lt;/p&gt;

</description>
      <category>design</category>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hacking 101</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Wed, 24 Jul 2019 01:02:33 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/hacking-101-122c</link>
      <guid>https://forem.com/spencerlindemuth/hacking-101-122c</guid>
      <description>&lt;h1&gt;
  
  
  What does it actually mean to be a hacker?
&lt;/h1&gt;

&lt;h4&gt;
  
  
  Well here's a clip of a dark web hacker in action:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/bv4U1HR7W2XQc/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/bv4U1HR7W2XQc/giphy.gif" alt="Hacker"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hacking is clearly the precise combination of finding the right ski-mask, and clever use of your banana hand. The people behind the Equifax data breach in 2017 penetrated the firewall by using a technique called multi-port exploitation where they cleverly used a whole &lt;em&gt;buschel&lt;/em&gt; of bananas to target numerous ports at once. &lt;/p&gt;

&lt;p&gt;All jokes aside, the Equifax breach, which leaked the names, social security numbers, addresses, birth dates, and driver's license numbers of over &lt;em&gt;145 million&lt;/em&gt; Americans alone, was carried out by exploiting a flaw in &lt;a href="https://en.wikipedia.org/wiki/Apache_Struts_2" rel="noopener noreferrer"&gt;Apache Struts&lt;/a&gt;, bad encryption techniques by Equifax, and insufficient breach detection mechanisms. So is this what &lt;strong&gt;hacking&lt;/strong&gt; is? Finding &lt;strong&gt;flaws&lt;/strong&gt; in &lt;strong&gt;systems&lt;/strong&gt;, and &lt;strong&gt;exploiting&lt;/strong&gt; them using &lt;strong&gt;advanced&lt;/strong&gt; programming techniques? It certainly can be! While those are a lot of buzz words we hear on tv about hacking, it can also be a plethora of other things! It really boils down to the age old question... Is posting to your friends facebook feed while they use the bathroom hacking?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fimages.junkee.com%2Fwp-content%2Fuploads%2F2014%2F07%2Fhack.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fimages.junkee.com%2Fwp-content%2Fuploads%2F2014%2F07%2Fhack.jpg" alt="Hacked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hacking is defined as: "The gaining of unauthorized access to data in a system or computer".&lt;/p&gt;

&lt;p&gt;By definition this means that posting on your friend's account &lt;em&gt;is&lt;/em&gt; hacking! Wow! That means we are all hackers! So with this newfound knowledge about ourselves, it should be &lt;em&gt;pretty easy&lt;/em&gt; to steal some data from one of the worlds largest credit reporting agencies! We just have to wait for the system administrator to get up to use the bathroom! While this may sound facetious and far-fetched, it brings us to most unknown &lt;strong&gt;hacking&lt;/strong&gt; technique:  &lt;/p&gt;

&lt;h2&gt;
  
  
  Social Engineering
&lt;/h2&gt;

&lt;p&gt;Social engineering is: The use of deception to manipulate individuals into divulging confidential or personal information that may be used for fraudulent purposes. That sounds really vague, so let's break it down into a couple examples.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phishing:
&lt;/h4&gt;

&lt;p&gt;Phishing is the use of deceptive websites and emails to coerce personal information out of people to gain &lt;em&gt;unauthorized access&lt;/em&gt; to their accounts. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FaxJNvDp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FaxJNvDp.jpg" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we dig a little deeper into this email we gain some insight on just what phishing is. First we notice that the address we received this email from is &lt;em&gt;close&lt;/em&gt; to wellsfargo.com but snuck an extra 's' in there to try and get the recipients to glaze over it without a second glance. Next we have an embedded hyperlink with the &lt;em&gt;text&lt;/em&gt;: "wellsfargo.com/account", but if you hover over the link, you see that it actually links to "&lt;a href="http://www.some-sketchy-site-that-looks-like-wells-fargo.com" rel="noopener noreferrer"&gt;http://www.some-sketchy-site-that-looks-like-wells-fargo.com&lt;/a&gt;". A good phisher will send you to a site that looks exactly like the target sites login page, then after you type in your credentials in an input field, log them in plain text and tell the user there was an error logging in, to get &lt;em&gt;even more&lt;/em&gt; password variations out of the user, or redirect to actual target site, and high five themselves for successfully stealing information. Next we see a phone number for a customer service line. Well if we are being &lt;em&gt;smart about our security&lt;/em&gt; we will call the customer service line just to make sure this email is legit! So we pick up our landline and dial the number here on the screen, and get a very nice voice on the other end of the line, who is almost &lt;em&gt;too&lt;/em&gt; eager to have us verify some account information, before telling us the link is indeed legit! Now you feel safer! Now you've given enough information to the &lt;strong&gt;hacker&lt;/strong&gt; to gain access to your bank... And probably all your social media accounts... And your email... &lt;em&gt;And your work email...&lt;/em&gt; And your work computer... And now this is a full blown corporate attack.&lt;/p&gt;

&lt;h4&gt;
  
  
  Front-door social engineering:
&lt;/h4&gt;

&lt;p&gt;Front-door social engineering is spoofing RFID tags, following people through doors, and onto elevators or pretending to be someone else to gain access to a system illegitimately. There's a famous saying, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"If you have a clipboard and a safety vest, you can walk in anywhere"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same thing goes for I.T. people, and system administrators, and janitors, and anyone that works in a corporate office really. Someone wearing a white button up and a tie, could walk into a corporate office and say, "Did someone on this floor open an I.T. ticket?" Someone raises their hand, then the imposter comments, "This might take a few minutes if you want to go grab a coffee." Now this imposter is working unsupervised on a workstation copying user-data and emails to a flash drive. This sounds far fetched but it's a surprisingly common methods of "hacking". EY’s Global Information Security Survey 2017 found 74% of cyber attack sources are careless or unaware employees. &lt;a href="https://www.ey.com/Publication/vwLUAssets/GISS_report_2017/$FILE/REPORT%20-%20EY%20GISS%20Survey%202017-18.pdf" rel="noopener noreferrer"&gt;[1]&lt;/a&gt; This is an exploit of a system, but not one that reads 1's and 0's and communicates over ethernet. This is the exploitation of people and their central nervous system. People are desperate to please, help, and avoid consequences, and &lt;em&gt;hackers&lt;/em&gt; exploit this daily, because it's much easier than filtering through millions of lines of code on the internet to find a hole. &lt;/p&gt;

&lt;h2&gt;
  
  
  Cyber attacks
&lt;/h2&gt;

&lt;p&gt;Don't fear! This isn't one of those articles where I lure you in with a topic like hacking and then tell you about how it isn't what you think it is, thus leaving you high and dry. There is still a large amount of cyber attacks carried out on a daily basis. This is &lt;em&gt;hacking&lt;/em&gt; in a more traditional sense. This is the person in an abandoned warehouse surrounded by servers with 9 monitors in a grid suspended in the air, typing in a bash terminal that you see in the movies. Hacking in this sense, when broken down into smaller bits, is pretty simple and straightforward, although the techniques are not. To put it in layman's terms, hacking in this sense is finding an error in some code, and using it to gain unauthorized access to data or execute code on a remote machine. This is also a vague description, so let's break it down. &lt;/p&gt;

&lt;h4&gt;
  
  
  Remote Code Execution
&lt;/h4&gt;

&lt;p&gt;Remote code execution is every hackers dream. A hacker finds a way to send code to a machine, which runs the code, returning information, or opening up doors for bigger exploitations. A good example is the 2015 Android &lt;a href="https://en.wikipedia.org/wiki/Stagefright_(bug)" rel="noopener noreferrer"&gt;Stagefright&lt;/a&gt; media server exploit, or the 2014 &lt;a href="https://en.wikipedia.org/wiki/Shellshock_(software_bug)" rel="noopener noreferrer"&gt;Shellshock&lt;/a&gt; hack which is described as "causing Bash to unintentionally execute commands when the commands are concatenated to the end of function definitions stored in the values of environment variables." The technical explanation is when Bash opens a new instance, it reads a list of predefined functions in a table referred to as environment variables, and executes them without verifying they were created legitimately. This was exploited in many different vectors, such as open SSH and via DHCP requests, where a hacker could append specialized privilege escalation functions onto a request to the server that would open bash to execute the initial command, not verify the appended code, and run all the commands haphazardly. &lt;/p&gt;

&lt;h4&gt;
  
  
  Code Injection
&lt;/h4&gt;

&lt;p&gt;Code injection is the exploitation of a computer bug that is caused by processing invalid data and is part remote code execution and part system manipulation. This is the categories that script kiddies fall into and lands high on the list of most common attacks. Code injection canvases SQL injection, scripting, and packet spoofing. This is the kind of hacking that takes advantage of poorly written code, and lack of input validation. An example is the 2012 &lt;a href="https://en.wikipedia.org/wiki/Heartbleed" rel="noopener noreferrer"&gt;Heartbleed&lt;/a&gt; attack, that was eventually patched with &lt;em&gt;just one line of code&lt;/em&gt;! The Heartbleed attack was an exploit carried out against the Open SSL protocol being used to encrypt web traffic across the world. To verify the SSL connection was still open, the web browser would send a "heartbeat" packet to the browser, which would then respond with the size and message of the original packet, but the server wouldn't verify wether the packet it was sending back was the same size as the original, instead rendering memory overflow data. A simplified explanation: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F1%2F11%2FSimplified_Heartbleed_explanation.svg%2F480px-Simplified_Heartbleed_explanation.svg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F1%2F11%2FSimplified_Heartbleed_explanation.svg%2F480px-Simplified_Heartbleed_explanation.svg.png" alt="heartbleed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This exploit was fixed by this single line of code (or 56 characters for the curious):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;s3&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;rrec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That line isn't hard for even a beginner to read and understand, yet the effect radius of the exploit will forever be unknown. &lt;/p&gt;

&lt;p&gt;This brings us to Spencer's top tips for avoiding getting hacked or fired for being "careless and unaware":&lt;/p&gt;

&lt;h3&gt;
  
  
  1:
&lt;/h3&gt;

&lt;p&gt;Always lock your computers when you walk away from them! This seems obvious, but is more common than it should be! It's simple. &lt;/p&gt;

&lt;h6&gt;
  
  
  (⊞ Win + L) on PC, or (⌘ Command + ^ Control + Q) on mac.
&lt;/h6&gt;

&lt;p&gt;Don't get data jacked while you're getting caffeine jacked!&lt;/p&gt;

&lt;h3&gt;
  
  
  2:
&lt;/h3&gt;

&lt;p&gt;This may be a hard realty to take in.. But &lt;strong&gt;NO&lt;/strong&gt;... That Nigerian Prince does &lt;em&gt;NOT&lt;/em&gt; want to share his fortune with you. Things in life that sound too good to be true almost always are. Especially when they are communicated over email! No one will send you an email telling you how much money you've just won, or about an all expenses paid cruise for 2 that you got so lucky to be selected for! Look at Publishing Clearing House! They at least have the decency to show up to your front door with a giant check! Banks and other institutions &lt;strong&gt;DO NOT&lt;/strong&gt; communicate private account information over email either. They may send you an information update verification to alert you if someone is tampering with your account, but they will not ask for any change to your personal information, or account verification over email to avoid this exact scenario. When in doubt, call your bank &lt;em&gt;from the number on google&lt;/em&gt;, or in the &lt;em&gt;yellow pages&lt;/em&gt; if you are still on AOL.&lt;/p&gt;

&lt;h3&gt;
  
  
  3:
&lt;/h3&gt;

&lt;p&gt;Use a password manager! There are tons available for tons of different price points. (Again here, you get what you pay for. You might not think it's important, but would you buy your car from Wal-Mart or your prescription meds 7-11 brand? Don't be cheap with your security!)&lt;br&gt;
Google has a password manager built into their programs now, iCloud has Keychain, and well-known third managers include &lt;a href="https://keepersecurity.com/" rel="noopener noreferrer"&gt;Keeper&lt;/a&gt;, &lt;a href="https://www.lastpass.com/hp" rel="noopener noreferrer"&gt;LastPass&lt;/a&gt;, and &lt;a href="https://www.dashlane.com/" rel="noopener noreferrer"&gt;DashLane&lt;/a&gt;. They can help you generate long, unique passwords for every account, while never forgetting or typing one again thanks to autofill, and also protecting you from bruteforce attacks, or plain and simple weak password techniques like hunter12  (although all I see is ********). Even a super-computer will have a hard time guessing: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LdjgfdksjhgJDLRKJZSKLFJKL:hjt4io4wr8iro1euwrewpt8o43tuO*U$#*OU$O#I$J#_E)(R#$%*UEOIJDKLGSJDKFAJSDGFKJHFGUYT*U(RU#)$IU#(ru30tujsdklgjdkgjfskgjeoir#UR5q9oRU&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(I would have guessed Passw0rd first, but that string would have been my second guess)&lt;/p&gt;

&lt;h3&gt;
  
  
  3:
&lt;/h3&gt;

&lt;p&gt;Number three sucks. It's a tip that isn't really a tip, but maybe something to turn some gears in your mind to help deal with the inevitable reality. Sometimes you just can't avoid attacks. The identities compromised in the Equifax breach were unavoidable by the people actually effected. Equifax was collecting your information with the "consent" you gave by being born, or signing up for that low limit/high interest credit card at 18 so you could get 5% off at Macy's and buy cigarettes without your parents finding out. The tip here is &lt;strong&gt;BE READY&lt;/strong&gt; when your information &lt;em&gt;is&lt;/em&gt; leaked. Put a credit freeze on your account to prevent criminals from opening lines of credit under your name. Change your passwords. Enable 2 step verification for all of your accounts. Even accounts like your Snapchat, Instagram, and iCloud are still tied to other accounts, can provide verification for important accounts, or leak things to public you didn't want getting out. &lt;/p&gt;

&lt;p&gt;It's a scary, hacked-together world out there... Don't get caught with your naughty pics on a Reddit thread, or the FBI going through your work computer at the Department of Labor because your computer gave hackers access to sensitive Department of energy nuclear data. &lt;/p&gt;

</description>
      <category>hacking</category>
      <category>security</category>
    </item>
    <item>
      <title>Don't be me. Be a better pair-programming partner.</title>
      <dc:creator>SpencerLindemuth</dc:creator>
      <pubDate>Mon, 01 Jul 2019 22:13:35 +0000</pubDate>
      <link>https://forem.com/spencerlindemuth/don-t-be-me-be-a-better-pair-programming-partner-2b90</link>
      <guid>https://forem.com/spencerlindemuth/don-t-be-me-be-a-better-pair-programming-partner-2b90</guid>
      <description>&lt;p&gt;Recently we were assigned our requirements for our first free-form pair programming project at school. Harkening back to elementary school, the mystery of who you'll be paired with burning inside you. &lt;em&gt;Hoping...&lt;/em&gt; Or very much hoping &lt;em&gt;not&lt;/em&gt; to be paired with the people around you. However unlike elementary school, you hardly know these people. You've only been here 2 weeks, and everyone is overwhelmed with the work, and it's still early and the skill level remains at a huge discrepancy. You start thinking, &lt;em&gt;"I've been programming since freshman year in twenty ten, and have written more basic CLI apps than I can count, this is going to be a cake walk"&lt;/em&gt; but you don't know who around you has the same level of experience, and I didn't know it at the time but this way of thinking is the first step to becoming a bad pair programming partner. Tip number 1 for better pair programming is to tie up to a hitching post and take a break from the ride on your high horse. &lt;/p&gt;

&lt;p&gt;Since this project seemed so &lt;em&gt;nominal&lt;/em&gt; from the start, and &lt;em&gt;"I'm such a good programmer"&lt;/em&gt;, I spent a lot of time thinking about what I wanted to accomplish in this dedicated week. I found a great API for real time stock market info that lined up perfectly with an app idea that I had been tossing around building in my free time. With this new-found API and energy I present the idea to my partner and they were on board! Perfect! Now the ideas really start swirling around in my brain. &lt;em&gt;"What should I start on first? What gem am I going to use to put this data in a table? What's the lifecycle of real-time stock market data in our program? What do I actually need out of this .JSON?"...&lt;/em&gt; and never thought for a second what kind of thoughts might be running through my partners head. &lt;em&gt;"What the hell is a stock? An ETF? Why would someone want to see a companies 5 year stock history?"&lt;/em&gt;. At this point I had already written 300 lines of imaginary code in my head without a second to think about what was happening in my partners. Tip number 2 for better pair programming is to realize that you have to share a vision to equally contribute to a project. No one is going to be enthusiastic to help with something they are constantly googling about along the way.&lt;/p&gt;

&lt;p&gt;After two days of furious coding it's time to start hooking their UI to my back-end hooks, and (to &lt;em&gt;no-one's&lt;/em&gt;) surprise! Their vision of what my pet project should look like is different than mine! (&lt;em&gt;gasp&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Don't worry, I can fix this! I'll stay late today and make some quote, unquote *subtle* changes."&lt;/em&gt; There's that pesky "bad partner" voice again. Tip number 3 to better pairing is acceptance. Riding right off the back of tip number 2, tip number 3 means you have to let it go. If you make the program look exactly how you want, do exactly what you want, and the whole concept is about exactly what you want, why do you even have a partner? Acceptance of your partners vision is only half the battle too. Everyone is different. Everyone's eyes are different, their fingerprints are different, their handwriting is different, and their coding style is different. To truly accept your pair partner (and life partner, but that's a different blog) is to appreciate the way they do things differently. Maybe they like if/else statements better than case statements, or they prefer .atom to VSCode like you, but maybe they've used a gem that makes that table you've been trying to format for 16 hours.&lt;/p&gt;

&lt;p&gt;Pair programming is meant to create to a result that is the expression of both parties involved, which inherently make is better suited to tackle a task because it has 100% more brain power behind it. Every change to the code might bring your vision up 1% or 2% but the capability of the program drops 5% or 10%. Tip number 4 is, don't be afraid to express yourself. You are great! Give the world what you have to offer! But so is your partner! Don't block the shine of the person shining next to you, because you know it wouldn't feel great if they were the one holding the umbrella. &lt;/p&gt;

&lt;p&gt;Let's review:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Be humble - Smart today doesn't mean smart tomorrow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Share a vision - Working towards a common goal is better than building someone else's. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Acceptance - You are as different to them, as they are to you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collaborate - If you had every great idea, why are you sitting here reading my blog?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The most important tip is &lt;strong&gt;learn something!&lt;/strong&gt; If you don't come out of a pair project feeling like you've learned something about coding &lt;em&gt;and&lt;/em&gt; yourself, you are living all wrong. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“If you’re the smartest person in the room, you’re in the wrong room.”&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>groups</category>
      <category>ruby</category>
      <category>flatironschool</category>
    </item>
  </channel>
</rss>
