<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Josep Jaume Rey</title>
    <description>The latest articles on Forem by Josep Jaume Rey (@josepjaume).</description>
    <link>https://forem.com/josepjaume</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%2F235569%2F7b05a5b4-729e-4a79-9256-4cfa2d594a26.jpg</url>
      <title>Forem: Josep Jaume Rey</title>
      <link>https://forem.com/josepjaume</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/josepjaume"/>
    <language>en</language>
    <item>
      <title>An Ode to Code Reviews</title>
      <dc:creator>Josep Jaume Rey</dc:creator>
      <pubDate>Tue, 21 Jan 2020 00:00:00 +0000</pubDate>
      <link>https://forem.com/codegram/an-ode-to-code-reviews-1img</link>
      <guid>https://forem.com/codegram/an-ode-to-code-reviews-1img</guid>
      <description>&lt;p&gt;At &lt;a href="https://www.codegram.com"&gt;Codegram&lt;/a&gt;, we truly believe that &lt;strong&gt;Code Reviews&lt;/strong&gt; are a &lt;strong&gt;crucial activity&lt;/strong&gt; in any software development endeavor. That's a mantra we've been repeating over and over inside our company, but honestly, we think we can get way better at it.&lt;/p&gt;

&lt;p&gt;This article is an ode to the beauties of &lt;strong&gt;Code Reviews&lt;/strong&gt; and how they can make your team share &lt;strong&gt;better&lt;/strong&gt; &amp;amp; be more &lt;strong&gt;accountable&lt;/strong&gt; for its decisions while making it all more &lt;strong&gt;enjoyable&lt;/strong&gt; for everyone. We'll explore why peer reviews matter and we'll introduce an idea — the &lt;em&gt;Review Buddy&lt;/em&gt; — to help you improve the way you review code as a team. But first...&lt;/p&gt;

&lt;h2&gt;
  
  
  ❓What even is a Code Review?
&lt;/h2&gt;

&lt;p&gt;Code Reviews are a &lt;strong&gt;quality assurance&lt;/strong&gt; process in which a developer exposes their code to an individual or a team in order to get feedback and change it until a consensus is achieved. Depending on your tool of choice, you're going to use GitHub's &lt;a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests"&gt;Pull Requests&lt;/a&gt;, GitLab's &lt;a href="https://docs.gitlab.com/ee/user/project/merge_requests/"&gt;Merge Requests&lt;/a&gt; and so on.&lt;/p&gt;

&lt;h2&gt;
  
  
  🙃 But why code review at all?
&lt;/h2&gt;

&lt;p&gt;We developers love code so much that &lt;strong&gt;we'd probably rather spend all day throwing lines at the editor&lt;/strong&gt; , leaving aside other mundane activities like meetings, answering e-mails or... reviewing other people's code.&lt;/p&gt;

&lt;p&gt;That's okay and sure everybody can understand that feeling. We just love code &lt;em&gt;so much&lt;/em&gt;! But writing code is not a science but rather an engineering task (some might say there's even some art in it), and successful engineers take the human factor into account &lt;strong&gt;every step of the way.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Taking the human factor into account". A-ha.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;See, what's made of a bunch of humans? Teams! So let's take a step back and think about what we're collaborating over: &lt;strong&gt;&lt;em&gt;code&lt;/em&gt;&lt;/strong&gt;. If we look at programming languages themselves, they're not meant to &lt;em&gt;just&lt;/em&gt; solve the problem at hand, they're also meant to be &lt;em&gt;expressive, clean&lt;/em&gt; and &lt;em&gt;reusable&lt;/em&gt;. Arguably, sometimes at the expense of efficiency solving the problem itself.&lt;/p&gt;

&lt;p&gt;Why is that? Because &lt;strong&gt;we care about how other humans&lt;/strong&gt; (or the future human you!) &lt;strong&gt;deal with code&lt;/strong&gt; so they can understand it, build on top of it, extend it and re-shape it as pleased.&lt;/p&gt;

&lt;p&gt;If you think about it, &lt;em&gt;code reviews&lt;/em&gt; are the ultimate form of expressiveness. They just happen to encompass another dimension: &lt;strong&gt;time&lt;/strong&gt;. When you create a &lt;em&gt;Pull Request&lt;/em&gt; on &lt;em&gt;GitHub&lt;/em&gt;, you do it to solve a specific need &lt;em&gt;at that moment in time&lt;/em&gt;, with a specific context in mind that might change in the future.&lt;/p&gt;

&lt;p&gt;Maybe a colleague — or yourself — need to revisit a decision you made a while ago and hey, revisiting that nice &lt;strong&gt;Pull Request&lt;/strong&gt; might just be what you need.&lt;/p&gt;

