<?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>DEV Community: Joshua Nelson ✨</title>
    <description>The latest articles on DEV Community by Joshua Nelson ✨ (@joshua).</description>
    <link>https://dev.to/joshua</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%2F8979%2F53a9e990-02aa-49dd-a47f-c7868fb0c4f5.png</url>
      <title>DEV Community: Joshua Nelson ✨</title>
      <link>https://dev.to/joshua</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joshua"/>
    <language>en</language>
    <item>
      <title>What were your "gotchas" when first learning React?</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Sun, 25 Nov 2018 07:00:30 +0000</pubDate>
      <link>https://dev.to/joshua/what-were-your-gotchas-when-first-learning-react-3mbk</link>
      <guid>https://dev.to/joshua/what-were-your-gotchas-when-first-learning-react-3mbk</guid>
      <description>&lt;p&gt;I've found there are some common stumbling blocks that people have when they're learning React, and sometimes there's an "Aha!" moment when they understand.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The difference between ES2015, React, JSX&lt;/li&gt;
&lt;li&gt;Complex usage of libraries like underscore or lodash in example code&lt;/li&gt;
&lt;li&gt;Understanding the overall "data flow" of React (And, the "Flux" architecture as a concept)&lt;/li&gt;
&lt;li&gt;Shared (but different!) concepts in other frameworks like Angular, Vue or even jQuery&lt;/li&gt;
&lt;li&gt;The asynchronous nature of some operations (like &lt;code&gt;setState&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Was there anything particularly tricky to get a handle on when you were learning React? What was your "Aha!" moment?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Idealism and Pragmatism</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 21 Nov 2018 07:18:04 +0000</pubDate>
      <link>https://dev.to/joshua/idealism-and-pragmatism-ain</link>
      <guid>https://dev.to/joshua/idealism-and-pragmatism-ain</guid>
      <description>&lt;p&gt;The fender on the Apollo 17 rover &lt;a href="https://airandspace.si.edu/stories/editorial/duct-tape-auto-repair-moon" rel="noopener noreferrer"&gt;fell off&lt;/a&gt;. This was a big problem – dust on the moon is very damaging to delicate instruments and suits.&lt;/p&gt;

&lt;p&gt;Luckily, there was a solution – literal duct tape. NASA advised the astronauts to put together some maps in the shape of a fender, and attach it to the rover with duct tape. This fixed their problem!&lt;/p&gt;

&lt;p&gt;Of course, this solution is not ideal – the original fender would have worked much better than this. However, with the resources available, this was a good decision – the makeshift fender worked.&lt;/p&gt;

&lt;p&gt;Similar questions can come up when making software:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey, is it ok if I just skip writing tests for this one?"&lt;/p&gt;

&lt;p&gt;"This is a bit of a hack, do you think it's ok?"&lt;/p&gt;

&lt;p&gt;"This isn't the way everything else is done, but it's easier. I think it's ok?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are common questions, questions that I have asked many times, and have been asked many times.&lt;/p&gt;

&lt;p&gt;How can you tell when a hack is too much of a hack? How do you know if you're being principled, or pedantic?&lt;/p&gt;

&lt;p&gt;Decisions like this fall on a spectrum. I think of this spectrum as the "Idealism and pragmatism" spectrum.&lt;/p&gt;

&lt;h1&gt;
  
  
  Pragmatism
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flfqt4h4613b05o4au49w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flfqt4h4613b05o4au49w.png" alt="Duct tape on a bike wheel" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pragmatism is "dealing with things sensibly and realistically in a way that is based on practical rather than theoretical considerations."&lt;/p&gt;

&lt;p&gt;In the context of software, this surfaces as a way of thinking about utility. A developer who concentrates more on outcomes (delivery, shipping, releases, or features) more than how those outcomes are achieved, is a pragmatic developer.&lt;/p&gt;

&lt;p&gt;In practice, this can often mean a willingness to do "hacks". If there is a non-ideal path to a good outcome, taking that path might be pragmatic.&lt;/p&gt;

&lt;p&gt;As an example, in the browser, maybe you need to override a &lt;code&gt;window&lt;/code&gt; method to fix an urgent bug. Or maybe you need to disable a test to make builds pass. Both of these things are not ideal, but they arrive at a good outcome.&lt;/p&gt;

&lt;h1&gt;
  
  
  Idealism
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frds9ce7001usyhyybxcy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frds9ce7001usyhyybxcy.jpg" alt="Gavel" width="726" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the other end of the spectrum is idealism. Idealism is &lt;br&gt;
the cherishing or pursuit of high or noble principles, purposes and goals"&lt;/p&gt;

&lt;p&gt;In software, idealism surfaces when we have a strong principle that we do not violate. A developer who focuses on what is "right", or "the best way to do things" may be idealistic in their attitude.&lt;/p&gt;

&lt;p&gt;Idealism in software development practices can come down to blocking things, or saying "no" to things being done incorrectly. It might be deciding to not do a hack, or by spending a little bit more effort to do something the way that it "should be done".&lt;/p&gt;

&lt;p&gt;Apart from just saying no to wrong things, idealistic practices might mean writing down principles, like "Document every new feature", or it might mean creating linting rules that force people to write code in a consistent way. The exact principles will depend on the project, but idealism is always about aiming for some high standard, even if it's hard to get there.&lt;/p&gt;

&lt;p&gt;These idealistic approaches trade off some short term speed for a long term benefit, like general code quality and consistency, test coverage, or complete documentation of features.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to know when to be which
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv94o2zide57qy7yx85a9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv94o2zide57qy7yx85a9.jpg" alt="Checklist" width="670" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Often decisions need to be made, where the answer falls into one of these two categories. Should you be pragmatic, or idealistic?&lt;/p&gt;

&lt;h2&gt;
  
  
  Actually have principles
&lt;/h2&gt;

&lt;p&gt;You can't be idealistic without having some principles written down, but you &lt;em&gt;also&lt;/em&gt; cannot be properly pragmatic without knowing your principles. What is it that is valuable to your project? Having these principles clearly written down and being shared knowledge on your team will help you assess how badly you are violating one of these principles, if you need to.&lt;/p&gt;

&lt;p&gt;Maybe you have a principle of "The user experience comes first", and you need to make a choice – delay delivery for one week, or deliver a somewhat buggy user experience. Having that principle written helps you acknowledge what is gained and lost on each side, and make the best call in that situation, acknowledging the costs and benefits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know the pressures
&lt;/h2&gt;

&lt;p&gt;Pressure is normal enough when developing software – there are deadlines, roadmaps, and releases. Often, a more pragmatic choice is appealing when one of these pressures are present.&lt;/p&gt;

&lt;p&gt;Try and break down exactly what the pressure is. If there  a large impact for a certain outcome (other teams / users are depending on a certain deliverable), that is a large impact, but maybe the deadline was just a date selected as a likely shipping date, and the impact of delaying delivery is low.&lt;/p&gt;

&lt;h2&gt;
  
  
  Be aware of your own bias
&lt;/h2&gt;

&lt;p&gt;Knowing where you sit on the spectrum of idealistic to pragmatic is a good first step. Do you often find yourself being "lazy", or taking shortcuts? Or do you find yourself too often being "stubborn", and frequently saying no? If you aren't sure, you can ask people you work with, who may have a good idea of where your natural tendency lies.&lt;/p&gt;

&lt;p&gt;Personally, my tendency is to make pragmatic choices, and I need to put in conscious effort to ensure principles are created and adhered too. (Tools and rules help a lot in this regard, as they are rigid standards that I can't forget about).&lt;/p&gt;

&lt;p&gt;If you know how you're naturally biased when making decisions, you can step back when you sense yourself making an overly pragmatic, or overly idealistic decision.&lt;/p&gt;

&lt;h1&gt;
  
  
  Examples
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx0u6fyks1p61n3n2d5f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx0u6fyks1p61n3n2d5f.png" alt="Bitbucket pull request screen" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The pull request
&lt;/h2&gt;

&lt;p&gt;You see something that is not ideal in a pull request. Maybe a test was forgotten, or some could should be refactored. Should you withhold approval?&lt;/p&gt;

&lt;p&gt;Things to keep in mind here are that you are setting a standard in your pull requests, and an idealistic approach here is valuable for future work (&lt;a href="https://hecate.co/blog/code-review-review-is-the-managers-job" rel="noopener noreferrer"&gt;the standard you walk past is the standard you accept&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;However, there might be pressures (see: &lt;em&gt;know the pressures&lt;/em&gt; above) that necessitate skipping some of these things.&lt;/p&gt;

&lt;p&gt;A pragmatic compromise might be, "Ok, let's merge and release this, but follow up with the proper fixes".&lt;/p&gt;

&lt;p&gt;The important thing to monitor here is that those fixes actually occur.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hack
&lt;/h2&gt;

&lt;p&gt;There's a way to do something that is clearly not ideal – you're breaking an API, or you're doing something that is so obviously wrong, you're almost embarrassed. However, it gets the job done.&lt;/p&gt;

&lt;p&gt;Is this ok?&lt;/p&gt;

&lt;p&gt;You can examine your principles to see how much it violates them. Is it a worse UX, worse code quality, or a risky change? If it heavily violates your principles, best to not implement this hack.&lt;/p&gt;

&lt;p&gt;On the other side, there are times when hacks are useful. Maybe it speeds up other developers, in a way where their code dodes not need to rely on this hack. It may allow you to deliver a high impact release on time, that users or other developers are depending on.&lt;/p&gt;

&lt;p&gt;In your decision, you might include a plan to remove this hack in the future. In this plan, make sure you include not only &lt;strong&gt;when&lt;/strong&gt; you would fix this hack, but also &lt;strong&gt;why&lt;/strong&gt; you would fix it. &lt;strong&gt;Why&lt;/strong&gt; might be a ticket, or process that would ensure this gets done. Hacks often live a very long time, so you should be sure you're ok with it being around for a long time.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bad habit
&lt;/h2&gt;

&lt;p&gt;Outside pressure leads towards the pragmatic approach – outcomes are what's important, but the way those outcomes are achieved is the domain of the engineer. This means that, left unchecked, bad habits and practices can creep in.&lt;/p&gt;

&lt;p&gt;In this case, it's important to realise that this is happening (see: &lt;em&gt;Actually have principles&lt;/em&gt;), and combat it. This can be by explicitly calling out the principle, and through pull requests, encouraging your team to adhere to them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The precedent
&lt;/h2&gt;

&lt;p&gt;Sometimes, first code of a new type is being checked in. If you are doing something for the first time, be aware that you are setting a precedent for all similar, future work. Are you making the first GraphQL resolver, the first API model, or the first shared library? You are setting a precedent that many developers will follow! In this case, an idealistic approach is always preferable.&lt;/p&gt;

&lt;h1&gt;
  
  
  A false dichotomy?
&lt;/h1&gt;

&lt;p&gt;There is a spectrum of pragmatism and idealism, but these approaches are not diametrically opposed. Most of the time, we can have both an ideal outcome, and ideal path. Often the best way to deliver high utility, even in the short term, is by doing things in an ideal way. This is not always the case for some harder decisions though, and there are times when tradeoffs need to be made.&lt;/p&gt;

&lt;h1&gt;
  
  
  How about you?
&lt;/h1&gt;

&lt;p&gt;Do you fall more on the side of pragmatic, or idealistic? Do you have any tips on how to know where your decision should fall on this spectrum? I'd love to hear!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>career</category>
    </item>
    <item>
      <title>Protecting performance (Part 4)</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 14 Nov 2018 08:52:35 +0000</pubDate>
      <link>https://dev.to/joshua/protecting-performance-part-4-2acp</link>
      <guid>https://dev.to/joshua/protecting-performance-part-4-2acp</guid>
      <description>&lt;p&gt;Performance is important for your users, your business, and the world. We need to pick good metrics that reflect real user experiences – and there are many available to choose from.&lt;/p&gt;

&lt;p&gt;So now we've picked our meaningful metric, and a tool to measure it with.&lt;/p&gt;

&lt;p&gt;Now what?&lt;/p&gt;

&lt;p&gt;Maybe you're thinking that now we need to actually fix performance. This is undoubtedly true! We won't address that in this blog though – there is plenty of dedicated resources for telling you what to improve. A great starting resource is &lt;a href="https://developers.google.com/web/tools/lighthouse/" rel="noopener noreferrer"&gt;the audits panel&lt;/a&gt; in the Chrome devtools.&lt;/p&gt;

&lt;p&gt;A natural follow up question might be, how long will it take to fix those performance issues?&lt;/p&gt;

&lt;p&gt;This is &lt;em&gt;not&lt;/em&gt; the right question to be asking. We're in it for the long run – performance is a cultural change we need to make, not a one off effort that we can do once.&lt;/p&gt;

&lt;h1&gt;
  
  
  The planning phase
&lt;/h1&gt;

&lt;p&gt;Often, performance regressions happen when a feature request materialises in a ticket of some form – a feature that will degrade performance is requested, and it's too late to reverse course. At this point, it's already too late to change things – we need a way of influencing planning much earlier than this, and we need a structured way of making sure that this conversation about performance happens much earlier, during the planning phase.&lt;/p&gt;

&lt;h1&gt;
  
  
  Performance budgets
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x6bwuy4ocb1f6x9d0wp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2x6bwuy4ocb1f6x9d0wp.jpg" alt="Piggy bank" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://speedcurve.com/blog/performance-budgets-in-action/" rel="noopener noreferrer"&gt;Performance budgets&lt;/a&gt; are a great way of having this conversation in a structured way. The key steps are:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Choose the right metrics
&lt;/h2&gt;

&lt;p&gt;During the previous part, we talked about choosing the right metric – it's important to do this, so that we're focusing on a meaningful metric to improve.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Get everyone to agree on a limit
&lt;/h2&gt;

&lt;p&gt;Whoever makes planning decisions needs to agree that the metric (and the limit) that you have chosen for your budget is a good goal.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Bring it up during planning
&lt;/h2&gt;

&lt;p&gt;When engineering is involved in planning decisions, this goal needs to be kept in mind and talked about. When things being talked about would impact the performance budget, this needs to be brought up.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Figure out how to stay in budget
&lt;/h2&gt;

&lt;p&gt;During this planning phase, compromises can be sought. It might be that the feature itself can be changed to perform better, or it might be that some other performance improvement can be made to allow the budget to be kept overall.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing a limit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rrmnveqza9toojptkm7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rrmnveqza9toojptkm7.png" alt="A picture of a speed limit sign" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choosing an exact number for the limit is difficult, but here are some things to keep in mind:&lt;/p&gt;

&lt;p&gt;0.1 seconds - tasks are considered &lt;strong&gt;"instant"&lt;/strong&gt;, in that the user does not perceive a delay (eg. good goal for first input delay)&lt;br&gt;
1.0 seconds - &lt;strong&gt;flow of thought&lt;/strong&gt; is maintained throughout tasks (good goal for subsequent response times)&lt;br&gt;
10 seconds - &lt;strong&gt;task switch&lt;/strong&gt; occurs after this (definitely do not aim for longer than this on any metric)&lt;/p&gt;

&lt;p&gt;Other questions to ask might be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is the current state?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What are your competitors doing?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Either of these questions can produce a limit that should be fairly easy to agree to – if your competitor is beating you, a sensible goal might be to beat your competitor!&lt;/p&gt;

&lt;p&gt;&lt;a href="//performancebudget.io"&gt;performancebudget.io&lt;/a&gt; is a useful tool for choosing a bundle size metric based on page load time – but remember from the previous post, total bundle size may not correlate with the real user experience, if heaving caching or code splitting is happening. It's important to measure real user experiences too, and it's good to pick a budget based on a metric more like that.&lt;/p&gt;

&lt;h1&gt;
  
  
  Apdex
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00mtiqxwxdu6zw25pdgj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00mtiqxwxdu6zw25pdgj.jpg" alt="Apdex logo" width="200" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://apdex.org/overview.html" rel="noopener noreferrer"&gt;Apdex&lt;/a&gt; is another useful, "meta metric" that can be used to protect your performance and measure it at a high level.&lt;/p&gt;

&lt;p&gt;In the context of meaningful metrics however, there are two things that I would warn against in the usage of Apdex.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pick your t value carefully
&lt;/h2&gt;

&lt;p&gt;Apdex works by picking a "t" value, that represents what a user would consider a "tolerable" page load. Anything less than t is considered "satisfied", and anything less than &lt;code&gt;t*4&lt;/code&gt; is considered "tolerable"&lt;/p&gt;

&lt;p&gt;Picking a t value of anything much more than 1s can lead to misleading metrics. Consider a t value of &lt;code&gt;t=2&lt;/code&gt;. Page loads taking less than 8 seconds would be considered "tolerating", which is quite close to the limit before a user will tasks switch. It is likely that users who load pages in 8 seconds are dissatisfied in lots of use cases, and in this case, the Apdex metric does not reflect it well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pick your "load" metric carefully
&lt;/h2&gt;

&lt;p&gt;Apdex also requires a concept of "load time" itself. If you plug in an incorrect load time (maybe you would be using DOMContentLoaded instead of Time to interactive), your Apdex will be incorrect too.&lt;/p&gt;

&lt;p&gt;With this in mind, Apdex can be a useful tool for protecting performance. It can be used to normalise metrics into a simple number – this might be useful for aggregating Apdexes. However, without a shared t value, it is hard to compare different Apdex numbers, and hard to relate to their values. A budget or goal measured in seconds can be easier to relate to, and compare.&lt;/p&gt;




&lt;p&gt;Over the course of this blog series, we have learnt to measure &lt;em&gt;real&lt;/em&gt; user experiences, and pick the right metric to do that. Quickly check that the metric you have chosen is being triggered when in a meaningful state.&lt;/p&gt;

&lt;p&gt;Ultimately, for me, dollars aren't inspiring – but making the internet better for everyone, and enabling the open exchange of information for the world, is an inspiring goal. Meaningful metrics are an important step to this goal. Let's make the internet better for everyone! ✨&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>metrics</category>
    </item>
    <item>
      <title>Choosing a metric (Part 3)</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 14 Nov 2018 08:49:49 +0000</pubDate>
      <link>https://dev.to/joshua/choosing-a-metric-part-3-2c6c</link>
      <guid>https://dev.to/joshua/choosing-a-metric-part-3-2c6c</guid>
      <description>&lt;p&gt;Performance is a problem, and it’s not getting better. The median mobile page load time is 15.6 seconds – this is unacceptable.&lt;/p&gt;

&lt;p&gt;We need meaningful measurements that actually capture the real user experience of a page loading for a user.&lt;/p&gt;

&lt;p&gt;There are good and bad metrics out there for measuring this. A good metric is one that accurately reflects this user experience, and a bad one does not.&lt;/p&gt;

&lt;h1&gt;
  
  
  Bad metrics
&lt;/h1&gt;

&lt;p&gt;We can start with an example of a bad metric. Consider the page loading below:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qWKzErmqkZA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;A common way of measuring page loading speed is with the “load” event. However, the point at when the “load” event is fired, the page looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3wjtrsekuet9n4p7eo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0j3wjtrsekuet9n4p7eo.png" alt="site loaded screenshot" width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which is obviously not the point at which the page has loaded. Relying on this metric is &lt;strong&gt;dangerous&lt;/strong&gt;. You’ll focus on the wrong things, changing meaningless numbers. Meanwhile, you’ll neglect real issues – and your users will silently suffer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Good metrics
&lt;/h1&gt;

&lt;p&gt;So, that's a bad metric. But what makes a good metric?&lt;/p&gt;

&lt;h2&gt;
  
  
  Real user experiences
&lt;/h2&gt;

&lt;p&gt;We’ll say that a metric is good if it &lt;em&gt;reflects real user experiences&lt;/em&gt;. There are a number of attributes of metrics that would be demonstrate this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Measured on a real devices&lt;/li&gt;
&lt;li&gt;Measured on a real user’s network&lt;/li&gt;
&lt;li&gt;Passes a basic litmus test – when is this metric considering an experience good or bad, for my site? Is that in line with what &lt;strong&gt;you&lt;/strong&gt; think?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is a “continuous” function
&lt;/h2&gt;

&lt;p&gt;In the maths sense, a continuous function means something similar, but we’ll say that a metric is “continuous” if:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small improvement in the metric relates to a small improvement in the UX, and a large improvement in the metric relates to a large improvement in the UX.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An example of a metric that would not be “continuous” in this way might be page weight. If you are aggressively code splitting and caching, it might be that an improvement in the page weight relates to no improvement in the UX.&lt;/p&gt;

&lt;p&gt;Another metric would be bad if it gave a 100% score if a page loads in &amp;lt;1s and a 0% score if it loads in &amp;gt;=1s – improving load time from 3s to 2s would be a slightly better UX, but would not be rewarded by the metric.&lt;/p&gt;

&lt;p&gt;This is a useful property to have in a metric, as it means that the metric cannot be cheated. You can’t quickly render a loading spinner, and have the metric improve. I like to think of the developers who will be looking at this metric as a greedy optimisation algorithm – they will take the shortest path to improving this metric, and ideally, that path will also be the shortest path for improving the overall UX.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is “repeatable”
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4inexkrcpks77lz2v54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4inexkrcpks77lz2v54.png" alt="A photo of agent smith from the matrix" width="800" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Never send a human to do a machine’s job – Agent Smith&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some metrics you can get in an easy, automatic way, through monitoring. Some are easier to get with audit tools. However, you must spend the time to automate gathering this data. This is critical for the long time preservation of the metric – humans are less reliable than machines for regular tasks like this, and it’s very useful to have lots of data points. They will be your friend when debugging performance problems, and a long historical backlog of data is precious.&lt;/p&gt;

&lt;h1&gt;
  
  
  Metric choices
&lt;/h1&gt;

&lt;p&gt;Let’s have a look at some of the different choices we have, and assess them according to our criteria:&lt;/p&gt;

&lt;h2&gt;
  
  
  Page weight
&lt;/h2&gt;

&lt;p&gt;Page weight is a good metric in some ways: it is relatively easy to measure, and &lt;a href="https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4" rel="noopener noreferrer"&gt;javascript is expensive&lt;/a&gt;. There is always a user experience cost to delivering javascript, so measuring page weight is a good thing.&lt;/p&gt;

&lt;p&gt;However, page weight is a proxy for the real user experience – page weight doesn’t &lt;em&gt;necessarily&lt;/em&gt; mean that a user’s experience with the page loading was bad. We may be aggressively code splitting or caching, which would mean that this may not fit the criteria set out above.&lt;/p&gt;

&lt;p&gt;Ultimately, page weight as a metric will depend on your use case, so think carefully about how the page weight actually impacts the user experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/siddharthkp/bundlesize" rel="noopener noreferrer"&gt;Bundlesize&lt;/a&gt; is a tool for measuring page weight in an automated way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Paint timing
&lt;/h2&gt;

&lt;p&gt;Paint timing is a popular choice for measuring performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfy63zikpjnfw48fabny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfy63zikpjnfw48fabny.png" alt="Paint timing" width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The three paint timing events in the diagram above reflect different parts of the paint lifecycle.&lt;/p&gt;

&lt;p&gt;First paint: anything is painted to the page, e.g.: the page background colour changes from white to black&lt;br&gt;
First contentful paint: a DOM element is rendered to the page, e.g.: a loading spinner is rendered&lt;br&gt;
First meaningful paint: meaningful data is first rendered to the page&lt;/p&gt;

&lt;p&gt;First paint and first contentful paint are measurable via the &lt;a href="https://css-tricks.com/paint-timing-api/" rel="noopener noreferrer"&gt;Paint timing API&lt;/a&gt;, however, first meaningful paint is harder to measure in this way. First meaningful paint is by its nature, meaningful: something that the user thought of as useful to them was given to them. This makes first meaningful paint a good metric, but first paint and first contentful paint may only be meaningful depending on your use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Subsequent meaningful paints
&lt;/h3&gt;

&lt;p&gt;For single page apps, there may be subsequent page loads, other than the "first' meaningful paint. Component timing is an approach that enables us to measure these follow up render times. The &lt;a href="https://github.com/jpnelson/react-component-timing" rel="noopener noreferrer"&gt;react-component-timing&lt;/a&gt; library is an attempt to create a React wrapper to automate this – contributions encouraged!&lt;/p&gt;

&lt;h2&gt;
  
  
  Speed index
&lt;/h2&gt;

&lt;p&gt;Speed index is a great metric, but can be initially difficult to understand. One way of thinking of it is, we “integrate the % of the page loaded over time” – which probably didn’t help clarify much, so let’s break that down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffuetbmbi251inotkua3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffuetbmbi251inotkua3g.png" alt="diagram of speed index" width="800" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We keep track of what percentage of the page has been loaded at some time interval. We score ourselves based on what % of the page we’ve loaded, and how quickly. As an example, a page that loads everything in 5 seconds will get a worse score than a page that loads half of the page at 2.5 seconds, and the other half at 5 seconds.&lt;/p&gt;

&lt;p&gt;This is a good metric in the sense that it is naturally extremely “continuous” – it incorporates the concept of “loaded-ness” into a single number. Optimizing for this number will certainly improve real user experiences.&lt;/p&gt;

&lt;p&gt;This is a hard metric to use in some other ways though: it is difficult to understand, meaning that it does not convey user empathy very well. It’s unit-less, and so understands a requirement of the metric itself.&lt;/p&gt;

&lt;p&gt;It also requires a tool like webpagetest.org to measure it, as we need to know what percentage of the page has loaded at various intervals. It means that we can’t measure it on &lt;strong&gt;real&lt;/strong&gt; networks and devices, but we can simulate these conditions.&lt;/p&gt;

&lt;h2&gt;
  
  
  ATF (above the fold) render time
&lt;/h2&gt;

&lt;p&gt;Above the fold render time is the time taken until all of the content above the fold of a web page has loaded.&lt;/p&gt;

&lt;p&gt;This metric is relatively easy to understand and empathise with, but it does not deal with post initial load well. It’s hard to measure in real browsers, and in reality, your users &lt;a href="http://abovethefold.fyi/" rel="noopener noreferrer"&gt;probably scroll&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Load event
&lt;/h2&gt;

&lt;p&gt;The load event is triggered after DOMContentLoaded, and after javascript downloads.&lt;/p&gt;

&lt;p&gt;This is an easy metric to measure and understand, and so is fairly common. However, there are some risks, as in the example perviously – it may not be triggered at a time that is truly meaningful, particularly with asynchronous requests for meaningful data.&lt;/p&gt;

&lt;h2&gt;
  
  
  First byte
&lt;/h2&gt;

&lt;p&gt;First byte is easy to measure with the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API" rel="noopener noreferrer"&gt;Navigation API&lt;/a&gt;, and is useful for diagnosing network and backend issues.&lt;/p&gt;

&lt;p&gt;However, this first byte may not represent anything actually meaningful to the user, and so cannot be depended upon alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Time to interactive
&lt;/h2&gt;

&lt;p&gt;Time to interactive measures the time taken until the page is ready to respond to user input.&lt;/p&gt;

&lt;p&gt;Metrics talked about so far have only concerned themselves with delivering data, but for any application that the user may interact with (most applications!) we need a way of measuring this responsiveness, to understand whether the user would truly consider the experience to be “performant”&lt;/p&gt;

&lt;p&gt;Time to interactive is good for doing this, but is less meaningful after the initial page load.&lt;/p&gt;

&lt;p&gt;For measuring it, there is a &lt;a href="https://github.com/GoogleChrome/tti-polyfill" rel="noopener noreferrer"&gt;polyfill available&lt;/a&gt; that approximates this experience by measuring the time at which the CPU first becomes idle – meaning that the page is ready to respond to user input.&lt;/p&gt;

&lt;h2&gt;
  
  
  First input delay
&lt;/h2&gt;

&lt;p&gt;First input delay measures the time it took for the application to respond when the user first interacts with it. This could be a mouse click, touch event, keyboard event, or anything else that the user has initiated.&lt;/p&gt;

&lt;p&gt;This metric is particularly interesting since every value represents real user pain. If your first input delay for a particular session is 1000ms, that's a full second someone had to wait before the button did anything!&lt;/p&gt;

&lt;p&gt;You need to be aware though, that this metric will naturally have some variance. The first input delay will depend on the user – a patient user might wait a long time before clicking something, but another user might click as soon as a button is rendered. For this reason, it is recommended that the 90th &lt;a href="https://en.wikipedia.org/wiki/Percentile" rel="noopener noreferrer"&gt;percentile&lt;/a&gt; is measured, so that you can optimise for reducing those truly painful experiences.&lt;/p&gt;

&lt;p&gt;For measuring, there is a &lt;a href="https://github.com/GoogleChromeLabs/first-input-delay" rel="noopener noreferrer"&gt;polyfill available&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DOMContentLoaded
&lt;/h2&gt;

&lt;p&gt;DOMContentLoaded measures the time it takes to parse HTML and download / parse synchronous javascript.&lt;/p&gt;

&lt;p&gt;This is basically never what you want. If you're considering using DOMContentLoaded as a checkpoint for your metrics, consider using the "load" event instead.&lt;/p&gt;

&lt;h1&gt;
  
  
  The metric starter pack
&lt;/h1&gt;

&lt;p&gt;If you're just getting started and want to start measuring something, I would recommend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time to interactive&lt;/li&gt;
&lt;li&gt;Bundle size&lt;/li&gt;
&lt;li&gt;First input delay&lt;/li&gt;
&lt;li&gt;First meaningful paint (if you can!)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I recommend these as they work pretty well out of the box, there are drop in ways of measuring them, and they represent real user pain in most cases. However, it's worth examining for your use cases, which of these is the best.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tools
&lt;/h1&gt;

&lt;p&gt;There are a number of good tools that can be used to measure the above metrics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The chrome devtools, including the audit tab in chrome ("Lighthouse")&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/ebidel/lighthouse-ci" rel="noopener noreferrer"&gt;Lighthouse CI&lt;/a&gt;, a repeatable version of the audit tab in chrome&lt;/li&gt;
&lt;li&gt;
&lt;a href="//webpagetest.org"&gt;Webpagetest.org&lt;/a&gt; is an amazing tool for measuring some of the "hard to measure" metrics listed above – it can produce a video of page load, which it can then analyse to calculate metrics like the speed index.&lt;/li&gt;
&lt;li&gt;
&lt;a href="//sentry.io"&gt;Sentry&lt;/a&gt;, &lt;a href="http://newrelic.com" rel="noopener noreferrer"&gt;New Relic&lt;/a&gt; and &lt;a href="https://analytics.google.com" rel="noopener noreferrer"&gt;Google analytics&lt;/a&gt; are vital tools for actually tracking real user metrics. Remember the importance of measuring on real devices and real networks – a tool like one of these is essential for doing so.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;It's important to choose a good metric, that reflects real user networks, devices, and experiences. It's also important to choose a metric that you can automate the collection of.&lt;/p&gt;

&lt;p&gt;Now that we have chosen a metric, we need to consider how we will get to this goal, and protect it from the grasp of entropy!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>metrics</category>
    </item>
    <item>
      <title>Measuring performance (Part 2)</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 14 Nov 2018 08:48:23 +0000</pubDate>
      <link>https://dev.to/joshua/measuring-performance-part-2-3648</link>
      <guid>https://dev.to/joshua/measuring-performance-part-2-3648</guid>
      <description>&lt;p&gt;Performance is a problem. The evidence is clear – performance affects your business goals, your user’s happiness, and it impacts areas with poor connectivity even more than you might expect.&lt;/p&gt;

&lt;p&gt;It’s really tempting to immediately think, “I already know what to do! Let’s just fix the problem”&lt;/p&gt;

&lt;p&gt;Certainly, there are some quick performance wins out there. However, if you want to permanently and certainly improve performance, we need a different approach.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can’t improve what you can’t measure&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a popular saying. The rationale is: changing something requires knowledge of both what you want to change, and critically, &lt;em&gt;how to tell if your changes worked&lt;/em&gt;. It’s important to know if your changes have made an impact, and by how much, so that you know whether you should keep performing that action, or try something else.&lt;/p&gt;

&lt;p&gt;However, I think it is still missing something&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can’t &lt;strong&gt;meaningfully&lt;/strong&gt; improve what you can’t &lt;strong&gt;meaningfully&lt;/strong&gt; measure&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We want to be measuring the right thing. If we measure the wrong thing, it’s worse than measuring nothing – we think that we’re having an impact, but we are not solving a meaningful problem. We’re just improving random numbers.&lt;/p&gt;

&lt;p&gt;So, we must carefully and deliberately examine what it is we’re measuring, and make sure that what we’re measuring is “meaningful”&lt;/p&gt;

&lt;h1&gt;
  
  
  What is meaningful?
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmyrsfxne84hu30v6yh9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmyrsfxne84hu30v6yh9.png" alt="A picture of plato" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s a great question. In the context of the universe… hard to say. But in a performance context, we have a clear answer:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Meaningful = better for our users&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ultimately, we’re making websites and apps for users. We’re fixing performance for our users, in the hope that we’re making existing experiences great, and enabling more (and possibly different!) users than we had before to use the information we hold.&lt;/p&gt;

&lt;h1&gt;
  
  
  A user centric definition of performance
&lt;/h1&gt;

&lt;p&gt;We’ve found a problem that is blocking this: performance. Let’s define “performance” for our purposes as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The time for a &lt;em&gt;page&lt;/em&gt; to &lt;em&gt;load&lt;/em&gt; for a &lt;em&gt;user&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can break this down to understand what it really is that we’re trying to measure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a page?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtye8c2rwzyk3w5xwb9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtye8c2rwzyk3w5xwb9z.png" alt="A page in a book" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the users perspective, a “page” has the following :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Behaviour&lt;/li&gt;
&lt;li&gt;Appearance&lt;/li&gt;
&lt;li&gt;Media&lt;/li&gt;
&lt;li&gt;Information&lt;/li&gt;
&lt;li&gt;Semantic information&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Which, from a computer’s perspective, is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Javascript&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;Assets&lt;/li&gt;
&lt;li&gt;Data&lt;/li&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if we want to truly understand a page, and how it is loaded, from the users perspective, we have to understand how these things get delivered to the user&lt;/p&gt;


&lt;div class="glitch-embed-wrap"&gt;
  &lt;iframe src="https://glitch.com/embed/#!/embed/page-load-without-spa?attributionHidden=true&amp;amp;previewSize=100&amp;amp;path=index.html" alt="page-load-without-spa on glitch"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;p&gt;But, are we done? Traditionally, yes. Each of these iterations is considered a page. However, today, the user might perceive something quite different as a “page”&lt;/p&gt;


&lt;div class="glitch-embed-wrap"&gt;
  &lt;iframe src="https://glitch.com/embed/#!/embed/page-load-with-spa?attributionHidden=true&amp;amp;previewSize=100&amp;amp;path=index.html" alt="page-load-with-spa on glitch"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;p&gt;Noting the addition at the end – from the users perspective, there is not much difference between a page loaded through an SPA transition, and the first page load of a site.&lt;/p&gt;

&lt;p&gt;So, ultimately, a page is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A HTML document&lt;/li&gt;
&lt;li&gt;A single page app state&lt;/li&gt;
&lt;li&gt;An app state&lt;/li&gt;
&lt;li&gt;Whatever your users think it is&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is “loading”?
&lt;/h2&gt;

&lt;p&gt;Watch the video below, and decide when you think the page has loaded&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/voHaPuTVjvE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Load is not a single moment in time — it’s an experience that no one metric can fully capture. There are multiple moments during the load experience that can affect whether a user perceives it as "fast" or “slow” – &lt;a href="https://w3c.github.io/paint-timing/" rel="noopener noreferrer"&gt;https://w3c.github.io/paint-timing/&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is no one event, or one easy answer to say when a page has loaded. It might even require knowledge of the future! You may think a page has loaded, until you see that there was actually more to come. It’s also a spectrum – we have varying states of “loaded-ness”, and a metric compresses this into a single number.&lt;/p&gt;

&lt;p&gt;For this reason, we need to be very careful about how we’re picking the metric. It should represent what the user thinks of as “loading”, and ideally, would have a way of representing the user’s perception of "loaded-ness".&lt;/p&gt;

&lt;h2&gt;
  
  
  Who are our “users”?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ef2uu8903gzpldmjvyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ef2uu8903gzpldmjvyy.png" alt="The game of guess who" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Who your users are might be obvious, but that may also be hard to determine. There are many variables to consider: users with fast or slow cpu’s, users with fast or slow internet connections. They may be a regular visitor, or it may be their first time. All of these factors impact the overall experience, and it’s important to measure them to get a better understanding of performance.&lt;/p&gt;




&lt;p&gt;Now we know what is involved in loading a page, from the users perspective, we can start thinking about which metrics to actually use to measure this experience&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>metrics</category>
    </item>
    <item>
      <title>The case for performance (Part 1)</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 14 Nov 2018 08:47:16 +0000</pubDate>
      <link>https://dev.to/joshua/the-case-for-performance-part-1-1gei</link>
      <guid>https://dev.to/joshua/the-case-for-performance-part-1-1gei</guid>
      <description>&lt;p&gt;Note: this is part 1 of a series on meaningful performance metrics.&lt;/p&gt;

&lt;p&gt;The median page load time for a website on a mobile device is 15.6 seconds.&lt;/p&gt;

&lt;p&gt;15.6 seconds.&lt;/p&gt;

&lt;p&gt;Think about that.&lt;/p&gt;

&lt;p&gt;Imagine if you picked up a newspaper or book, and the letters were invisible, or jumped around, for a full 15.6 seconds before staying still.&lt;/p&gt;

&lt;p&gt;First, you'd probably be shocked, books don't normally do that. After that, you'd probably drop it somewhere around the 10 second mark.&lt;/p&gt;

&lt;p&gt;This is a totally normal experience for lots of people when trying to use the web on mobile devices. This is a fundamentally broken experience, and it's one that we can fix.&lt;/p&gt;




&lt;p&gt;The pain of slowly loading websites is one that I've felt acutely over the course of my life. I used to live in a fairly small town, in rural Australia.&lt;/p&gt;

&lt;p&gt;Australia isn't exactly famous for blazing fast internet speeds. They did a test, around the time I lived there, in 2009. The Prime Minister said&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If [the opposition] had their way Australians would be left using carrier pigeons for the future rather than accessing an internationally competitive broadband network&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, they tested it. &lt;a href="https://www.itnews.com.au/news/australian-internet-fails-pigeon-test-159232" rel="noopener noreferrer"&gt;They flew a carrier pigeon&lt;/a&gt; with a 700 megabyte usb drive from the central west, to Sydney, about 100kms or 60 miles.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxj9972oltzvhuiad6vh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxj9972oltzvhuiad6vh.jpg" alt="Carrier pigeon" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The carrier pigeon won, in 1 hour and 5 minutes. They sent a car, which took 2 hours and 10 minutes. And the internet didn't even make it, it dropped out twice.&lt;/p&gt;

&lt;p&gt;This is the environment that web pages are loading in, every day. But, it was in 2009, so surely things have gotten better since then, right?&lt;/p&gt;

&lt;p&gt;Luckily, they have! Internet speeds have improved over time:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28rbljo47tfe3p926mp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28rbljo47tfe3p926mp7.png" alt="graph of internet speeds" width="800" height="521"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.statista.com/statistics/616210/average-internet-connection-speed-in-the-us/" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And on top of that, CPU speeds have also been increasing every year:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyit9y7t411djwl7qqd76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyit9y7t411djwl7qqd76.png" alt="graph of CPU speeds" width="800" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But alas! The web isn't getting faster at all:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fww0rgegjwfkwxa3zytsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fww0rgegjwfkwxa3zytsy.png" alt="graph of page load times" width="800" height="488"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://httparchive.org/reports/state-of-javascript?start=earliest&amp;amp;end=latest&amp;amp;view=list" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why is this? We keep improving our technology, but the internet speeds have stayed roughly the same over the past few years.&lt;/p&gt;

&lt;p&gt;A similar thing happens when we add extra lanes to a highway – a phenomenon known as &lt;a href="https://trrjournalonline.trb.org/doi/abs/10.3141/2653-02?journalCode=trr" rel="noopener noreferrer"&gt;the "induced demand" effect&lt;/a&gt;. Research has found that adding extra lanes to a highway doesn't actually improve traffic much at all – and sometimes makes it worse. A 1% increase in highway capacity can lead to an up to 1.1% increase in demand! The more highway there is, the more people want to use it.&lt;/p&gt;

&lt;p&gt;A similar thing has happened with the web. As technology has improved, our appetite for media, new experiences, and ultimately, total bundle size, has grown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieoogcwq7noj9i7c8n62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieoogcwq7noj9i7c8n62.png" alt="graph of increasing bundle size" width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://httparchive.org/reports/state-of-javascript?start=earliest&amp;amp;end=latest&amp;amp;view=list" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, this problem is not getting better. But for the sake of our users, it needs to.&lt;/p&gt;

&lt;h2&gt;
  
  
  The impact of performance
&lt;/h2&gt;

&lt;p&gt;There are three major areas that this has an impact: It affects business goals, user happiness, and ultimately, the world.&lt;/p&gt;

&lt;h3&gt;
  
  
  Business goals
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftlyn6hmggd689ryh5iq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftlyn6hmggd689ryh5iq.png" alt="A person on a laptop in a conference room" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Performance directly equates to business goals, and money $$$.&lt;/p&gt;

&lt;p&gt;Research conducted by Microsoft found that a one second delay in Bing resulted in a 2.8% drop in revenue. Two seconds of delay resulted in a 4.3% drop.&lt;/p&gt;

&lt;p&gt;Walmart found that a one second improvement in load time resulted in a 2% increase in conversions, and every 100ms resulted in up to a 1% increase in conversions.&lt;/p&gt;

&lt;p&gt;Google found that publishers whose mobile sites load in 5 seconds earn &lt;em&gt;double&lt;/em&gt; from mobile ad revenue than sites loading in 19 seconds.&lt;/p&gt;

&lt;p&gt;There are &lt;a href="https://wpostats.com/tags/revenue/" rel="noopener noreferrer"&gt;many, similar results&lt;/a&gt; from all sorts of sites.&lt;/p&gt;

&lt;p&gt;So, time invested in fixing performance directly leads to money. It's already worth investing in performance, just based on this alone.&lt;/p&gt;

&lt;h3&gt;
  
  
  User happiness
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2mvt2vbpa7s2848516o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2mvt2vbpa7s2848516o.png" alt="A frustrated user on a laptop" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.nngroup.com/articles/response-times-3-important-limits/" rel="noopener noreferrer"&gt;Human Computer Interaction research&lt;/a&gt; shows that from the users perspective, there are three general categories of tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tasks in &amp;lt;= 0.1s are &lt;strong&gt;"instant"&lt;/strong&gt; tasks. The user feels as though the system is reacting immediately to their input&lt;/li&gt;
&lt;li&gt;Tasks in &amp;lt;= 1s are &lt;strong&gt;flow&lt;/strong&gt; tasks. The user is able to maintain a sense of flow as they are navigating through their tasks. They will notice delay, but it will not break concentration&lt;/li&gt;
&lt;li&gt;Tasks in &amp;gt; 10s result in a &lt;strong&gt;task switch&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, along that spectrum, from 1 second to 10 seconds, users are getting progressively more and more frustrated. The moment at which the user is switching a task, the user is certainly frustrated – impacting how they feel about your product, and making them unhappy.&lt;/p&gt;

&lt;h3&gt;
  
  
  The world
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dqxafzgh8azde5ythh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dqxafzgh8azde5ythh6.png" alt="A picture of earth" width="800" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A version of youtube was created, called "&lt;a href="https://wpostats.com/2015/11/11/youtube-feather.html" rel="noopener noreferrer"&gt;Youtube feather&lt;/a&gt;". This version of youtube was 90% lighter in terms of page weight, and contained just the bare minimum for youtube to load. The creators wanted to see if this would improve average load times for that version, so they opted in a small percentage of traffic.&lt;/p&gt;

&lt;p&gt;Strangely, they found that the average load time actually went up!&lt;/p&gt;

&lt;p&gt;Upon investigation, they found an &lt;em&gt;increase&lt;/em&gt; in traffic from Southeast Asia, South America, Africa and Sibera – areas with traditionally poor internet connectivity. These were actually new users – users who previously would not have been able to use Youtube at all, due to prohibitively slow loading times!&lt;/p&gt;

&lt;h2&gt;
  
  
  What next?
&lt;/h2&gt;

&lt;p&gt;So, performance is a problem, and it's one worth fixing. However, it's pretty likely if you're reading this that you &lt;strong&gt;already think&lt;/strong&gt; that performance is an issue.&lt;/p&gt;

&lt;p&gt;Then, why haven't we fixed it?&lt;/p&gt;

&lt;p&gt;There are a couple of common responses I've heard:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The "give up": "It's such a hard problem, we can't fix it"&lt;/li&gt;
&lt;li&gt;The "denial": "It's ok, our users have fast internet and cpu's, right?"&lt;/li&gt;
&lt;li&gt;The "loop": "Oh god you're right, let's fix it" -&amp;gt; "we fixed it!" -&amp;gt; "Oh god it's terrible again"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, performance is doomed to be bad until the inevitable heat death of the universe. Ever expanding entropy will claim all. Chaos reigns supreme. We can’t control it, performance will always regress.&lt;/p&gt;

&lt;p&gt;Or, we try.&lt;/p&gt;

&lt;p&gt;Meaningful performance metrics can save you.&lt;/p&gt;

&lt;p&gt;We need a &lt;em&gt;meaningful&lt;/em&gt; way of measuring performance, and to make a commitment that we'll hold to, once and for all.&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>performance</category>
      <category>metrics</category>
    </item>
    <item>
      <title>The state of the state: React state management in 2018</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Fri, 15 Jun 2018 06:05:42 +0000</pubDate>
      <link>https://dev.to/joshua/the-state-of-the-state-react-state-management-in-2018-2l0c</link>
      <guid>https://dev.to/joshua/the-state-of-the-state-react-state-management-in-2018-2l0c</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SMu1KSUv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/j954wf72re89cn06fe5c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SMu1KSUv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/j954wf72re89cn06fe5c.jpg" alt="Photo of a dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's always been a myriad of ways to manage state in React. Redux has always been a popular choice, but with React 16, and recently released libraries, there are now even more options. What are these options, and why would you use any of these over any others?&lt;/p&gt;

&lt;p&gt;I've gone through some popular choices for managing state in React, and created very simple todo apps to demonstrate their usage. I've tried to keep things as simple as possible, so that you can directly compare these examples. The source is annotated with comments, so take a look and see what best fits your use case!&lt;/p&gt;

&lt;h1&gt;
  
  
  React's setState()
&lt;/h1&gt;

&lt;p&gt;State is discussed at the start of many different React tutorials for a reason. It's included as a part of React, and is a core part of the way the framework works.&lt;/p&gt;

&lt;p&gt;This is referred to as "local state" in the &lt;a href="https://reactjs.org/docs/state-and-lifecycle.html#adding-local-state-to-a-class"&gt;react docs&lt;/a&gt;, "state". Here we will call it "setState()" to differentiate from the other approaches.&lt;/p&gt;

&lt;p&gt;setState() is a simple way to manage your application state, and doesn't require any libraries beyond just React.&lt;/p&gt;

&lt;p&gt;There are some good reasons to use setState():&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your state is not entirely describable as plain objects (you may store unserializable state in setState(), such as DOM nodes, or objects with circular references)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your changes are not pure functions, and depend on the "outside world" (like, the browser) to determine how state should change&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You don't need a global view of the UI – your state will never be persisted or stored remotely.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ✨ Example
&lt;/h3&gt;

&lt;p&gt;There's annotated source available for a comparative example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_fsImIm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5g5xjtj4td4ywxzszsak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_fsImIm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5g5xjtj4td4ywxzszsak.png" alt="react set state screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/m9v3xvkl0y"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzpI10jk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit react-state-demo-setstate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Redux
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://redux.fastjs.link/"&gt;Redux&lt;/a&gt; is a popular alternative to using setState() when the above constraints no longer hold true. Redux is a set of tools for writing to and reading from a global state in a functional, consistent way. &lt;a href="https://github.com/reduxjs/react-redux"&gt;React redux&lt;/a&gt; provides a convenient way of mapping your redux state onto React components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Async redux
&lt;/h3&gt;

&lt;p&gt;For async and remote state, &lt;a href="https://github.com/reduxjs/redux-thunk"&gt;Redux thunk&lt;/a&gt; and &lt;a href="https://github.com/redux-saga/redux-saga"&gt;Redux saga&lt;/a&gt; are popular choices. Redux thunk uses redux middleware to allow actions to be async functions, and redux saga uses a pattern that allows easy handling of async behaviour and side effects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redux-observable.js.org/"&gt;Redux observables&lt;/a&gt; is a way of allowing all the power of observables in your state management, pluggin RxJS into redux through some middleware. &lt;a href="http://rxmarbles.com/"&gt;rxmarbles&lt;/a&gt; provides some great examples to give you and idea of what's possible here.&lt;/p&gt;

&lt;p&gt;While Redux thunk and Redux saga make async state management with redux easier, but can become one more thing for developers to learn regarding state management.&lt;/p&gt;

&lt;p&gt;⚠️ Redux is the de-facto standard for state management in React, but &lt;a href="https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367"&gt;you might not need Redux&lt;/a&gt; (by Dan Abramov, a &lt;em&gt;co-author&lt;/em&gt; of redux!). Choosing something more complicated than you need will slow you down and complicate simple state changes. This applies to other items in the list - you might not need anything other than setState().&lt;/p&gt;

&lt;p&gt;The questions to ask are explained well in &lt;a href="https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367"&gt;you might not need Redux&lt;/a&gt;, but in summary – Redux is good if you need serialisable state with an opinionated way of managing global state, but can be overkill for some use cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨ Example
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/mzjmrpn63y"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzpI10jk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit react-state-demo-redux"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Apollo link state
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://apollo-link-state.fastjs.link"&gt;Apollo link state&lt;/a&gt; is a way to combine your local state management with your remote state management. The approach assumes you are using &lt;a href="https://www.apollographql.com/"&gt;Apollo&lt;/a&gt;, which allows you to use GraphQL over Rest. However, &lt;em&gt;you do not need a GraphQL server in order to use this approach!&lt;/em&gt; – &lt;a href="https://www.apollographql.com/docs/link/links/http.html"&gt;apollo-link-http&lt;/a&gt; allows you to write everything you need to adopt Apollo client side. This means that it's a viable all-in-one solution for state management (async and remote included), even if you aren't using GraphQL.  &lt;/p&gt;

&lt;p&gt;The way that local and remote state becomes intermingled is through your queries and mutations. &lt;code&gt;apollo-link-state&lt;/code&gt; gives you access to a special &lt;code&gt;@client&lt;/code&gt; directive that tells Apollo to look for this piece of state in local memory, rather than some remote server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;GetTodos&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;@client&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Getting Apollo set up just for state management can be a bit of work, but the payoff is a natural way of querying and mutating state, combining local and remote state management.&lt;/p&gt;

&lt;p&gt;For simple use cases, and apps that don't heavily depend on async or remote state, Apollo link state is surely overkill. For more involved use cases, Apollo can help by consolidating state management into one system.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨ Example
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/k9k56pnj77"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzpI10jk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit react-state-demo-apollo-linkstate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Unstated
&lt;/h2&gt;

&lt;p&gt;React 16 has brought with it a &lt;a href="https://reactjs.org/docs/context.html"&gt;new context API&lt;/a&gt;, which is a nice way of sharing information around React's virtual tree. &lt;a href="https://unstated.fastjs.link"&gt;Unstated&lt;/a&gt; is a library that makes the most of this – it's a light weight way of managing global state across your application.&lt;/p&gt;

&lt;p&gt;It's similar to Redux conceptually, but with less opinions about how you should use it. The state is not sliced up into different sections, and defining "actions" is left to you. The API is very similar to React's setState() in shape.&lt;/p&gt;

&lt;p&gt;⚠️ Given this, if you're using Unstated, you should again carefully consider if setState() is sufficient for your use case. From the unstated readme:&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/jamiebuilds/unstated#what-state-should-i-put-into-unstated"&gt;unstated readme&lt;/a&gt; gives good guidance about when to use alternatives such as Apollo, libraries, or Backbone models and collections.&lt;/p&gt;

&lt;p&gt;From the readme:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Unstated isn't ambitious, use it as you need it, it's nice and small for that reason. Don't think of it as a "Redux killer". Don't go trying to build complex tools on top of it. Don't reinvent the wheel. Just try it out and see how you like it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're looking for a simple, un-opinionated state management system and don't want the overhead of alternatives, it's worth looking at.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨ Example
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/qxw215zm7j"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzpI10jk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit react-state-demo-unstated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Honourable mentions
&lt;/h2&gt;

&lt;p&gt;This is not an exhaustive list! I've included some references to alternatives not mentioned here that I haven't yet been able to create examples for or include here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/developit/stockroom#readme"&gt;Stockroom&lt;/a&gt; lets you offload your store management to a web worker! This frees up the main thread from computation, and makes all of your requests to read and modify state async.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://backbonejs.org/"&gt;Backbone models and collections&lt;/a&gt; is a well known alternative, and might be sufficient for your use case.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://lsm.github.io/alfa/#/"&gt;Alfa&lt;/a&gt; is a very small and simple state management option.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/mobxjs/mobx"&gt;MobX&lt;/a&gt; is a popular choice (hoping I get a chance to try this and add it to the blog!)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;React doesn't include this type of state management itself, which leads to this rise of alternative state management systems. It can be hard to make this choice, but it's good to be allowed the choice – different problems work better with different solutions, and it's nice that React is flexible enough to work with all of them :)&lt;/p&gt;




&lt;p&gt;👋 Hi! I’m &lt;a href="https://twitter.com/nelsonjoshpaul"&gt;Joshua Nelson&lt;/a&gt;. I’m a developer who cares about making the web a better, for everyone ✨&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>React explaining, explained</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Wed, 30 May 2018 07:14:12 +0000</pubDate>
      <link>https://dev.to/joshua/react-explaining-explained-1lb8</link>
      <guid>https://dev.to/joshua/react-explaining-explained-1lb8</guid>
      <description>&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fr7ilhvlik6oggrmilwuv.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fr7ilhvlik6oggrmilwuv.jpg" alt="Feynman with a blackboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Richard Feynman was once asked by a Caltech faculty member to explain why spin 1/2 particles obey Fermi-Dirac statistics. He gauged his audience perfectly and said, “I’ll prepare a freshman lecture on it.” But a few days later he returned and said, “You know, I couldn’t do it. I couldn’t reduce it to the freshman level. That means we really don’t understand it. [1]&lt;/p&gt;

&lt;p&gt;Explaining things is hard. It requires knowing that thing intimately, back to front. Putting yourself in the mind of someone who doesn’t understand reveals what you don’t understand. It’s an &lt;a href="https://medium.com/@iantracey/engineering-empathy-158b60dc661e" rel="noopener noreferrer"&gt;exercise in empathy&lt;/a&gt;, and a skill that can be honed.&lt;/p&gt;

&lt;p&gt;Effectively explaining is very satisfying, and is a useful skill to develop. As software engineers, a large part of our responsibility is not only understanding things, but to explain them too. Many times a day, we need to explain things to new team members, product managers, designers, and even people from completely different disciplines.&lt;/p&gt;

&lt;h1&gt;
  
  
  Is React easy or hard to understand?
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;I’m going to be honest: I’ve had a hell of a time getting my head around React. More than any other technology I’ve touched over the last 10 years of my career, I just haven’t had it click for me. It’s very frustrating as I really want to learn it, and it’s clear the library has legs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;– Brad Frost, &lt;a href="http://bradfrost.com/blog/post/my-struggle-to-learn-react/" rel="noopener noreferrer"&gt;http://bradfrost.com/blog/post/my-struggle-to-learn-react/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This isn’t the first time I’ve heard someone say that React is hard to learn. However, I’ve also heard people say “The core concepts of React are easy to understand!”.&lt;/p&gt;

&lt;p&gt;So, which is it? Is it actually hard to understand React? Is it more or less hard than understanding another framework?&lt;/p&gt;

&lt;p&gt;There’s no definitive answer. React will be easy to understand for some people, and harder to understand for a different set of people. People come with a different backgrounds, and a different set of &lt;a href="https://jamesclear.com/feynman-mental-models" rel="noopener noreferrer"&gt;“mental models”&lt;/a&gt; (more Richard Feynman stories, sorry 😅), which means that the core concepts of React will be easier or harder for different people!&lt;/p&gt;

&lt;p&gt;For someone who has worked a lot with &lt;a href="https://www.polymer-project.org/" rel="noopener noreferrer"&gt;web&lt;/a&gt; &lt;a href="https://github.com/skatejs/skatejs" rel="noopener noreferrer"&gt;components&lt;/a&gt;, React has a nice home in that person’s set of mental models. However, for someone who has only really used jQuery in an ad-hoc way, there are lots of new concepts to understand, and care must be taken when explaining to cover those.&lt;/p&gt;

&lt;p&gt;If lot of concepts of React are new to people, it’s useful to know how people understand things, so that we can more effectively explain.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to explain React things
&lt;/h1&gt;

&lt;p&gt;It took me some time to realise &lt;em&gt;the way you understood React isn’t the way that someone else will understand it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are many reasons for this — people come from different backgrounds, with different experiences. They may be more used to how Angular works, or Backbone, or maybe they’re used to using jQuery to manipulate the DOM directly. They might have limited javascript experience, or they may know everything there is to know about ES6. The important thing is to spend time getting to know the background of the people, or person, that you are explaining things to. People learn new concepts by relating them to things they already know, and this can be encouraged with good analogies and comparisons.&lt;/p&gt;

&lt;p&gt;Another key reason why someone else won’t necessarily understand it in the same way is due to history, and time. I was talking with a friend recently about how rapidly things change. “Front end stuff just moves so fast! I learnt javascript a year ago, and the next time I came back everything’s different!”. Gradually building up concepts over time made learning React straightforward for me, but for somebody who is confronted with React, ES6, Webpack and JSX all at the same time — these are all new concepts that are easily confused with each other.&lt;/p&gt;

&lt;h1&gt;
  
  
  So, how can we explain better?
&lt;/h1&gt;

&lt;p&gt;If you don’t pay careful attention to these differences in experiences, your explanation won’t be effective. Depending on whether you’re explaining 1 on 1 or in a group setting, there are different strategies for approaching these varying experiences.&lt;/p&gt;

&lt;p&gt;Ask questions regularly. This gives you an opportunity to check in on the person you’re explaining things to. It engages the other person, and makes explaining an interactive process, rather than a passive one. Ask questions that encourage engagement. Instead of asking yes or no questions like “Does this make sense?” (often met with empty nods or “uh, yeah.”), ask “what” or “why” questions, like “What would happen in this situation?” and “Why is this piece of code important?”&lt;br&gt;
Be prepared to change tacts. Since there is a wide spectrum of experience, in a 1 on 1 setting, you should be prepared to tailor your explanation to the individual. This is better as it helps them relate to the knowledge, and allows them to engage more.&lt;/p&gt;

&lt;p&gt;Give the right level of detail. If you know something in depth, it’s tempting to deep dive into interesting but unimportant details. Be prepared to use abstractions or skip parts that aren’t relevant to ensure your explanation meets the experience of your audience (note: this doesn’t mean you should &lt;a href="https://xkcd.com/803/" rel="noopener noreferrer"&gt;simplify to the point of being incorrect&lt;/a&gt; )&lt;/p&gt;
&lt;h1&gt;
  
  
  Examples
&lt;/h1&gt;

&lt;p&gt;Specifically with React, there are common confusing points for people who haven’t been following closely.&lt;/p&gt;
&lt;h2&gt;
  
  
  ES6 vs. JSX
&lt;/h2&gt;

&lt;p&gt;Introducing these two concepts at the same time is often confusing for people. Looking at the following code sample, we can see there are multiple new concepts combined&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="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&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="c1"&gt;//ES2015 + React&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&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-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;//ES2015 + React&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allCaps&lt;/span&gt; &lt;span class="o"&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;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;//ES2015&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelloWorld&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&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="c1"&gt;//ES2015 + React&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;//ES2015 + React&lt;/span&gt;
    &lt;span class="kd"&gt;const&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;=&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;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//ES2015&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;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;allCaps&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;/p&amp;gt;{/&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;JSX&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&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;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&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;HelloWorld&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Josh&lt;/span&gt;&lt;span class="dl"&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Starting off with an overview of &lt;a href="http://espadrine.github.io/New-In-A-Spec/es6/" rel="noopener noreferrer"&gt;which parts are ES6&lt;/a&gt; can be helpful if the person is unfamiliar with this new syntax.&lt;/p&gt;

&lt;p&gt;I also made a tool, &lt;a href="https://react-or-es2015.glitch.me/" rel="noopener noreferrer"&gt;“React or ES2015”&lt;/a&gt;, to help with this. Pasting a code snippet, you can see which parts are React, JSX, ES2015, or ES5, and click through to relevant documentation for each part. This tool may not be helpful to someone who can immediately tell which syntax come from where, but there are many people for who I hope this is useful!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are there so many ways of creating components?
&lt;/h2&gt;

&lt;p&gt;A React component can be defined as a class, a function, or by calling &lt;code&gt;React.createClass&lt;/code&gt;. This is a confusing point for people new to React. Introduce this concept carefully — provide &lt;em&gt;clear guidelines&lt;/em&gt; on when to use each of them, to avoid unnecessary confusion (will you use state? Use a class : Use a function).&lt;/p&gt;

&lt;h2&gt;
  
  
  The overall model
&lt;/h2&gt;

&lt;p&gt;This is my favourite part to explain, as I think it’s one of the greatest parts of building UI in React. The &lt;a href="https://reactjs.org/docs/thinking-in-react.html" rel="noopener noreferrer"&gt;overall data flow&lt;/a&gt; model is generally easy to understand, and understanding this basic concept is a useful mental model.&lt;/p&gt;

&lt;p&gt;This is also a great opportunity to compare with other languages, approaches and frameworks that the user is used to. Comparing and contrasting the approaches will help solidify the concepts in the learner’s mind.&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://facebook.github.io/flux/docs/in-depth-overview.html#content" rel="noopener noreferrer"&gt;https://facebook.github.io/flux/docs/in-depth-overview.html#content&lt;/a&gt;&lt;br&gt;
Pointing out that React is the view layer in the above diagram helps clear up ambiguity around React’s job.&lt;/p&gt;

&lt;p&gt;The fundamental idea of the flux model is useful to know, but give the right level of detail, and don’t spend too much time in the abstract. Seeing how things follow this model in practice is more useful than an in-depth, abstract explanation of the flux model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helper libraries
&lt;/h2&gt;

&lt;p&gt;When creating demos or writing examples for people, be careful to not depend on helper libraries that are not relevant to the point you are trying to convey. If you’re trying to make a point about React state management, avoid using lodash, react-router, react-intl, or anything that’s not directly related to what you’re trying to explain.&lt;/p&gt;

&lt;p&gt;While it’s clear to people familiar with lodash that &lt;code&gt;_.concat&lt;/code&gt; isn’t the point of your example, this can be a confusing distraction for people unfamiliar with lodash, and the point you’re trying to make.&lt;/p&gt;

&lt;h2&gt;
  
  
  State
&lt;/h2&gt;

&lt;p&gt;Another common question relates to what type of state to use. This is getting more confusing for beginners as there are many new alternatives — each with some advantage (&lt;a href="https://github.com/jamiebuilds/unstated" rel="noopener noreferrer"&gt;they’re small&lt;/a&gt;, &lt;a href="https://github.com/developit/stockroom" rel="noopener noreferrer"&gt;they’re not running in the main thread&lt;/a&gt;, &lt;a href="https://www.apollographql.com/docs/link/links/state.html" rel="noopener noreferrer"&gt;they’re wired to GraphQL&lt;/a&gt;, or they’re just using normal React features like store and context).&lt;/p&gt;

&lt;p&gt;Personally, I find these new developments exciting, but understandably, new learners find the amount of choice here distressing. Providing clear guidance helps mitigate this. Pick one of these and learn that to begin with — when you’ve come to grasp the main concepts of React, the nuance of which store is best becomes a more relevant question.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to explain in general
&lt;/h2&gt;

&lt;p&gt;Research shows that people learn more effectively with active, rather than passive learning [2]. Active learning is a style that encourages learners to analyse what they know and do not know. For an explainer, this means encouraging questions, and also asking questions regularly to keep the learner engaged. People also learn more effectively when they are given control over what they want to learn, as this encourages engagement [3].&lt;/p&gt;

&lt;p&gt;Once someone is engaged, learning can take place by relating new concepts to existing ones that they already understand. Learning and remembering new ideas becomes easier once that idea finds a place in our set of mental models.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why all of this?
&lt;/h1&gt;

&lt;p&gt;Front end development is great, and getting better all the time. The way that we can continue making the technology, and the community even better, is by putting effort into explaining things clearly and effectively. More people can learn, become experts, and share new, diverse ideas.&lt;/p&gt;

&lt;p&gt;Communicating how technologies, and React, work, is a key part of this. The way you understood React isn’t the way that someone else will understand it, and with some conscious effort, we can get better at sharing our ideas about things with each other 😁&lt;/p&gt;




&lt;p&gt;👋 Hi! I’m &lt;a href="https://twitter.com/nelsonjoshpaul" rel="noopener noreferrer"&gt;Joshua Nelson&lt;/a&gt;. I’m a developer who cares about making the web a better, for everyone ✨&lt;/p&gt;

&lt;p&gt;This is a cross post from &lt;a href="https://medium.com/@joshuanelson/react-explaining-explained-13a3fe6e5b9d" rel="noopener noreferrer"&gt;https://medium.com/@joshuanelson/react-explaining-explained-13a3fe6e5b9d&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Six Easy Pieces: Essentials of Physics Explained by Its Most Brilliant Teacher&lt;/li&gt;
&lt;li&gt;&lt;a href="http://life-slc.org/docs/Bransford_etal-Learningtheories_2006.pdf" rel="noopener noreferrer"&gt;(Bransford, 2000, pg.15–20)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;J. Scott Armstrong (2012). “Natural Learning in Higher Education”. &lt;a href="https://faculty.wharton.upenn.edu/wp-content/uploads/2014/09/Natural-Learning-in-Higher-Education_2.pdf" rel="noopener noreferrer"&gt;https://faculty.wharton.upenn.edu/wp-content/uploads/2014/09/Natural-Learning-in-Higher-Education_2.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Software Imagineering</title>
      <dc:creator>Joshua Nelson ✨</dc:creator>
      <pubDate>Fri, 24 Mar 2017 06:34:19 +0000</pubDate>
      <link>https://dev.to/joshua/software-imagineering</link>
      <guid>https://dev.to/joshua/software-imagineering</guid>
      <description>&lt;p&gt;If you work at a Disney theme park, you might be what they call an &lt;em&gt;Imagineer&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;“Imagineer is a portmanteau of imagination and engineering, and the term was coined to describe a role that blends these two concepts. Imagineers &lt;em&gt;design&lt;/em&gt; the theme park’s rides, attractions, and overall experience – but they also &lt;em&gt;engineer&lt;/em&gt; them.&lt;/p&gt;

&lt;p&gt;The process starts off with what is known as “blue sky speculation, or as I’ve heard it referred to, “&lt;a href="https://medium.com/designing-atlassian/want-better-ideas-go-to-crazytown-48f9f793922f" rel="noopener noreferrer"&gt;going to crazy town&lt;/a&gt;”. This part of the design process is pure imagination – no limits, disregard reality. Just ask “what if?”&lt;/p&gt;

&lt;p&gt;For instance: imagine a ride that could truly convince people that they were flying. No rails, no strings attached. What would it feel like? What would the  deal experience be? But, how would this ride actually work? Where are people going to sit? If I can see the ride, I’m not going to be convinced that I’m flying.&lt;/p&gt;

&lt;p&gt;Delay any questions or doubts that you might have in your mind. Think about the  ideal experience.&lt;/p&gt;

&lt;p&gt;I am a developer on the design team at Atlassian. When I joined the team, I didn’t know what I was getting into – I liked front end development, and my team sat under the design umbrella. I bought a few books on design, but I had no idea what I had signed up for.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AX1yi1Z7mkYV129_IbMTprg.jpeg" 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AX1yi1Z7mkYV129_IbMTprg.jpeg" alt="design week photo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.flickr.com/photos/doctordray/" rel="noopener noreferrer"&gt;Aundray Cheam, flickr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part of my job is taking designs from the &lt;a href="https://design.atlassian.com/latest/" rel="noopener noreferrer"&gt;Atlassian Design Guidelines&lt;/a&gt;, and transforming that into a &lt;a href="http://docs.atlassian.com/aui/latest/" rel="noopener noreferrer"&gt;user interface library&lt;/a&gt; for our developers to use. I see the discrepancy between imagination and reality every day. The experiences our designers imagine are fantastic, but I often see designers and engineers unable to compromise when it comes to implementing the designs. If compromises cannot be made, it leads to bad, buggy implementations, or clunky experiences that do not match the user’s needs.&lt;/p&gt;

&lt;p&gt;It’s imperative that our designers work closely with engineers, and the engineers with designers, in order to make educated and conscious compromises where necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compromises
&lt;/h3&gt;

&lt;p&gt;Large scale implementation of design is hard. Developing for web applications and the front end is particularly fraught with difficulty. In theory, we’d be able to tweak design by just changing CSS rules, but reality is not so simple. Overrides, hacks and edge cases are plentiful, and engineers need to be perpetually conscious of these in order to maintain a bug-free experience.&lt;/p&gt;

&lt;p&gt;Software engineers are trained to think of edge cases for the software they design. When it comes to talking to designers, this type of thinking can easily influence our conversations. Engineers need to be realistic, but they should also know when the feedback is appropriate, and how to give it.&lt;/p&gt;

&lt;p&gt;I recall an instance where a designer did some conceptual work for a new user experience in one of our products. The end result was amazing – it included automatic discovery and running of tests and intelligent repositories that set everything up for you. My feedback for them poked holes in the idea though – I asked, “How would this work? This isn’t what reality is like at all. This cannot&lt;br&gt;
be done”.&lt;/p&gt;

&lt;p&gt;Later though, I realised that this was not the point of the exercise – and I approached giving the feedback in the wrong way. I was thinking about the engineering work (my own experience), when I should have been thinking about the end user’s experience. Approaching the idea from the perspective of a user, it’s a fantastic idea. Thinking about the user’s experience first, I would have been able to compromise to achieve the same goals that the designer had – the best possible experience for our users.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Awc93l-OCYuPtDcziryTc2A.jpeg" 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Awc93l-OCYuPtDcziryTc2A.jpeg" alt="design week photo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.flickr.com/photos/doctordray/" rel="noopener noreferrer"&gt;Aundray Cheam, flickr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, designers need to be aware of engineering concerns when it comes to their designs. Often these concerns are technical limitations. A good designer is not afraid of constraints though – if the designer is willing to compromise, and to &lt;em&gt;understand&lt;/em&gt; the technical constraints fully, the designer and the engineer can create a better user experience for all users.&lt;/p&gt;

&lt;p&gt;During this type of conversation, both parties must be aware of each other’s goals, and know when it’s sensible to compromise. The way to achieve this is through empathy – designers must be willing to understand the goals, concerns, and fears of engineers, and engineers should know why designers create the designs they do. Ultimately, engineers and designers should care about the experience of the user.&lt;/p&gt;

&lt;p&gt;The imagineers at Disneyland were able to create a ride that simulated the sensation of flying. This ride is called “&lt;a href="http://en.wikipedia.org/wiki/Soarin'_Over_California" rel="noopener noreferrer"&gt;Soarin’ Over California&lt;/a&gt;”. The ride is constructed with a large screen in front of the participants, completely encompassing the field of vision. They sit in elevated chairs that move as the ride progresses.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AShi8mxp77jt5GvSAtT23jg.jpeg" 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AShi8mxp77jt5GvSAtT23jg.jpeg" alt="soarin over California"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/12734746@N00" rel="noopener noreferrer"&gt;Josh Hallett&lt;/a&gt; from Winter Haven, FL, USA – &lt;a href="http://www.flickr.com/photos/hyku/4741725097/" rel="noopener noreferrer"&gt;Soarin’ – Disney California Adventure&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An idea like this is a compromise between engineering and design. Participants don’t actually fly – they don’t even move. However, the core experience, the sensation of flight, was maintained throughout the design and its implementation, and the ride’s users are happier for it.&lt;/p&gt;

&lt;p&gt;Design and development, or imagination and engineering, are often thought of as opposed forces, or a line across which a tradeoff can be made – but if both disciplines are willing to fully understand the goals and constraints, we can make  better products, experiences, and theme park rides for everyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Joshua Nelson
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/nelsonjoshpaul" rel="noopener noreferrer"&gt;https://twitter.com/nelsonjoshpaul&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/in/joshua-nelson-a0156523/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/joshua-nelson-a0156523/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developer at &lt;a href="http://twitter.com/Atlassian" rel="noopener noreferrer"&gt;@Atlassian&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(&lt;a href="https://medium.com/@joshuanelson/software-imagineering-aa41874fda67#.ox0m34ugb" rel="noopener noreferrer"&gt;cross-post&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>design</category>
      <category>ux</category>
      <category>frontend</category>
      <category>compromise</category>
    </item>
  </channel>
</rss>