&lt;p&gt;You might be thinking: Okay, so code reviews are mainly a bookkeeping tool. Yes and no! They are &lt;strong&gt;way more powerful than that.&lt;/strong&gt; Keep reading to know why (mini-clickbait) 👇🏼!&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Code Reviews help with knowledge transfer.
&lt;/h2&gt;

&lt;p&gt;If you're reading this, you're probably the &lt;strong&gt;curious&lt;/strong&gt; type. Being curious in the tech industry usually means constantly looking for new &amp;amp; effective solutions to solve your everyday problems, or even trying to jump to &lt;em&gt;that new cool framework&lt;/em&gt; and going for a quick ride on the &lt;em&gt;hype&lt;/em&gt; train.&lt;/p&gt;

&lt;p&gt;What's better for that than being able to see what other &lt;em&gt;humans&lt;/em&gt; are doing? Code Reviews enable precisely this - the ability to peek into someone else's code to learn new stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 Code Reviews create a sense of shared responsibility.
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Continuously having to make decisions on your own&lt;/strong&gt; on a piece of code without any help, let alone a whole project is &lt;strong&gt;mentally draining &amp;amp; stressful&lt;/strong&gt;. By having others review your code, you'll be able to get some relief while knowing there'll be someone else there for you in times of need. &lt;del&gt;And that can be the start of a friendship that lasts forever.&lt;/del&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  👀 Code Reviews will improve code quality even when nobody is watching.
&lt;/h2&gt;

&lt;p&gt;You might be familiar with the "rubber duck debugging" technique, a concept introduced in &lt;em&gt;&lt;a href="https://pragprog.com/book/tpp20/the-pragmatic-programmer-20th-anniversary-edition"&gt;The Pragmatic Programmer&lt;/a&gt;&lt;/em&gt; book. Dave Thomas, the author, makes a case on how the mere act of &lt;strong&gt;explaining&lt;/strong&gt; code to a peer can help you debug a problem without any actual interaction needed — so we might as well be talking to a rubber duck 🦆.&lt;/p&gt;

&lt;p&gt;I like to think the same principle applies to Code Reviews as well. By writing code as if someone would review it (even it that doesn't happen), you're going to &lt;strong&gt;write better code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;*Rule of thumb:&lt;/strong&gt; Assume you always have a bunch of ducks around when writing and delivering code.*&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But the humans...?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ok, back to the main point! When you &lt;strong&gt;do&lt;/strong&gt; get your code reviewed by other humans:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You gain a better understanding&lt;/strong&gt; of your own decisions by being questioned over them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You will get useful contributions&lt;/strong&gt; that can help to fix bugs, to find new edge cases, and maybe even lead to rethinking a flawed architecture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You will learn from people&lt;/strong&gt; that might have more experience or insights about a particular area.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🤩 OMG Code reviews are so cool!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EWfgeAOx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.codegram.com/blog/an-ode-to-code-reviews/allthethings.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EWfgeAOx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.codegram.com/blog/an-ode-to-code-reviews/allthethings.png" alt=""&gt;&lt;/a&gt;&lt;small&gt;Code Review all the things!&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;...so &lt;strong&gt;why don't we do it more often&lt;/strong&gt;? Well, I think that's because coming up with an effective way to present &amp;amp; review code is &lt;strong&gt;hard by nature.&lt;/strong&gt; And because of that, some people see it as a burden and put it in the same box as &lt;em&gt;reading e-mails&lt;/em&gt; or &lt;em&gt;attending meetings&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let me introduce you to some advice on how Pull Requests need to be dealt with at the grass-roots level, and then we can talk about &lt;em&gt;team dynamics&lt;/em&gt;, which is a whole different thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  🦄 Here's how to step up your code reviewing game
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;There are three sides to every story: yours, mine &amp;amp; the truth.— &lt;em&gt;anonymous&lt;/em&gt;, but also the title of a &lt;a href="https://open.spotify.com/album/2TV8JqednqRKb2injBMYGd"&gt;rock album&lt;/a&gt; I really like&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  As an author, you should:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Be verbose and provide enough context:&lt;/strong&gt; A Pull Request needs to have a clear structure &amp;amp; description. More than &lt;em&gt;what&lt;/em&gt; and &lt;em&gt;how —&lt;/em&gt; which can often be guessed by the code itself — one must focus on the &lt;em&gt;Why&lt;/em&gt;. Why did you choose a particular path? Were you under a tight deadline and did you have to compromise? Whom does it affect? Does this affect any business logic?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write tests:&lt;/strong&gt; Tests are a great way to express the boundaries of a problem and provide specific examples of how the code behaves in real-life scenarios. Reviewers will appreciate having them gain a better understanding (and your customers probably will too, but that's another story)!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Checks, checks everywhere:&lt;/strong&gt; GitHub, GitLab, et al allow for automated checks such as linters, code coverage analysis, and others to be embedded just within your Pull Request. By doing that, we leave some low-value topics such as styling out of the conversation and let our dear reviewers focus on what's important.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get your Pull Request deployed somewhere&lt;/strong&gt; : Sometimes &lt;em&gt;seeing&lt;/em&gt; something is better than just reading about its internals. Using tools like &lt;a href="https://devcenter.heroku.com/articles/github-integration-review-apps"&gt;Heroku's Review Apps&lt;/a&gt; or &lt;a href="https://www.netlify.com/blog/2016/07/20/introducing-deploy-previews-in-netlify/"&gt;Netlify's Deploy Previews&lt;/a&gt; can be really helpful, providing a separate deployment &lt;em&gt;per Pull Request&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't let your Pull Requests block your progress&lt;/strong&gt; : Quality code reviews take some time and you don't want to rush people into accepting them just because they're blocking you. If you're being smart about it, you'll have come up with an architecture that will allow you to have &lt;strong&gt;multiple Pull Requests going on&lt;/strong&gt; without one depending on another. It takes some practice and it's not always possible, but it's definitely worth the effort!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't take criticism personally:&lt;/strong&gt; When getting your code reviewed, you might sometimes feel personally attacked. That feeling might come from a vulnerable position — &lt;em&gt;am I not smart enough?&lt;/em&gt; — or even from a defensive position — &lt;em&gt;they're over their head&lt;/em&gt;! Just keep in mind &lt;em&gt;you&lt;/em&gt; are not your &lt;em&gt;code.&lt;/em&gt; Take a breathe and remember: they're challenging &lt;strong&gt;your code, not you&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be cooperative:&lt;/strong&gt; Even if you think a reviewer's suggestion isn't &lt;em&gt;right&lt;/em&gt;, be cooperative and walk them along with &lt;em&gt;why&lt;/em&gt; you think that's the case. Dismissing another person's opinions just because isn't nice — think about how you'd want to be treated if the situation was reversed. Plus, if you think the issue lies in the reviewer not understanding the problem at hand, chances are you didn't provide enough context, to begin with.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  As a reviewer, you should:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Be empathetic:&lt;/strong&gt; Keep in mind a Pull Request done properly took a lot of effort. You'll get a way better conversation if you keep an upbeat, engaging tone in your comments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write thoughtful, unambiguous comments:&lt;/strong&gt; Tone is difficult to grasp on written communication. Be sure you don't leave space for ambiguity and that your writing is clear &amp;amp; concise while providing enough context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Suggest specific changes&lt;/strong&gt; : If you think something can be improved, don't just say so, suggest a specific change. But again, don't &lt;em&gt;just&lt;/em&gt; suggest a change, it can stike the other side as passive-aggressive. Take some time to explain &lt;em&gt;why&lt;/em&gt; you think something can be changed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't be judgmental:&lt;/strong&gt; There are lots of reasons why code doesn't look &lt;em&gt;the way you think it should look&lt;/em&gt;. Don't make judgments and try to understand why they came up with that particular solution. After all, you're both aiming at the same goal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you need it, download the code and run it:&lt;/strong&gt; Superficial reviews are not useful at all. It's a temptation you need to fight. If you need to, download the code and run it. It's fun!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beware of the impostor syndrome:&lt;/strong&gt; Have confidence in your feelings on the code and don't be afraid to start a discussion, even when reviewing more experienced developers' code. Also, comments on Code Reviews don't always need to be about suggestions - asking questions to gain better understanding of what's happening is perfectly fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be responsive:&lt;/strong&gt; When asking for changes, don't just leave and come back days after just to find your suggestions addressed in a couple of minutes. That's not nice. Just keep on top of what you review so everybody can get done with it!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🖖 Nice tips! Give me my CodeReviewMaster© shirt already.
&lt;/h2&gt;

&lt;p&gt;Well, wait a minute. These tips &amp;amp; tricks are really cool, but for these to work, &lt;strong&gt;Code Reviews need to actually &lt;em&gt;happen&lt;/em&gt;&lt;/strong&gt;. As it turns out, that isn't always that easy. It certainly isn't for us, being a consultancy that works in lots of different projects at the same time. Why is that?&lt;/p&gt;

&lt;p&gt;On one hand, &lt;strong&gt;when working within a really small team, getting quality code reviews can be hard:&lt;/strong&gt; Imagine you're working on a project and you're the only front-end developer. Who can review your outstanding &lt;em&gt;Vue.js&lt;/em&gt; code if there's no one else in the team that knows about it? You could always ask someone else outside of the team, but then, on the other hand, &lt;strong&gt;collaboration cross-project is just tedious.&lt;/strong&gt; Creating a &lt;code&gt;#code-reviews&lt;/code&gt; channel on Slack where everybody can go get their PRs reviewed looked like a nice idea at first, but doesn't really cut it. You can't possibly get valuable reviews out of them -- reviewers are missing a lot of context due to them not being actively involved on the project. Soon enough, the channel ends up being cluttered of unanswered cries for help and, eventually, people stop asking for reviews at all.&lt;/p&gt;

&lt;p&gt;One &lt;strong&gt;could reach the conclusion that Code Reviews can only happen in mid-sized teams and up&lt;/strong&gt; , and that collaborating outside of the team's boundaries is just a pipe dream. A sad reality to live in.&lt;/p&gt;

&lt;h2&gt;
  
  
  😓 So we're doomed. Back to writing code alone in the dark.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eK0RWsik--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.codegram.com/blog/an-ode-to-code-reviews/blanket.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eK0RWsik--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.codegram.com/blog/an-ode-to-code-reviews/blanket.png" alt=""&gt;&lt;/a&gt;&lt;small&gt;Coding alone with a blanket at night&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;Please don't close this tab yet! We've come up with ways to &lt;strong&gt;get your Code Reviews&lt;/strong&gt; &lt;em&gt;to be way more effective&lt;/em&gt;! Or at least, we think so 😏.&lt;/p&gt;

&lt;p&gt;We're about to change how we collaborate over code at Codegram and we expect this will lead to improved &lt;em&gt;team dynamics&lt;/em&gt; (see! I said we would talk about it). &lt;strong&gt;Code Reviews are about to be second-class citizens no longer&lt;/strong&gt;. Here's our plan:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Every developer working alone on a project or in an area will get a &lt;em&gt;review buddy&lt;/em&gt;&lt;/strong&gt; : A &lt;em&gt;review buddy&lt;/em&gt; might not need to be involved in the actual coding, but will be there to &lt;strong&gt;preventing PRs from becoming stale&lt;/strong&gt; with their helpful reviews. A &lt;em&gt;review buddy&lt;/em&gt; knows about the history of a project and thus understands all the decisions behind every step taken, leading to in-depth, spot-on appreciations. A &lt;em&gt;review buddy&lt;/em&gt; has no reason to ignore your PRs. A &lt;em&gt;review buddy&lt;/em&gt; is your best friend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developers can still ask someone else for help:&lt;/strong&gt; In the event that a developer and their &lt;em&gt;review buddy&lt;/em&gt; (I love this name) are stuck, they can always ask for help to someone else — since they won't receive a constant stream of impersonal review requests anymore, they'll appreciate being chosen for the task and be more willing to help. Note than one must &lt;strong&gt;keep the list of reviewers short&lt;/strong&gt; for this to work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;We'll leverage better tools:&lt;/strong&gt; We'll ditch that &lt;code&gt;#code-reviews&lt;/code&gt; channel on Slack and promote the use of other tools like &lt;a href="https://pullreminders.com/"&gt;Pull Reminders&lt;/a&gt; — a free &lt;em&gt;Slack&lt;/em&gt; integration that will keep in touch with every developer and make sure they follow up on their duties. In addition, using &lt;a href="https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners"&gt;GitHub's CODEOWNERS&lt;/a&gt; file in our projects will also help to streamline the process of &lt;em&gt;asking&lt;/em&gt; for Code Reviews in the first place.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's &lt;strong&gt;just three simple steps&lt;/strong&gt; but we expect them to have a high impact leading to &lt;em&gt;healthier reviews&lt;/em&gt;, &lt;em&gt;happier developers&lt;/em&gt;, and, in the end, &lt;em&gt;better software&lt;/em&gt;. Sometimes things are not that complicated!&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Collaboration doesn't stop on Code Reviews
&lt;/h2&gt;

&lt;p&gt;While we've seen Code Reviews are incredibly useful, they're &lt;strong&gt;not the one and only way to collaborate over code&lt;/strong&gt;. Sometimes you just need to do some pair programming - and that's an incredibly nice experience &lt;em&gt;when you really need it&lt;/em&gt;! At Codegram, we particularly like &lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare"&gt;Visual Studio Code's Live Share&lt;/a&gt;&lt;/strong&gt; feature and we use it quite a lot. Damn, it looks like &lt;em&gt;Microsoft&lt;/em&gt; is killing it these days.&lt;/p&gt;

&lt;p&gt;Finally, you should always keep in mind that everything said in this article &lt;strong&gt;can't make up for missing documentation or bad architecture&lt;/strong&gt;. More than that — clean, documented code leads to &lt;strong&gt;easier-to-deal-with&lt;/strong&gt; Code Reviews, and Code Reviews can help you &lt;strong&gt;keep your code clean &amp;amp; documented&lt;/strong&gt;. Use that power for good!&lt;/p&gt;

&lt;p&gt;&lt;small&gt;Did you seriously think there wouldn't be any Baby Yodas in this article?&lt;/small&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  👋 That'll be all!
&lt;/h2&gt;

&lt;p&gt;I hope you've enjoyed my humble views on the topic — with any luck it'll have inspired you to adopt some or all of these techniques and that'll help you and your team to be more collaborative. Or maybe you just think &lt;em&gt;this is bananas!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In any case, I'd love to hear your feedback — you can send us an e-mail to &lt;a href="//mailto:hello@codegram.com"&gt;hello@codegram.com&lt;/a&gt;, ping us on &lt;strong&gt;Twitter&lt;/strong&gt; at &lt;a href="https://twitter.com/codegram"&gt;@codegram&lt;/a&gt; or just yell at the programming gods!&lt;/p&gt;

</description>
      <category>codereviews</category>
      <category>teamwork</category>
      <category>developerproductivity</category>
    </item>
    <item>
      <title>Adopting the JAMStack: Building CMS-backed static websites with Vue or React</title>
      <dc:creator>Josep Jaume Rey</dc:creator>
      <pubDate>Mon, 12 Aug 2019 13:59:01 +0000</pubDate>
      <link>https://forem.com/codegram/adopting-the-jamstack-building-cms-backed-static-websites-with-vue-or-react-480l</link>
      <guid>https://forem.com/codegram/adopting-the-jamstack-building-cms-backed-static-websites-with-vue-or-react-480l</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://www.codegram.com/blog/a-jamstack-journey-headless-content-management-with-vue-react" rel="noopener noreferrer"&gt;Codegram's blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;This post's title could also be called &lt;em&gt;forget about Wordpress and Drupal&lt;/em&gt; but after a bit of thinking I thought it wouldn't be a fair comparison since they're also really good tools. But in a way, it would be. Well, keep reading to find out why!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hello! So if you're here, you've probably heard about the &lt;strong&gt;JAMStack&lt;/strong&gt; already, or you're curious about it. &lt;em&gt;Cool cool cool&lt;/em&gt;. I was too - hopefully, this post will probably save you some time if you're looking to get started into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the JAMStack?
&lt;/h2&gt;

&lt;p&gt;The word &lt;strong&gt;JAMStack&lt;/strong&gt; started being used just a few years ago. It stands for &lt;em&gt;JavaScript, APIs, Markup&lt;/em&gt; as stated on their &lt;a href="https://jamstack.org/" rel="noopener noreferrer"&gt;official website&lt;/a&gt;. It's not about specific languages or technologies, but rather an abstract definition of a runtime &amp;amp; deployment chain.&lt;/p&gt;

&lt;p&gt;The term was coined by &lt;strong&gt;Netlify&lt;/strong&gt; - but the tools &amp;amp; concepts behind it have been there for a long time. It just turns out that when presented together, they pack a lot of punch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Statically generated&lt;/strong&gt; sites&lt;/li&gt;
&lt;li&gt;Using the latest &lt;strong&gt;JavaScript frameworks&lt;/strong&gt; &amp;amp; libraries&lt;/li&gt;
&lt;li&gt;Leveraging &lt;strong&gt;APIs&lt;/strong&gt; (REST, GraphQL, or anything else)&lt;/li&gt;
&lt;li&gt;Deploying to a &lt;strong&gt;CDN&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atomic&lt;/strong&gt; deployments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated&lt;/strong&gt; deployments via WebHooks&lt;/li&gt;
&lt;li&gt;Plays really nice with &lt;strong&gt;Serverless&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The benefits it provides are generous:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unbeatable Time To First Byte&lt;/strong&gt; : Since we'll be using CDNs to serve our whole request cycle, the time spent by the browser trying to get our first bytes of information is only limited by the CDN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-time deployments:&lt;/strong&gt; There's no boot time associated with deployments, which means new deploys or rollbacks are instantaneous.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; The surface area for attack is greatly reduced, as most of our requests are now served by battle-tested CDNs that don't have direct contact with our APIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simpler model&lt;/strong&gt; : JAMStack's is a nice breeze of air in a world dominated by Docker, Kubernetes, Buildpacks &amp;amp; such.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Straightforward scalability:&lt;/strong&gt; If your website isn't using APIs at run-time (the website is entirely statically built), you'll have the certainty your website can't go down because of a huge spike in traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decoupling presentation from data&lt;/strong&gt; : By separating the data source from the actual application, we get a greater choice of technologies. While this is true for many SPA, going the JAMStack way forces you, which is RealGood™️.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  No doubt, no doubt. Should I use it?
&lt;/h2&gt;

&lt;p&gt;As most technologies, the JAMStack is not for everyone. But it certainly is the right tool for you if you're building:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A website that's mostly public, &lt;strong&gt;backed by a server-side CMS&lt;/strong&gt; (say WordPress, Drupal, Joomla...).&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Single Page&lt;/strong&gt; Application&lt;/li&gt;
&lt;li&gt;Any kind of typical &lt;strong&gt;monolithic application&lt;/strong&gt; that has a lot more reads than writes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It might have other use cases, but at the moment these are the scenarios where I've felt myself most comfortable using it. And I'm &lt;em&gt;really&lt;/em&gt; loving it.&lt;/p&gt;

&lt;p&gt;A good use case would be &lt;a href="https://www.smashingmagazine.com/" rel="noopener noreferrer"&gt;Smashing Magazine&lt;/a&gt;: they're &lt;a href="https://www.smashingmagazine.com/2017/03/a-little-surprise-is-waiting-for-you-here/" rel="noopener noreferrer"&gt;running on the JAMStack&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  How does the developer experience look like?
&lt;/h2&gt;

&lt;p&gt;I've previously said one of the huge selling points of the &lt;strong&gt;JAMStack&lt;/strong&gt; is the developer experience. Here's how a regular development day will look you if you &lt;em&gt;embrace the JAMStack:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You write your website in your favorite technology: &lt;strong&gt;Vue, React&lt;/strong&gt; , or even plain &lt;strong&gt;HTML/JS/CSS&lt;/strong&gt; - in practice, you'll use some of the build tools I'll talk about later on. You tie its rendering to some external API's data, namely a &lt;strong&gt;Headless CMS&lt;/strong&gt; (I'll talk about it after a bit too!)&lt;/li&gt;
&lt;li&gt;You &lt;strong&gt;push&lt;/strong&gt; your website to your favorite &lt;strong&gt;Git&lt;/strong&gt; provider: GitHub, BitBucket, etc.&lt;/li&gt;
&lt;li&gt;During your deployment, your website fetches all the needed data from your APIs and gets &lt;strong&gt;statically built&lt;/strong&gt; , generating a bunch of HTML, JS &amp;amp; CSS in the way.&lt;/li&gt;
&lt;li&gt;Your site gets published to a &lt;strong&gt;CDN&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Users visit your website and get served static data &lt;em&gt;all the way along&lt;/em&gt;, so you don't have to worry about scaling your APIs - the data is embedded in your markup.&lt;/li&gt;
&lt;li&gt;When your content changes on your source of data, a &lt;strong&gt;webhook&lt;/strong&gt; gets fired, rebuilding and redeploying the whole website.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can probably already see how all this plays extremely nice with automation tools like &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;GitHub actions&lt;/a&gt; or even &lt;a href="https://zapier.com" rel="noopener noreferrer"&gt;Zapier&lt;/a&gt;. Huge win!&lt;/p&gt;

&lt;h2&gt;
  
  
  Sold. How can I start using it today?
&lt;/h2&gt;

&lt;p&gt;I'm sure there's a lot more tools and services I'm missing, but here's a compilation of the ones I've had experience using and I can actually recommend!&lt;/p&gt;

&lt;h3&gt;
  
  
  Web application frameworks
&lt;/h3&gt;

&lt;p&gt;The first step in building our JAMStack-enabled site will be selecting our framework-of-choice.&lt;/p&gt;

&lt;h4&gt;
  
  
  Gatsby
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.gatsbyjs.org/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; is one of the most ambitious projects to support the &lt;strong&gt;JAMStack&lt;/strong&gt;. Built with React, it allows embedding nearly any kind of data source into their internal GraphQL database for you to query. All the queried data will get statically built into the templates, making it blazing fast!&lt;/p&gt;

&lt;p&gt;In my experience, working with their GraphQL api can be a bit cumbersome and somehow limited, especially when it comes to relational data or other complex queries, but my experience is limited and a bit outdated - this might have changed on the last few months. That said, it's a great project with outstanding innovations like automatic responsive images, PWA support out of the box, and more.&lt;/p&gt;

&lt;h4&gt;
  
  
  Gridsome
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://gridsome.org/" rel="noopener noreferrer"&gt;Gridsome&lt;/a&gt; is a newcomer and the Vue equivalent (&lt;em&gt;equivualent&lt;/em&gt;?) to Gatsby. Still in its early stages, it looks really promising.&lt;/p&gt;

&lt;p&gt;While it lacks the bigger ecosystem &lt;strong&gt;Gatsby&lt;/strong&gt; has, it has picked up on their latest features and improved on them, and I personally expect it to move quite fast. Their documentation is getting better every day.&lt;/p&gt;

&lt;p&gt;We've build the website for &lt;a href="https://2019.fullstackfest.com" rel="noopener noreferrer"&gt;Full Stack Fest 2019&lt;/a&gt; with it, and it's been great. Just check out how fast it is!&lt;/p&gt;

&lt;h4&gt;
  
  
  Nuxt.js
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://nuxtjs.org/" rel="noopener noreferrer"&gt;Nuxt&lt;/a&gt; is the dominant framework when it comes to building web applications with &lt;strong&gt;Vue.js&lt;/strong&gt;. Inspired by &lt;strong&gt;Next.js&lt;/strong&gt; (its counterpart in the React world), it provides a statically generated mode that will embed the data used in your pages in your HTML templates.&lt;/p&gt;

&lt;p&gt;There's only one gotcha: Calls to the original data API will still happen on page transitions. It looks like they're &lt;a href="https://github.com/nuxt/rfcs/issues/22" rel="noopener noreferrer"&gt;working on it&lt;/a&gt; and they're conscious of their limitations, based on our recent &lt;a href="https://twitter.com/josepjaume/status/1093473712588894209" rel="noopener noreferrer"&gt;tweet exchange&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Nuxt has great support for i18n and a big ecosystem. Worth checking it out!&lt;/p&gt;

&lt;h3&gt;
  
  
  Headless CMSs
&lt;/h3&gt;

&lt;p&gt;The big eye-opener for me has been finding out that I can definitely &lt;strong&gt;delegate the CMS&lt;/strong&gt; to an external provider. While some use cases are calling out for a tailored backend, most use cases are simple enough that can configured via a UI. Nobody likes having to reinvent the wheel over and over!&lt;/p&gt;

&lt;p&gt;There's many of them, but I'll only describe the ones I have actually tried in production.&lt;/p&gt;

&lt;h4&gt;
  
  
  Contentful
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.contentful.com/" rel="noopener noreferrer"&gt;Contentful&lt;/a&gt; is undoubtedly the biggest player out there and has recently received a &lt;em&gt;33.5M$&lt;/em&gt; funding round, so it isn't going anywhere.&lt;/p&gt;

&lt;p&gt;Its backend is quite simple and flexible to most use cases, including support for I18n fields, content relationships, a rich HTML content editor, and more. However, it's unexpectedly expensive. They have a free plan that might work for most use cases, though.&lt;/p&gt;

&lt;p&gt;Their data is exposed via a REST API, but they have a GraphQL one on bigger plans though.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prismic
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://prismic.io/" rel="noopener noreferrer"&gt;Prismic&lt;/a&gt; has an outstanding UI and user experience. It has support for I18n documents, associations, responsive images, and many kinds of fields. They also have tools for working for the major JS frameworks, a great querying API, and more. They're &lt;a href="https://prismic.io/blog/graphql-api-alpha-release" rel="noopener noreferrer"&gt;working on a GraphQL API&lt;/a&gt; as well which will be hopefully available to the public soon!&lt;/p&gt;

&lt;p&gt;My experience working with them is pretty extensive and so far their response times have always been &lt;strong&gt;steady&lt;/strong&gt; and &lt;strong&gt;reliable&lt;/strong&gt; (which is one of the core things you're looking for when delegating your content to an external platform). Worth checking them out!&lt;/p&gt;

&lt;h3&gt;
  
  
  Deployment platforms
&lt;/h3&gt;

&lt;p&gt;I'm sure there's plenty of options out there to deploying static content, but I'll list just what I can recommend:&lt;/p&gt;

&lt;h4&gt;
  
  
  Netlify
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt; it's just perfect for the &lt;strong&gt;JAMStack&lt;/strong&gt; — notably, their CEO came up with the term — so expect it to support everything they need and more, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cached, automatic builds&lt;/li&gt;
&lt;li&gt;Deployment previews, sync'd with GitHub's PRs&lt;/li&gt;
&lt;li&gt;A/B testing&lt;/li&gt;
&lt;li&gt;Support for Serverless functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My experience using Netlify has been amazing from moment one. Did I mention they're free for individual plans?&lt;/p&gt;

&lt;p&gt;No, I'm not working for them or nor do I have any kind of agreement. I just love it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Your CI of choice + S3 + [CloudFront|CloudFlare|.*]
&lt;/h4&gt;

&lt;p&gt;As in the end you're only deploying static sites, using your own &lt;strong&gt;CI&lt;/strong&gt; to lint &amp;amp; build and then deploy to AWS S3 or similar is &lt;strong&gt;perfectly fine&lt;/strong&gt;. You will just have to write part of the pipeline; rollbacks, deploy previews, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My recommendation&lt;/strong&gt; : If you want to leverage your own CDN, just back it with &lt;strong&gt;Netlify&lt;/strong&gt; 👌&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fua613dwhoti9kakz1id2.gif" 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%2Fua613dwhoti9kakz1id2.gif"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Giving you some time to rest and let it sink&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that I've learned working with the JAMStack
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Rebuilding after every change is totally fine
&lt;/h3&gt;

&lt;p&gt;If your website isn't incredibly dynamic by nature, rebuilding after every change is perfectly fine: you're &lt;strong&gt;consuming CPU time in advance&lt;/strong&gt; in exchange of saving the &lt;strong&gt;time spent on the runtime by your server mangling with html strings&lt;/strong&gt;. Isn't that a great tradeoff? After all, aren't we throwing thousands of hours into our CIs already anyway? As an example, we have a &lt;strong&gt;webhook&lt;/strong&gt; that rebuilds our &lt;a href="https://2019.fullstackfest.com" rel="noopener noreferrer"&gt;Full Stack Fest 2019&lt;/a&gt; website every time a podcast episode gets published. Working with client projects, we set it up so the whole site gets rebuilt every time a news article gets published (which happens several times a day).&lt;/p&gt;

&lt;h3&gt;
  
  
  Highly dynamic content can also be served
&lt;/h3&gt;

&lt;p&gt;If some of your content is highly dynamic, there's nothing wrong with it — you can always resort to consuming an external API on runtime. This is the case for comments, for example. Gridsome, Nuxt &amp;amp; co allows you to defer the rendering of part of your component tree to the client. This is actually great for UX - the user gets server-side content as soon as possible, while the rest of the page gets load asynchronously. This also works for admin panels, private user areas &amp;amp; more!&lt;/p&gt;

&lt;h3&gt;
  
  
  It's nice having your HTML back
&lt;/h3&gt;

&lt;p&gt;Having your application boil down to a bunch of static files kind of reminds you how the web was in the GoodOldDays™️. This enables new possibilities like &lt;strong&gt;Progressive Web Applications&lt;/strong&gt; , publishing to the &lt;strong&gt;P2P web&lt;/strong&gt; (see &lt;a href="https://beakerbrowser.com/" rel="noopener noreferrer"&gt;Beaker&lt;/a&gt; and DAT) &amp;amp; more!&lt;/p&gt;

&lt;h3&gt;
  
  
  It helps with SEO
&lt;/h3&gt;

&lt;p&gt;While sometimes a limitation, not being able to dynamically change your served content depending on the client's headers (see I18n) forces you down a path that actually helps with SEO. That, and the fact that the content gets served blazingly fast, adds up to a &lt;strong&gt;happy google bot&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  I want moar
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Pheeew, that was quite a brain dump!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're eager to learning more about the JAMStack, here's some great resources to learn from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;a href="https://2019.fullstackfest.com/" rel="noopener noreferrer"&gt;Full Stack Fest 2019&lt;/a&gt; conference (which we happen to organize at &lt;a href="https://codegram.com" rel="noopener noreferrer"&gt;Codegram&lt;/a&gt;) features &lt;strong&gt;Brian Douglas&lt;/strong&gt; , one of the original proponents of the JAMStack and he's also the host of the &lt;a href="https://www.heavybit.com/library/podcasts/jamstack-radio/" rel="noopener noreferrer"&gt;JAMStack radio podcast&lt;/a&gt;. Boom, shameless plug!&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://netlify.curated.co/" rel="noopener noreferrer"&gt;JAMStack Newsletter&lt;/a&gt;: A newsletter about the JAMStack curated by Netlify.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/automata/awesome-jamstack" rel="noopener noreferrer"&gt;Awesome JAMStack&lt;/a&gt;: A compilation of resources following the &lt;em&gt;awesome-&lt;/em&gt;* repo series.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other resources&lt;/strong&gt; : The &lt;a href="https://jamstack.org/resources/" rel="noopener noreferrer"&gt;JAMStack website&lt;/a&gt; features other resources like talks and articles about it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading this and I hope it will help you get started into the &lt;strong&gt;JAMStack&lt;/strong&gt; world!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Looking for someone to help you build your next project on the **JAMStack&lt;/em&gt;&lt;em&gt;? Throw us a line at &lt;a href="//mailto:hello@codegram.com"&gt;hello@codegram.com&lt;/a&gt; and we'll be glad to help you!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>jamstack</category>
      <category>vue</category>
      <category>gridsome</category>
      <category>gatsby</category>
    </item>
  </channel>
</rss>
