<?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: Brandon Marrero 🇺🇸</title>
    <description>The latest articles on DEV Community by Brandon Marrero 🇺🇸 (@branmar97).</description>
    <link>https://dev.to/branmar97</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%2F458420%2F3b90c9c3-b515-4503-8632-c7c8563ea1d1.jpg</url>
      <title>DEV Community: Brandon Marrero 🇺🇸</title>
      <link>https://dev.to/branmar97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/branmar97"/>
    <language>en</language>
    <item>
      <title>Basic React Hooks: useState, useEffect, and useContext</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Mon, 10 May 2021 15:46:23 +0000</pubDate>
      <link>https://dev.to/branmar97/basic-react-hooks-usestate-useeffect-and-usecontext-3o2h</link>
      <guid>https://dev.to/branmar97/basic-react-hooks-usestate-useeffect-and-usecontext-3o2h</guid>
      <description>&lt;p&gt;Hooks allow use of special React functions without class components. They can be used to maintain state, update data, grab HTML elements, and more.&lt;/p&gt;

&lt;p&gt;In this blog post, we will cover why Hooks are necessary and the main ones you need to know.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Before &lt;a href="https://reactjs.org/docs/hooks-intro.html"&gt;Hooks&lt;/a&gt;, class components were required to take advantage of special React functions (state, lifecycle methods, etc). &lt;/p&gt;

&lt;p&gt;The problem is that class components require much more boilerplate, making them difficult to read and update.&lt;/p&gt;

&lt;h3&gt;
  
  
  Class Component
&lt;/h3&gt;

&lt;p&gt;Must have a &lt;code&gt;constructor&lt;/code&gt; and call &lt;code&gt;this.state&lt;/code&gt; to access a piece of state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    }
  }

  render() {
    return (
      &amp;lt;div&amp;gt;
        {this.state.count}
      &amp;lt;/div&amp;gt;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Functional Equivalent
&lt;/h3&gt;

&lt;p&gt;Creates the equivalent of the above component in just a few lines. It does not require use of the &lt;code&gt;this&lt;/code&gt; keyword to access state and is much easier to read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
   const [count] = useState(0);

   return &amp;lt;div&amp;gt;{count}&amp;lt;/div&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we dive into the 3 basic React Hooks, there are two important rules to remember. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You &lt;strong&gt;must import any hooks&lt;/strong&gt; that you use&lt;/li&gt;
&lt;li&gt;Hooks &lt;strong&gt;can only be called at the top level&lt;/strong&gt; of your functional components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is what those rules look like in practice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react'

function App() {
   const [count] = useState(0)

   const multiplyCount = () =&amp;gt; {
      return count * 2
   }

   return &amp;lt;div&amp;gt;{count}&amp;lt;/div&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's take a look at the 3 main &lt;a href="https://reactjs.org/docs/hooks-intro.html"&gt;Hooks&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  useState()
&lt;/h2&gt;

&lt;p&gt;This hook is called to add local state to a component. It returns a pair with the current value and a function to update that value. The value initially passed to &lt;code&gt;useState()&lt;/code&gt; is display on the first render. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;useState()&lt;/code&gt; provides more flexibility than &lt;code&gt;this.state&lt;/code&gt; because state can be either an object or regular value. It can also be accessed and changed based on variable names you define.&lt;/p&gt;

&lt;p&gt;When state changes, React will automatically update the UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function VisitorCount() {
   count [count, setCount] = useState(0)

   return (
      &amp;lt;div&amp;gt;
         &amp;lt;p&amp;gt;{count} Visitors&amp;lt;/p&amp;gt;
         &amp;lt;button 
            onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
            Increment
         &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  useEffect()
&lt;/h2&gt;

&lt;p&gt;In class components, we have access to &lt;a href="https://www.w3schools.com/react/react_lifecycle.asp"&gt;lifecycle methods&lt;/a&gt;, such as, &lt;code&gt;componentDidMount()&lt;/code&gt;, &lt;code&gt;componentDidUpdate()&lt;/code&gt; and &lt;code&gt;componentWillUnmount()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentdidMount() {
   // The component has initialized
}

componentDidUpdate() {
   // The component state has changed
}

componentWillUnmount() {
   // The component is destroyed 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the &lt;code&gt;useEffect()&lt;/code&gt; hook, all of these are unified under one function. &lt;/p&gt;

&lt;p&gt;It accepts a function as its first argument and runs once on initialization, and again after each state change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
 console.log('Hello World!')
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Call When Updated
&lt;/h4&gt;

&lt;p&gt;You may want to only run a function on initialization, or if a specific piece of state changes. &lt;/p&gt;

&lt;p&gt;To do this, pass an array as a second argument to &lt;code&gt;useEffect()&lt;/code&gt;. This is called the dependencies array.&lt;/p&gt;

&lt;p&gt;An empty array will cause the function to run on the first render, and an array with state added will only call the function when that state is updated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(
   () =&amp;gt; {
      fetch('http://localhost:3000/data')
      .then(response =&amp;gt; {
         console.log(response.json())
      })
   {,
   [count] // function called when count is updated
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the function will only be called when &lt;code&gt;count&lt;/code&gt; has changed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Call When Destroyed
&lt;/h4&gt;

&lt;p&gt;To call a function before a component is removed from the UI, simply return a function within &lt;code&gt;useEffect()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
   console.log('Hello!')

   return () =&amp;gt; console.log('Bye Felicia!')
   },
   []
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  useContext()
&lt;/h2&gt;

&lt;p&gt;In React, data is shared one-way by passing &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;props&lt;/a&gt; down the component tree. &lt;/p&gt;

&lt;p&gt;Passing data from the top of the tree to the third level requires passing props to two components. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xnAyza9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8xm3dn7jgk2hzhkuq4ic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xnAyza9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8xm3dn7jgk2hzhkuq4ic.png" alt="Data Flow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useContext()&lt;/code&gt; simplifies this process by allowing props to be shared anywhere in a component tree. &lt;/p&gt;

&lt;h4&gt;
  
  
  Creating Context
&lt;/h4&gt;

&lt;p&gt;To create context, we pass an object to &lt;code&gt;useContext()&lt;/code&gt;, then create a provider to make this object accessible throughout the tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const hunger = {
   hungry: 'You are hungry',
   full: 'You feel full',
}

const HungerContext = createContext(hunger)

function App(props) {

   return (
      &amp;lt;HungerContext.Provider value={hunger.full} &amp;gt;
         &amp;lt;Hungry /&amp;gt;
      &amp;lt;/HungerContext.Provider&amp;gt; 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the hunger value can be carried down without passing props between child components.&lt;/p&gt;

&lt;h4&gt;
  
  
  Accessing Context
&lt;/h4&gt;

&lt;p&gt;We also utilize the &lt;code&gt;useContext()&lt;/code&gt; hook to access any context we create, no matter where the component is in the tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Hungry() {
   const hunger = useContext(HungerContext)

   return &amp;lt;p&amp;gt;{hunger}&amp;lt;/p&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This component will display the provided hunger value, and update whenever that value changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks for reading my blog post. I hope this post helped you understand the basic React Hooks. &lt;/p&gt;

&lt;p&gt;I will be touching more on these hooks in future posts covering functional components.&lt;/p&gt;

&lt;p&gt;To learn more about React Hooks, checkout the &lt;a href="https://reactjs.org/docs/hooks-overview.html"&gt;official docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding How React Works: A Beginner's Guide</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Tue, 27 Apr 2021 17:44:37 +0000</pubDate>
      <link>https://dev.to/branmar97/understanding-how-react-works-a-beginner-s-guide-5f0l</link>
      <guid>https://dev.to/branmar97/understanding-how-react-works-a-beginner-s-guide-5f0l</guid>
      <description>&lt;p&gt;Are you thinking about learning React to build your next web application, but do not understand how it works? &lt;/p&gt;

&lt;p&gt;After reading this brief post, you will have a basic understanding of the React flow to get you headed in the right direction. Your React journey starts here.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is React?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; is a front-end JavaScript library that helps developers quickly build dynamic user interfaces. In an MVC application (Model View Controller), React is the view layer, which is what the user can see and interact with. The view layer can update without reloading the webpage when changes are made.&lt;br&gt;
It has a component architecture that allows reusable code which can be rendered anywhere.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is the format?
&lt;/h2&gt;

&lt;p&gt;Using declarative programming, React makes code easy to read and debug. Declarative programming expresses the logic without displaying all the instructions happening in the background. &lt;/p&gt;

&lt;p&gt;Let me break that down...&lt;/p&gt;

&lt;p&gt;A declarative view is like a customer ordering a cake from a bakery. The customer explains how they expect the cake to look and the baker makes it without specific instructions from the customer. This is declarative programming in a nutshell.&lt;/p&gt;

&lt;p&gt;Here is a code sample.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
     return (
          &amp;lt;div className="app"&amp;gt;
               &amp;lt;Nav /&amp;gt;
               &amp;lt;Home /&amp;gt;
               &amp;lt;Footer /&amp;gt;
          &amp;lt;/div&amp;gt;
     );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What can we expect from this output? We are rendering a navigation bar, home screen, and footer. &lt;/p&gt;

&lt;p&gt;You may also notice what looks like an HTML element (div), but this is actually &lt;a href="https://reactjs.org/docs/introducing-jsx.html" rel="noopener noreferrer"&gt;JSX&lt;/a&gt;, a React element or extension of JavaScript. The JSX is compiled by Babel into regular JavaScript.&lt;/p&gt;

&lt;p&gt;This is another example of declarative programming. We specify a React Element, which then gets compiled into JavaScript which creates and appends the HTML element to the DOM. &lt;/p&gt;

&lt;p&gt;Read more on JSX &lt;a href="https://reactjs.org/docs/introducing-jsx.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are components?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/components-and-props.html" rel="noopener noreferrer"&gt;Components&lt;/a&gt; are parts that represent pieces of the user interface. Going back to the previous example regarding declarative programming, the components were Nav, Home, and Footer. &lt;/p&gt;

&lt;p&gt;These components are children of the root component, typically called the App component. Combining all the components together makes an application. &lt;/p&gt;

&lt;p&gt;Components are also reusable with different properties. As data changes, a component can update the information and styling.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does React flow?
&lt;/h2&gt;

&lt;p&gt;In React, data flows in one direction, top to bottom. This allows for predictable and maintainable code. Data is passed down from the parent component in the form of &lt;a href="https://reactjs.org/docs/components-and-props.html#gatsby-focus-wrapper" rel="noopener noreferrer"&gt;props&lt;/a&gt;. The data can be used in other forms or passed further down the component tree.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm17ji4j257qh9m6tfjg0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm17ji4j257qh9m6tfjg0.png" alt="Component Flow Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each component has its own &lt;a href="https://reactjs.org/docs/faq-state.html#gatsby-focus-wrapper" rel="noopener noreferrer"&gt;state&lt;/a&gt;, similar to props but private. It stores property values that belong to a component. Property values can be changed using a method called &lt;code&gt;setState()&lt;/code&gt;. By default, a component will re-render when state is changed.&lt;/p&gt;

&lt;p&gt;Using state and props together allows breaking down of components based on specific behaviors. Let's say a &lt;code&gt;PlantsContainer&lt;/code&gt; has a state property with a list of plants. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;PlantsForm&lt;/code&gt; component would render a form for adding new plants and a &lt;code&gt;Plants&lt;/code&gt; component might render the list of plants to the user interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks for reading my blog post. I hope this post helped you understand the basics of React. If it still seems overwhelming, React can be broken down into 4 key concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;JSX&lt;/li&gt;
&lt;li&gt;State&lt;/li&gt;
&lt;li&gt;Props&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will be touching more on these concepts in future posts.&lt;/p&gt;

&lt;p&gt;To learn more about React, I recommend referencing the &lt;a href="https://reactjs.org/docs/getting-started.html" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Asynchronous Redux using Redux Thunk</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Sun, 11 Apr 2021 23:20:41 +0000</pubDate>
      <link>https://dev.to/branmar97/asynchronous-redux-using-redux-thunk-1fij</link>
      <guid>https://dev.to/branmar97/asynchronous-redux-using-redux-thunk-1fij</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WMHUONcg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3psu9opx7qovkdh4dkx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WMHUONcg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3psu9opx7qovkdh4dkx8.png" alt="Redux Thunk Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/reduxjs/redux"&gt;Redux&lt;/a&gt; is a great tool for managing state in large scale applications. It has a single state container called the store, which can be managed using actions and reducers. With Redux, your state is accessible throughout your application tree using dispatchers. &lt;/p&gt;

&lt;p&gt;Most applications are making at least one API call, and unfortunately, Redux is not setup for this outside of the box. This is because action creators cannot return functions and is synchronous by default. &lt;a href="https://github.com/reduxjs/redux-thunk"&gt;Redux Thunk&lt;/a&gt; was created by Dan Abramov to fill this gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;This post assumes you have some basic knowledge of React and Redux. I do not explain the finer details of Redux, such as mapping state and dispatch. For a great introduction to Redux, checkout this &lt;a href="https://redux.js.org/tutorials/essentials/part-1-overview-concepts"&gt;tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Redux Thunk?
&lt;/h2&gt;

&lt;p&gt;In Redux, action creators are expected to return objects. However, using Redux Thunk allows us to pass functions within our action creators to create an asynchronous Redux.&lt;/p&gt;

&lt;p&gt;This means that Redux Thunk can be used to make API requests, delay a dispatch, or set dispatch conditions. Essentially, it provides full control over the dispatch method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;In my opinion, the best way to learn how Redux Thunk works is to see it in action. View the example below with very concise explanations.&lt;/p&gt;

&lt;p&gt;Install the &lt;code&gt;redux-thunk&lt;/code&gt; package by typing &lt;code&gt;npm install redux-thunk&lt;/code&gt; in your terminal.&lt;/p&gt;

&lt;p&gt;Then you need to import &lt;code&gt;applyMiddleware&lt;/code&gt; from redux and &lt;code&gt;thunk&lt;/code&gt; from redux-thunk. The &lt;code&gt;applyMiddleware()&lt;/code&gt; method will be the second argument to your &lt;code&gt;createStore()&lt;/code&gt; method. &lt;/p&gt;

&lt;p&gt;Pass in thunk as your argument for &lt;code&gt;applyMiddleware()&lt;/code&gt;. It should look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;createStore(rootReducer, applyMiddleware(thunk));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, build your new action creator. In this example, we are making a fetch request to an API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const fetchFromApi = () =&amp;gt; {
    return dispatch =&amp;gt; {
        fetch('http://localhost:3001/data')
        .then(response =&amp;gt; {
          return response.json()
        })
        .then(responseJSON =&amp;gt; {
          dispatch({ type: 'GET_DATA', data: responseJSON })
        })
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How Does It Work?
&lt;/h2&gt;

&lt;p&gt;In this scenario we are calling our action creator within the &lt;code&gt;componentDidMount()&lt;/code&gt; method of a React component. The action creator becomes available as a prop here. &lt;/p&gt;

&lt;p&gt;If you want more information about mapping props see the documentation &lt;a href="https://react-redux.js.org/using-react-redux/connect-mapdispatch"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once the component mounts, the &lt;code&gt;fetchFromApi()&lt;/code&gt; action is called. This action contains a function with a fetch request to our API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentDidMount() {
        this.props.fetchFromApi()
}    
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Redux Thunk then calls this function. The application is still functional while the request is working in the background without the user needing to wait for the promise to resolve.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return dispatch =&amp;gt; {
    fetch(`http://localhost:3001/data`)
    .then(response =&amp;gt; {
      return response.json()
    })
    .then(responseJSON =&amp;gt; {
      dispatch({ type: 'GET_DATA', data: responseJSON })
    })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the promise has resolved, the response is returned. In this case, we convert the response to a readable JSON format using the &lt;code&gt;json()&lt;/code&gt; method provided by native JavaScript. The converted response is then dispatched to a reducer where the store is updated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dispatch({ type: 'GET_DATA', data: responseJSON })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the store is updated the component is reloaded. If everything is set up correctly, the new data should be available via the store.&lt;/p&gt;

&lt;p&gt;Ta-Da! You can now make asynchronous action creators within your React application.&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React/Rails Final Bootcamp Project</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Wed, 24 Mar 2021 00:58:40 +0000</pubDate>
      <link>https://dev.to/branmar97/react-rails-final-bootcamp-project-381a</link>
      <guid>https://dev.to/branmar97/react-rails-final-bootcamp-project-381a</guid>
      <description>&lt;p&gt;For my final project at Flatiron School, I chose to build a web application around one of my favorite video games, Apex Legends. It is a matchmaking application where players can find teammates to add to their squad. The concept is simple. A player can create, view and request to join lobbies. &lt;/p&gt;

&lt;p&gt;Lobbies display the gamertag of the host, as well as the gamemode, relative time, platform, requirements, region, and players interested. Currently, lobbies and requests can only be created, not updated or deleted. &lt;/p&gt;

&lt;p&gt;I plan on adding more functionality in the future versions, including, authentication, profile pages, and realtime game stats. For now, players are limited to create and view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rails API
&lt;/h2&gt;

&lt;p&gt;The backend uses &lt;a href="https://rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt; as an API. This section was fairly simple to build. I needed Rack CORS Middleware to handle my HTTP requests from the React Frontend, and the &lt;a href="https://rubygems.org/gems/fast_jsonapi/"&gt;fast_jsonapi&lt;/a&gt; gem to filter my JSON rendering. Once my models were setup, I then created the routes for the requests. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U2jOPz9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/b2306f88d7ff1491fd6a1bae90e5742d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U2jOPz9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/b2306f88d7ff1491fd6a1bae90e5742d.png" alt="Lobbies Backend"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial Design
&lt;/h2&gt;

&lt;p&gt;Before doing anything with my frontend, I created a web design using Figma. I needed a sense of direction, and having this reference was a huge benefit when getting to the ReactJS portion of the project. I had a very good idea about how many components I would need and how things would be styled. I even downloaded fonts for my theme. &lt;/p&gt;

&lt;p&gt;Here is my design:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Yqd_xJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/8d764a18299466354b0f96d5643af55f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Yqd_xJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/8d764a18299466354b0f96d5643af55f.jpg" alt="Initial Web Design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ReactJS
&lt;/h2&gt;

&lt;p&gt;My frontend utilized the ReactJS framework. I used 'create-react-app' to jumpstart my process. There were many more moving parts for this section, especially for the initial setup. There are 2 containers and 10 components in the current state. I used a variety of packages, including, &lt;a href="https://www.npmjs.com/package/react-redux"&gt;react-redux&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/react-router-dom"&gt;react-router-dom&lt;/a&gt;, and &lt;a href="https://www.npmjs.com/package/tailwindcss"&gt;tailwindcss&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  React Redux
&lt;/h3&gt;

&lt;p&gt;Redux allows your application to read data from a store, or global state. Actions can be dispatched to the store to update the data.&lt;/p&gt;

&lt;p&gt;This was my first time configuring Redux for an application of this scale. There I hit quite a few roadblocks, and had to reference lots of material to fully understand the setup. After reviewing, I decided to split store, actions and reducers into separate files. Each model has its own reducers and actions file. This made everything easy to read and update later. Whenever I needed a particular action for a component, I imported the function from actions file.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Router
&lt;/h3&gt;

&lt;p&gt;For my application, I needed routes that referenced the appropriate components, as well as dynamic routes for individual lobbies. This allowed me to maintain a single-paged application (SPA) with multiple views. The page essentially never reloads.&lt;/p&gt;

&lt;p&gt;Setup was very simple and easy to understand. There is a Router tag with all of your components/routes enclosed. Each route has a path and a component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Router&amp;gt;
        &amp;lt;div className='bg-wraith bg-center bg-top bg-cover bg-no-repeat bg-fixed pb-16'&amp;gt;
              &amp;lt;Nav /&amp;gt;
              &amp;lt;Route exact path="/" component={Home} /&amp;gt;
              &amp;lt;Route exact path='/about' component={About} /&amp;gt;
              &amp;lt;Route exact path="/lobbies" component={LobbiesContainer} /&amp;gt;
              &amp;lt;Route path="/lobbies/:id" component={Lobby} /&amp;gt;
        &amp;lt;/div&amp;gt;
&amp;lt;/Router&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tailwind CSS
&lt;/h3&gt;

&lt;p&gt;Tailwind was the fun part, even the process of figuring it out was enjoyable. I chose Tailwind over other frameworks like Bootstrap, due to its styling flexibility. The Tailwind configuration file is easy to customize. It was like writing plain CSS, but with class attributes.&lt;/p&gt;

&lt;p&gt;This simple setup...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div className='card shadow-2xl bg-gray-500 bg-opacity-50 text-gray-200 p-10'&amp;gt;
            &amp;lt;div className="font-semibold text-xl tracking-wider uppercase"&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;Link to={`/lobbies/${id}`}&amp;gt;{gamertag}&amp;lt;/Link&amp;gt;&amp;lt;/h2&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div className="text-sm"&amp;gt;&amp;lt;p&amp;gt;{gamemode} • 30 min&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div className="flex mt-2"&amp;gt;{platformType()} {micRequired()}&amp;lt;/div&amp;gt;
            &amp;lt;div className="text-sm mt-2"&amp;gt;&amp;lt;p&amp;gt;{region} • {skillLevel}&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div className="text-sm mt-4 btext-white"&amp;gt;&amp;lt;p&amp;gt;{description}&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div className="mt-8 inline-block float-left"&amp;gt;
                &amp;lt;svg className="w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&amp;gt;&amp;lt;path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" /&amp;gt;&amp;lt;/svg&amp;gt;

                &amp;lt;span className='text-sm ml-1 mt-0.5'&amp;gt;7 Interested&amp;lt;/span&amp;gt;  
            &amp;lt;/div&amp;gt;
            &amp;lt;div className="mt-6 inline-block float-right"&amp;gt;
                &amp;lt;Link to={`/lobbies/${id}`}&amp;gt;
                    &amp;lt;button className='flex bg-red-600 hover:bg-red-500 text-white hover:text-white py-2 px-3 text-sm uppercase'&amp;gt;
                    View Lobby
                    &amp;lt;/button&amp;gt;
                &amp;lt;/Link&amp;gt;
            &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Created these responsive cards...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CMXpZHAp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/339949db2994fda755a1f166ceeae2c6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CMXpZHAp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/339949db2994fda755a1f166ceeae2c6.png" alt="Lobby Cards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LpXhrD85--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/16cc859b22cff995a175b16fe2873b88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LpXhrD85--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/16cc859b22cff995a175b16fe2873b88.png" alt="Responsive Lobby Cards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The styling is nearly identical to the mock up one I created using Figma. This is probably the closest I have gotten to any mock up I have created in prior projects.&lt;/p&gt;

&lt;p&gt;Here is a look at the final index page. Compare it to the mockup above:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jVmNbB64--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/db756c24a2000feab8e807ac51626c0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jVmNbB64--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/db756c24a2000feab8e807ac51626c0f.png" alt="Index Page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to dive into the code? Checkout the repo &lt;a href="https://github.com/branmar97/apexlink-frontend"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>react</category>
      <category>tailwindcss</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Class Journal - JavaScript and Rails Project</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Sat, 16 Jan 2021 01:45:34 +0000</pubDate>
      <link>https://dev.to/branmar97/class-journal-javascript-and-rails-project-e95</link>
      <guid>https://dev.to/branmar97/class-journal-javascript-and-rails-project-e95</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I created a digital journal where users can create and delete journal entries, as well as comment on them. Think of it as a time capsule or diary that all students can read. This project uses a Rails backend, and JavaScript and Bootstrap on the frontend. My main goal with this project was to use my knowledge of Rails and JavaScript to build a CRUD application. Entries can only be created, read and deleted in the current state, however, I do plan on implementing an update entries feature in the future. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Kf_tr6s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/daa9a3de63fc0a50f029cb7fcf055ca2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Kf_tr6s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/daa9a3de63fc0a50f029cb7fcf055ca2.png" alt="Index page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Requirements
&lt;/h3&gt;

&lt;p&gt;There were some basic guidelines I needed to follow when building my application. Rails was required for the backend of this project. HTML, CSS and JavaScript were to be used for the frontend. I was required to have one has-many relationship, use classes to encapsulate my logic, and cover at least 2 of CRUD. I also needed to handle interactions between the client and server asynchronously using at least 3 AJAX calls while using JSON for the communication format. I fulfilled these requirements by creating and accessing entries from my Rails backend using serializers and fetch requests, and adding the information to the DOM on the frontend.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rails Backend
&lt;/h3&gt;

&lt;p&gt;Using Rails as an API for my project was very easy to setup. I finished this component with only 18 commits. My Rails backend has two models: Entry and Comment. Entry has title, author and text attributes. Comment has text, author and entry_id attributes, and belongs to Entry. This is how I fulfilled my has-many/belongs-to relationship requirement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class EntriesController &amp;lt; ApplicationController
    before_action :set_entry, only: [:show, :destroy]

    def index
        @entries = Entry.all

        render json: @entries, except: [:created_at, :updated_at]
    end

    def show 
        render json: @entry , except: [:created_at, :updated_at]
    end

    def create 
        entry = Entry.create(entry_params)
        render json: entry, status: 200
    end

    def destroy 
        @entry.destroy
    end

    private

    def set_entry
        @entry = Entry.find(params[:id])
    end 

    def entry_params 
        params.require(:entry).permit(:title, :text, :author)
    end 
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class EntrySerializer
  include FastJsonapi::ObjectSerializer
  attributes :id, :title, :text, :author
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My entries controller features index, show, create and destroy actions. I utilized the fast_jsonapi gem for building out my serializers and creating formatted JSON responses for communication on the frontend with JavaScript. The comments controller features only index and create. Thanks to Rails and fast_jsonapi, my JSON was organized and easy to work with. &lt;/p&gt;

&lt;h3&gt;
  
  
  JavaScript Frontend
&lt;/h3&gt;

&lt;p&gt;The JavaScript component was the most challenging part of this application. It was my first time building what I consider a complete Rails and JavaScript application. After I completed the backend I honestly did not know where to begin with my frontend. &lt;/p&gt;

&lt;p&gt;I did many google searches, and viewed other projects and repos for examples. I decided to start with the index page, since I would need containers and a basic setup to manipulate the DOM. I then built my API Adapter, a class that made fetch requests to my Rails backend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;createEntry(entryTitle, entryAuthor, entryText) {
        const entry = {
            title: entryTitle,
            author: entryAuthor,
            text: entryText
        }

        return fetch(this.root + "/entries", {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json"
            },
            body: JSON.stringify(entry)
        })
        .then(res =&amp;gt; (res.json()))
        .catch(error =&amp;gt; console.log("Error: " + error))
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With my fetch requests working, I started to build the Entry and Entries classes. Entry is in charge of instantiating and rendering entries, while Entries handles creating entries from form data, getting entries, and posting entries to the backend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const entriesContainer = document.getElementById("entries-container")

        // Build Entry Div
        const entryDiv = document.createElement("div")
        entryDiv.className = "entry-container mt-3 mb-5"
        entryDiv.id = `entry-${this.id}-container`
        entriesContainer.appendChild(entryDiv)

        // Entry Title
        const title = document.createElement("h3")
        title.className = "entry-title"
        title.innerText = this.title
        entryDiv.appendChild(title)

        // Entry Author
        const author = document.createElement("p")
        author.className = "entry-author"
        author.innerHTML = `&amp;lt;i&amp;gt;${this.author}&amp;lt;/i&amp;gt;`
        entryDiv.appendChild(author)

        // Entry Text
        const text = document.createElement("p")
        text.className = "entry-text"
        text.innerText = this.text
        entryDiv.appendChild(text)

        // Comment Container
        const commentsDiv = document.createElement("div")
        commentsDiv.className = "entry-comment-container mt-5 mb-5"
        commentsDiv.id = `entry-${this.id}-comment-container`
        commentsDiv.style.display = "none"

        // Show/Hide Comments
        const showCommentsBtn = document.createElement("button")
        showCommentsBtn.id = `entry-show-button-${this.id}`
        showCommentsBtn.className = "btn btn-secondary me-1"
        showCommentsBtn.innerHTML = "Comments"
        showCommentsBtn.addEventListener("click", showHideComments.bind(this))
        entryDiv.appendChild(showCommentsBtn)

        // Delete Button
        const deleteBtn = document.createElement("button")
        deleteBtn.setAttribute("id", `delete-button-${this.id}`)
        deleteBtn.className = "btn btn-danger me-1"
        deleteBtn.innerHTML = "Delete"
        entryDiv.appendChild(deleteBtn)
        entryDiv.appendChild(commentsDiv)

        deleteBtn.addEventListener("click", () =&amp;gt; {
            entryDiv.remove()
            this.adapter.deleteEntry(`${this.id}`)
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function showHideComments() {
            const commentsDiv = document.getElementById(`entry-${this.id}-comment-container`)
            if (commentsDiv.style.display === "none") {
                commentsDiv.style.display = "block"
            } else {
                commentsDiv.style.display = "none"
            }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did not like how much screen real estate that comments was taking up, so I built a function that shows or hides comments on a button listener. This seemed to be a lot more user friendly and much easier to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Aa2J7FBq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/f4f4cee4ff74e3028664cf644d215e7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aa2J7FBq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/f4f4cee4ff74e3028664cf644d215e7b.png" alt="Journal Comments"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating New Entries
&lt;/h4&gt;

&lt;p&gt;The entries class was setup with form bindings and an event listener on the submit button, which triggers my create new entry method. It uses the form values to make a post request to the backend and instantiate new entry objects, then utilizes the responses to create entry objects on the frontend for rendering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;newEntryBindings() {
        this.newEntryForm = document.getElementById("new-entry-form")
        this.newEntryTitle = document.getElementById("new-entry-title")
        this.newEntryAuthor = document.getElementById("new-entry-author")
        this.newEntryText = document.getElementById("new-entry-text")
        this.newEntryForm.addEventListener('submit', this.createNewEntry.bind(this));
    }

    createNewEntry(event) {
        event.preventDefault()
        const entryTitle = this.newEntryTitle.value
        const entryAuthor = this.newEntryAuthor.value 
        const entryText = this.newEntryText.value

        this.adapter.createEntry(entryTitle, entryAuthor, entryText)
        .then(entry =&amp;gt; {
            const newEntry = new Entry(entry)
            this.entries.push(newEntry)
            this.newEntryTitle.value = " "
            this.newEntryAuthor.value = " "
            this.newEntryText.value = " "
            newEntry.renderEntry()
        })
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Building Comments
&lt;/h4&gt;

&lt;p&gt;The Comment and Comments classes were setup similarly to my Entry classes. Comment instantiates and renders comments to the DOM and Comments fetches and renders comments from the backend. Building this section was a lot of fun and a great learning experience. I learned how to display comment count by getting the number of children from the unordered list elements. It can also make the word "comment" singular or plural based on the count.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const commentCount = document.createElement("h5")
        commentCount.id = `entry-${this.id}-comment-count`
        commentCount.className = "mt-5 mb-3"
        if (commentsUl.childElementCount === 1) {
            commentCount.innerText = `${commentsUl.childElementCount} Comment`
        } else {
            commentCount.innerText = `${commentsUl.childElementCount} Comments`
        }

        commentsDiv.prepend(commentCount)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Async Issues
&lt;/h3&gt;

&lt;p&gt;Later on into development, I stumbled upon a huge bug that I did not notice at first. Sometimes my comments were rendering, and other times they would fail to load. My entries were coming up as null. &lt;/p&gt;

&lt;p&gt;I eventually found out that this was a timing issue. Initially, my application was running asynchronously in parallel. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new Entries()
new Comments()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem with this setup was that both classes were making fetch requests at the same time, which is not really ideal. There were also too many functions being called in my entries constructor. &lt;/p&gt;

&lt;p&gt;My fetch requests for Entries were much larger, and the comments were coming back before the entries had finished loading. This was a major issue because the entries are parents of the comments, and without them the comments cannot render. &lt;/p&gt;

&lt;p&gt;The solution was to add an event listener with DOMContentLoaded and a callback function that would not instantiate comments until entries are finished. I used "them" and an arrow function to make this work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.addEventListener("DOMContentLoaded", function() {
    new Entries().fetchAndLoadEntries().then(() =&amp;gt; {
        new Comments()
    })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Polishing
&lt;/h3&gt;

&lt;p&gt;After the async fix I had a complete, functional project. I began to focus on polishing and making the frontend look prettier. Bootstrap made this step very easy. I styled entire headers, forms and lists in minutes. &lt;/p&gt;

&lt;h3&gt;
  
  
  Future Improvements
&lt;/h3&gt;

&lt;p&gt;I plan on making a few changes to what can be done with entries. Currently, entries can only be read, created and deleted. I hope to have full CRUD capability for entries in the future.&lt;/p&gt;

&lt;p&gt;Comment count can also be refactored. Instead of getting comment count by child element count, I can store entry comments in an array and get the array count to make my code more dynamic.&lt;/p&gt;

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

&lt;p&gt;Building this project was a huge challenge and a learning experience. Not only did I become much more confident writing JavaScript, I utilized what I learned in my previous module with Rails, but in new ways. I can now build complete applications using JavaScript, Rails and Bootstrap with CRUD features. Two months ago I would not even know where to begin. I hope to take what I have learned and create even richer projects in the future. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ruby</category>
      <category>rails</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>Rails MVC Project with RESTful Routes - Bundl</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Wed, 18 Nov 2020 00:51:31 +0000</pubDate>
      <link>https://dev.to/branmar97/rails-mvc-project-with-restful-routes-bundl-4glj</link>
      <guid>https://dev.to/branmar97/rails-mvc-project-with-restful-routes-bundl-4glj</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;This is the most polished, complete project I have built to date. Bundl is a social-networking application built on the Rails framework. It is based on the popular groups app, Meetup. &lt;/p&gt;

&lt;p&gt;Users can join and login, as well as create groups and events, post discussions, rsvp, and join groups. The goal is to allow users to find groups of people with similar interests. Groups have a name, description, location, members, events with RSVPs, and discussions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Planning
&lt;/h2&gt;

&lt;p&gt;Before I wrote a single line of code, I got out my handy notebook. I then drew diagrams of my model and attributes. Thinking about how I wanted my UX was a tremendous help during this process. I thought of it like reverse engineering. I had to build the UX the way I saw a user interacting with it in my head. With a basic understanding of my project structure, I began coding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the App
&lt;/h2&gt;

&lt;p&gt;Rather than taking my usual approach and starting with the User model, I decided to build my apps core component first, Groups. This is where most interactions are made in my application. Groups have a name, description, location and an owner or user. Users can view, join and leave groups, as well as access a bunch of nested components I will cover later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/db/20201004221257_create_groups.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateGroups &amp;lt; ActiveRecord::Migration[6.0]
  def change
    create_table :groups do |t|
      t.string :name
      t.text :description
      t.string :location
      t.integer :user_id
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, I decided that groups need a topic. Topics can belong to multiple groups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/db/20201004221451_create_topics.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateTopics &amp;lt; ActiveRecord::Migration[6.0]
  def change
    create_table :topics do |t|
      t.string :title
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Users should also be able to join groups. I thought that the best way to do this was with a join model called Membership. Memberships have a group_id and user_id. Using this method allowed me to create the functionality for users to join and leave groups with '@membership.destroy'.&lt;/p&gt;

&lt;p&gt;Members should be able to view events for their groups. This is where I added the Event model, which has a group, title, description, location, start-time, and end-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/db/20201004221815_create_memberships.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class CreateMemberships &amp;lt; ActiveRecord::Migration[6.0]
  def change
    create_table :memberships do |t|
      t.integer :group_id
      t.integer :user_id
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  User Model
&lt;/h3&gt;

&lt;p&gt;I created my User model using Devise. Most of the features of my application require a user account. My User model accepts a name, email and password. I then used Devise to setup users routes and users_controller for users actions. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/config/routes.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
     devise_for :users, path: '', path_names: { sign_in:    "login", sign_out: "logout", sign_up: "join" }
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I decided to start building my users join and login forms, so that I could begin testing other features of my app as I build them. Devise and Simple Form make error messages much easier later. I added my view 'views/registrations/new.html.erb' and wrote the following code:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/app/views/registrations/new.html.erb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %&amp;gt;
     &amp;lt;%# &amp;lt;%= f.error_notification %&amp;gt;

     &amp;lt;%= f.input :name,
             required: true,
             label: "Full Name",
             input_html: { autocomplete: "name" }%&amp;gt;

     &amp;lt;%= f.input :email,
             required: true,
             autofocus: true,
             input_html: { autocomplete: "email" }%&amp;gt;

     &amp;lt;%= f.input :password,
             required: true,
             hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
             input_html: { autocomplete: "new-password" } %&amp;gt;

     &amp;lt;%= f.input :password_confirmation,
             required: true,
             label: "Confirm Password",
             input_html: { autocomplete: "new-password" } %&amp;gt;

     &amp;lt;%= f.button :submit, "Sign up" %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The users login form is similar, but only has fields for email and password. &lt;/p&gt;

&lt;h3&gt;
  
  
  Groups
&lt;/h3&gt;

&lt;p&gt;At this point I had my Groups model created, so I built the feature to create new groups. I added a new action to the groups controller and built the new view.&lt;/p&gt;

&lt;p&gt;I then added validations for name, description, topic and location to ensure that the user fills out all required fields. &lt;/p&gt;

&lt;p&gt;I created the RSVP and Discussion models, and put together the groups show page with  name, description, buttons, and a members list. I wrote conditions, such as 'if @group.user == current_user,' to display advanced options to the group admin only. Group members also have more options than non-members.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bJ9AaElN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/cd6ee88232d7d84cdecb26baa93720c5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bJ9AaElN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/cd6ee88232d7d84cdecb26baa93720c5.png" alt="Screenshot of groups new form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v3oOG_a---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/f0998e25826616f108a849b9ba9ee173.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v3oOG_a---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/f0998e25826616f108a849b9ba9ee173.png" alt="Screenshot of groups show"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The groups feature a variety of associations and nested routes. This allowed me to build unique discussions, members and events pages for each group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources :groups do
    resources :memberships, only: [:index], path: "/members"
    resources :discussions, only: [:index, :create, :destroy]
    resources :events, only: [:index, :show, :new]
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tags
&lt;/h3&gt;

&lt;p&gt;This is a feature I added on a whim. I wanted another way for users to browse groups, so I thought it would be a great idea for users to create their own tags. I implemented this feature by creating a GroupTag join model that belongs to a tag and group. When a user enters a tag title, the application will create that tag or find a tag if one already exists with the given title.&lt;/p&gt;

&lt;p&gt;I decided to get creative with this new model, and allow users to enter multiple tags, separated by commas, into a text area in the groups new form. &lt;/p&gt;

&lt;p&gt;You may have seen it in the screenshot above. This works via two instance methods I created called tag_list and tag_list=(value).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def tag_list 
    self.tags.map { |t| t.name }.join(", ")
end 

def tag_list=(value)
    tag_names = value.split(/,\s+/)

    self.tags = tag_names.map { |name| Tag.where('name = ?', name).first or Tag.create(:name =&amp;gt; name) }
end 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first method displays all group tags separated by commas and the second method takes the input from the text area, splits it at commas, and finds or creates tags with the provided values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Searches
&lt;/h3&gt;

&lt;p&gt;What good are the tags if they cannot be used? This is where the Search model comes in. The purpose of this model is to search for groups by tags, however more search fields can be added if wanted.&lt;/p&gt;

&lt;p&gt;Here is the form: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9YkLqCsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/dcbd10d16706f2ba8fd113e6cb136891.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9YkLqCsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/dcbd10d16706f2ba8fd113e6cb136891.png" alt="Searches new form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every time that form is submitted, a new Search instance is created. This also means that each search result is displayed on a unique show page with the Search instance ID. This is a little more advanced than the Groups index search field that filters the results. &lt;/p&gt;

&lt;h3&gt;
  
  
  OAuth
&lt;/h3&gt;

&lt;p&gt;The final step, as far as the backend, was setting up OAuth, specifically OAuth-Facebook, which allows users to login to your application using their Facebook account. &lt;/p&gt;

&lt;p&gt;First I added Omniauth columns to my users table. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# bundl/db/migrate/20201105220126_create_searches.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class AddOmniauthToUsers &amp;lt; ActiveRecord::Migration[6.0]
   def change
     add_column :users, :provider, :string
     add_column :users, :uid, :string
   end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then bundle installed the Omniauth-Facebook and DotEnv gems. Devise actually works with Omniauth, so I was able to add this line of code to my Devise initializer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.omniauth :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you look at the code above, you will notice the constants, "FACEBOOK_APP_ID" and "FACEBOOK_APP_SECRET." These constants are stored in DotEnv, and hold my unique ID and secret. This prevents the information from being exposed. &lt;/p&gt;

&lt;p&gt;Omniauth uses these codes to direct users to my Facebook app, and back to my application. It pulls the Facebook user's email and name to build their user account in the Bundl application. This is happening in the background when the user is redirected, and the information is stored to the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roadblocks
&lt;/h2&gt;

&lt;p&gt;There were a few headaches throughout the process of building my Rails application. The hardest part was sitting down and getting to work. Having lots of moving parts caused me to become overwhelmed. I was jumping from one feature to another and feeling unsure about where to start. This feeling slowly faded away as I got further into development. &lt;/p&gt;

&lt;p&gt;My biggest area of struggle was forms. At times, my form field data would not pass over. I spent hours trying to understand why new groups were coming back as invalid due to not having a topic. It ended up being as simple as adding a topic_id column to my groups table and fixing the associations in my models. I had it setup as Group 'has_one :topic', when the correct association is 'belongs_to :topic'.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building this project was a huge learning experience. I utilized everything I learned throughout the module, including associations, validations, authentications, nested fields, nested routes, displaying validations and using helper methods. I have developed a solid understanding of Rails. Here are a few key take aways from my experience:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Test your application and try to break it&lt;/li&gt;
&lt;li&gt;Use byebug and use it often&lt;/li&gt;
&lt;li&gt;Break down your project into small parts&lt;/li&gt;
&lt;li&gt;Keep a tab with documentation handy&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>My Experience in a Coding Bootcamp After 6 Months</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Fri, 04 Sep 2020 12:29:29 +0000</pubDate>
      <link>https://dev.to/branmar97/my-experience-in-a-coding-bootcamp-after-6-months-102b</link>
      <guid>https://dev.to/branmar97/my-experience-in-a-coding-bootcamp-after-6-months-102b</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Here I am, six months into my coding Bootcamp. I had to count the months on my fingers because I could not believe how fast they went by. Many things have happened that I expected, and other things surprised me. In this article, I will cover how I learned about coding, finding a Bootcamp, and what code Bootcamp is like. This is more of a self-reflection, but I hope you can learn something from my experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Passion for Creating
&lt;/h3&gt;

&lt;p&gt;After some lackluster experiences with college, I decided it was time for a change. I started to think about things that I could see myself doing. Mostly fields that do not require a college degree. Initially, I thought I was going into a trade like HVAC or welding, but I remembered how interested I was in web development as a pre-teen. I always saw myself as a creator, building websites with online web builders.&lt;/p&gt;

&lt;p&gt;There was a thrill I got from seeing people interact with my websites. One of my most memorable websites was one I built with &lt;a href="https://webs.com"&gt;Webs&lt;/a&gt;, it featured forums, chatrooms, photo/video galleries, arcade games, and user login. Friends from school would signup to hang out, chat, and play silly arcade games. &lt;/p&gt;

&lt;h3&gt;
  
  
  Finding a Bootcamp
&lt;/h3&gt;

&lt;p&gt;When I remembered how much I enjoyed building websites, I thought about learning how to build them from scratch. After multiple failed attempts with learning on my own, I began to search for a school. I discovered there were technical schools called Bootcamps geared towards learning code, and I had to learn more. I found the perfect school that offered ISA (Income Share Agreement), 10-month programs, live/virtual classes, personal mentorship, counseling, job assistance, and a strong curriculum. &lt;/p&gt;

&lt;p&gt;The ISA was very appealing to me because I could not afford any Bootcamp out of pocket. With ISA, I could start classes with no money down. All I needed to do was sign a contract stating that I agree to pay a percentage of my income after completing the program and finding a job.&lt;/p&gt;

&lt;p&gt;I researched the Bootcamp for days, learning as much as I could. Most of the content I consumed were testimonials from alumni in blogs, videos, and Reddit posts. I would say that most reviews I found were positive. Graduates did not seem to have a problem finding jobs, and those who did would eventually land one. I learned that the Bootcamp could turn non-coders into developers building complete web applications. I had to sign up.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Bootcamp
&lt;/h3&gt;

&lt;p&gt;To apply, I had to fill out some basic information, and write a short essay about why I wanted to attend Bootcamp. I wrote some of what I have written in this blog post, including how passionate I am about creating and breaking things. &lt;/p&gt;

&lt;p&gt;Within a week I was selected for a video call, where they got to learn more about me. The student advisor was interested in my personality, learning preferences, and attitude towards programming. They wanted proof that I was capable of putting in the work and self-discipline that their program requires. &lt;/p&gt;

&lt;p&gt;The meeting went well, and I was selected to attend their online Bootcamp. I filled out paperwork, got my start date, installed the software I would need, and waited for classes to begin.&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting Out
&lt;/h3&gt;

&lt;p&gt;The online program was broken into five modules, each covering a different language or framework. It was finally time to module one, my first day of class. I was in a period they call, "The First Mile." This period allows students two weeks to complete a specified amount of lectures/assignments, to see if coding is a good fit for them. Students who fail this period are able to drop out of the Bootcamp with no penalties. We learned about the process of coding and dived into a little bit of Ruby coding. &lt;/p&gt;

&lt;p&gt;From then on, we were learning something new each day. You definitely need to set aside time in your schedule strictly for coding. As a parttime student, I was averaging about 20-25 hours per week. Each week was expanding on what we learned previously. We also had scheduled live lectures, study groups, chatrooms, and coaching sessions each week.&lt;/p&gt;

&lt;p&gt;Being in code Bootcamp is a hustle and grind. You are constantly learning new information very quickly. If you do not stay focused, it is easy to fall behind. One of the best things I did to help this was using what I learned. I built applications and kept stacking every feature I learned about on top of them. I also attended almost every lecture and study group in my first module. &lt;/p&gt;

&lt;p&gt;You may also want to make some friends. I have learned so much from my peers in my cohort. Setting up study groups and working on labs together has not only been fun, but beneficial to my coding experience. I could also just message a friend whenever I felt stuck. &lt;/p&gt;

&lt;h3&gt;
  
  
  After The Basics
&lt;/h3&gt;

&lt;p&gt;Once we covered the foundations of Ruby and built our first console application, it was time to build actual web applications. The first Ruby framework we learned about was Sinatra. This web framework allowed us to build MVC applications with views, controllers, authentication, and more. We moved really quickly on this one and started our projects after less than two months. Pretty much all of what we learned in the Ruby module was applied to this one, so make sure you keep previous material fresh in mind. &lt;/p&gt;

&lt;p&gt;My final Sinatra project was an MVC CRUD recipes application. Users could create, view, update and delete their recipes. This application had multiple pages, user authentication, and forms. One thing I was not quite ready for was the project review. In project reviews, you are asked a lot of technical questions. They may ask how a specific part of your code works, or even about HTTP protocol. I completely stumbled when describing HTTP protocol, because I was focused solely on the code and framework. I still passed, but definitely be sure to brush up on internet protocols and other technical topics. &lt;/p&gt;

&lt;p&gt;Fast forward to today and I am in my third module, Ruby on Rails. It is like Sinatra, yet much more advanced. Things I built in Sinatra can be done in minutes (or seconds) with Rails. I am doing a mix of front-end and back-end development. This module introduced lots of optional CSS lessons, and writing HTML with Ruby code. I can generate a form in just a few lines of Ruby. Pretty cool right?&lt;/p&gt;

&lt;p&gt;At this point, I feel like I am actually building things. Not just "hello world" console apps, but fully functional web applications. I understand how to tie Ruby, HTML, CSS, and SQL altogether to make a working MVC application. I still have a lot to brush up on, but the foundation is there. &lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Has it been worth it so far? I believe it definitely has. I have gone from not understanding what the heck I am doing, to kind of understanding what I am doing. &lt;/p&gt;

&lt;p&gt;Do not expect to enroll in Bootcamp and automatically become a full-stack developer. Everyone has to put in the effort. You are going to get out of this program what you put into it. If you put in the necessary hours per week and challenge yourself, then you will reap the rewards. &lt;/p&gt;

&lt;p&gt;Be prepared to go through some very frustrating times and keep yourself motivated. Also, imposter syndrome is real, and it may hit you hard. The good thing is that you have a lot of support around as a Bootcamp student. Use every asset you have. &lt;/p&gt;




&lt;p&gt;Thank you for taking the time to read my article. Would you attend a code Bootcamp? Have you or are you currently attending one? I would love to read about your experience.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>bootcamp</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building an Advanced Search Form in Rails 6</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Mon, 31 Aug 2020 03:09:13 +0000</pubDate>
      <link>https://dev.to/branmar97/building-an-advanced-search-form-in-rails-6-2fkm</link>
      <guid>https://dev.to/branmar97/building-an-advanced-search-form-in-rails-6-2fkm</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;A simple search form is great, but one with advanced search options can have many use cases. Can you imagine Amazon with a search form that only accepts item names? Pssh...that sounds like a nightmare to me. &lt;/p&gt;

&lt;p&gt;I prefer to provide more options for my users. Adding more filters can help users narrow down the results and find exactly what they are looking for. &lt;/p&gt;

&lt;p&gt;You can use gems like &lt;a href="https://github.com/activerecord-hackery/ransack"&gt;Ransack&lt;/a&gt; to build search forms much faster, but for the purpose of learning and performance we will be building this feature ourselves. Throughout the process, you will also learn how to customize Rails default pluralization. By the end, we will be able to search for Pokemon by name, type, and region. &lt;/p&gt;

&lt;h2&gt;
  
  
  Before We Dive In
&lt;/h2&gt;

&lt;p&gt;I recommend testing the application throughout the process. You can run &lt;code&gt;rails server&lt;/code&gt; in your terminal and visit &lt;a href="https://dev.tolocalhost:3000"&gt;localhost:3000&lt;/a&gt; after each feature implementation and see if the application works as expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Let us begin by creating a new Rails app. Execute the following code in your command line: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails new PokemonDB&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will set up the entire Rails directory structure that we need to run our application. Before we do our scaffold, we need to setup Pokemon to have proper pluralization. Since Pokemon is already plural, we do not want Rails to add an 's' after it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/config/initializers/inflections.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ActiveSupport::Inflector.inflections do |inflect|
    inflect.uncountable "pokemon"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can create our first model, Pokemon. Our model will have three strings of name, type, and region. We will generate this using a &lt;a href="https://guides.rubyonrails.org/command_line.html#rails-generate"&gt;scaffold&lt;/a&gt;, which will generate the database and the basic MVC configuration we need. Feel free to build this without using a scaffold if you want an extra challenge. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Rails sets attributes as strings by default. Since all of our attributes are strings, we do not need to specify the datatypes. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails generate scaffold Pokemon name type region --force-plural&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After your scaffold is built, update the Pokemon class to make 'type' an acceptable attribute for Pokemon. Rails reserves 'type' by default. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/models/pokemon.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Pokemon &amp;lt; ApplicationRecord
    self.inheritance_column = "not_sti"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Be sure to follow up with &lt;code&gt;rails db:migrate&lt;/code&gt; to update the schema. Our application will not run with pending migrations. &lt;/p&gt;

&lt;h2&gt;
  
  
  Updating Routes
&lt;/h2&gt;

&lt;p&gt;Now we need to update our &lt;a href="https://guides.rubyonrails.org/routing.html"&gt;routes&lt;/a&gt; to change the action for the root page, indicated by a forward slash. Use the 'pokemon#index' action for the root. Update the routes file:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/config/routes.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
  root 'pokemon#index'
  resources :pokemon
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our root page should look like this. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9ChIAPTw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/5f411d27d8b056471f470071f0be675a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9ChIAPTw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/5f411d27d8b056471f470071f0be675a.png" alt="Index page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Your Create Form
&lt;/h2&gt;

&lt;p&gt;Go ahead and click 'New Pokemon.' Create three or four Pokemon to test the form, then check the index page. This will also provide objects to work with. I prefer this method because I can test my forms and build 'seeds' at the same time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PCjrqceM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/8a1c3b74374f4e989480918e4fb231d3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PCjrqceM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/8a1c3b74374f4e989480918e4fb231d3.png" alt="New pokemon form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have added Pokemon, you should see them on the index page. They will be displayed in the order you created them with show, edit, and destroy links. The next step will be to add a basic search form and logic. &lt;/p&gt;

&lt;h2&gt;
  
  
  Search by Name
&lt;/h2&gt;

&lt;p&gt;Before we build the advanced search, let us build a basic Pokemon search form to search by name. We will expand on it later. &lt;/p&gt;

&lt;p&gt;To build this use the &lt;code&gt;form_with&lt;/code&gt; tag in the Pokemon index file. If you are using an older version of Rails, &lt;code&gt;form_tag&lt;/code&gt; will work just fine with a few slight differences. Add the following code to the index view above the Pokemon table. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/views/pokemon/index.html.erb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;%= form_with(url: '/pokemon', method: 'get', local: true) do %&amp;gt;
  &amp;lt;%= text_field_tag(:search) %&amp;gt;
  &amp;lt;%= submit_tag("Search") %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our form is taking in a path and method. The &lt;code&gt;text_field_tag&lt;/code&gt; displays a textbox where users can enter a search value, while the submit tag sends the information for us to use and filter results. Here is the &lt;a href="https://guides.rubyonrails.org/form_helpers.html"&gt;documentation&lt;/a&gt; if you would like to brush up on forms. &lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Search Method
&lt;/h3&gt;

&lt;p&gt;It is time to build the search method. Since this is database logic, it will be handled by the model. This method will find Pokemon based on a given name. If no search parameters are provided, then it will display all Pokemon. Update your 'pokemon.rb' file to look like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/models/pokemon.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Pokemon &amp;lt; ApplicationRecord
    self.inheritance_column = "not_sti"

    def self.search(search)
        if search 
            where(["name LIKE ?","%#{search}%"])
        else
            all
        end
    end 
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will put this new class method to use by calling it in our Pokemon index. The following code will take in search params from the search form we built earlier. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/controllers/pokemon_controller.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def index
    @pokemon = Pokemon.search(params[:search])
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tZcGQtLA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/78a25e5da98a9dee9efb52261097e88f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tZcGQtLA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.gyazo.com/78a25e5da98a9dee9efb52261097e88f.png" alt="Search form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The basic search form is now functional. I was able to find Bulbasaur! Time to make this form more useful and interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search Model
&lt;/h2&gt;

&lt;p&gt;Next, we will add functionality to search for Pokemon by type and region. This is a bit more advanced and will require a separate model to handle searches. We will use &lt;code&gt;rails generate&lt;/code&gt;, but this time for a model. This model will have name, type, and region. Be sure to run &lt;code&gt;rails db:migrate&lt;/code&gt; after generating.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails generate model Search name type region&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Searches Controller
&lt;/h2&gt;

&lt;p&gt;For our advanced search form to work properly, it will need its own &lt;a href="https://guides.rubyonrails.org/action_controller_overview.html"&gt;controller&lt;/a&gt;. Make sure the controller name is pluralized. Run the following in your terminal, then update your routes. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails generate controller searches&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/config/routes.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
  root 'pokemon#index'
  resources :pokemon
  resources :searches
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Controller Actions
&lt;/h3&gt;

&lt;p&gt;The controller will have three &lt;a href="https://guides.rubyonrails.org/action_controller_overview.html"&gt;actions&lt;/a&gt; and a 'search_params' private method. Our actions are show, new, and create. Here is the code. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Older versions of rails may use &lt;code&gt;.uniq&lt;/code&gt; rather than &lt;code&gt;.distinct&lt;/code&gt;. Try them out to see which one throws errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/controllers/searches_controller.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SearchesController &amp;lt; ApplicationController
    def show
        @search = Search.find(params[:id])
    end 

    def new 
        @search = Search.new
        @types = Pokemon.distinct.pluck(:type)
        @regions = Pokemon.distinct.pluck(:region)
    end

    def create
        @search = Search.create(search_params)
        redirect_to @search
    end 

    private

    def search_params
        params.require(:search).permit(:name, :type, :region)
    end 
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building a New Form
&lt;/h2&gt;

&lt;p&gt;Start by creating a link to our new advanced search form. This can go directly under the standard search form in the Pokemon index view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/views/pokemon/index.html.erb&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;%= link_to "Advanced Search", new_search_path %&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You may notice that this link does not go anywhere. We need to create our views in the searches folder! Create the views &lt;code&gt;new.html.erb&lt;/code&gt; and &lt;code&gt;show.html.erb&lt;/code&gt;. Make sure they are in the &lt;strong&gt;# pokemondb/app/views/searches&lt;/strong&gt; directory. &lt;/p&gt;

&lt;p&gt;Now we have some empty views. Time to add some code to create new searches. This will be a form with select menus and a submit field. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/views/searches/new.html.erb&amp;lt;/strong&lt;br&gt;
&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Advanced Search&amp;lt;/h1&amp;gt;

&amp;lt;%= form_with model: @search do |f| %&amp;gt;
    &amp;lt;%= f.label :name %&amp;gt;
    &amp;lt;%= f.text_field :name %&amp;gt;

    &amp;lt;%= f.label :type %&amp;gt;
    &amp;lt;%= f.select :type, options_for_select(@types), include_blank: true %&amp;gt;&amp;lt;br&amp;gt;

    &amp;lt;%= f.label :region %&amp;gt;
    &amp;lt;%= f.select :region, options_for_select(@regions), include_blank: true %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;

    &amp;lt;%= f.submit "Search" %&amp;gt;
&amp;lt;% end %&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;%= link_to "Back", '/pokemon' %&amp;gt;&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Our advanced search view should look very clean. Try the 'Advanced Search' link on the index page to see if everything works as expected. Move on to the &lt;strong&gt;show&lt;/strong&gt; view. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/views/searches/show.html.erb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Search Results&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;%= link_to "Back", new_search_path %&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;% if @search.search_pokemon.empty? %&amp;gt;
    &amp;lt;p&amp;gt;No Pokemon were found.&amp;lt;/p&amp;gt;
&amp;lt;% else %&amp;gt;
    &amp;lt;table&amp;gt;
        &amp;lt;thead&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;
                &amp;lt;th&amp;gt;Region&amp;lt;/th&amp;gt;
                &amp;lt;th colspan="3"&amp;gt;&amp;lt;/th&amp;gt;
            &amp;lt;/tr&amp;gt;
        &amp;lt;/thead&amp;gt;

        &amp;lt;tbody&amp;gt;
            &amp;lt;% @search.search_pokemon.each do |pokemon| %&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= pokemon.name %&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= pokemon.type %&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= pokemon.region %&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= link_to 'Show', pokemon %&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= link_to 'Edit', edit_pokemon_path(pokemon) %&amp;gt;&amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;&amp;lt;%= link_to 'Destroy', pokemon, method: :delete, data: { confirm: 'Are you sure?' } %&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;% end %&amp;gt;
        &amp;lt;/tbody&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may notice this table is almost identical to the one generated by the scaffold. I decided to use it since it looks clean and easy to read. &lt;/p&gt;

&lt;h2&gt;
  
  
  Updating the Search Model
&lt;/h2&gt;

&lt;p&gt;Just like our Pokemon model, the Search model needs a method to find Pokemon. This one will be an instance method that will be called on instances of Search. We have called it in our views with &lt;code&gt;.search_pokemon&lt;/code&gt;. It is time to build it. Keep in mind that since this model also has a 'type' attribute, we will need to make it an acceptable attribute. We have done this on the second line of the search model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;# pokemondb/app/models/search.rb&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Search &amp;lt; ApplicationRecord
    self.inheritance_column = "not_sti"

    def search_pokemon
        pokemon = Pokemon.all 

        pokemon = pokemon.where(['name LIKE ?', name]) if name.present?
        pokemon = pokemon.where(['type LIKE ?', type]) if type.present?
        pokemon = pokemon.where(['region LIKE ?', region]) if region.present?

        return pokemon
    end 
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test the Search
&lt;/h2&gt;

&lt;p&gt;Everything should work properly! We should have the ability to filter Pokemon by name, type, and region. The various links and buttons we added also allow for great user-friendliness. It is nice to have a link to go back to the previous page and links to alter our Pokemon. &lt;/p&gt;

&lt;p&gt;Run your rails server and visit &lt;a href="https://dev.tolocalhost:3000"&gt;localhost:3000&lt;/a&gt; to see everything in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Si7Lf6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/AXTQcJW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Si7Lf6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/AXTQcJW.png" alt="Advanced search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading this tutorial. I hope this can be of use to you in a future Rails project. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why You Should Start Pair Programming</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Thu, 27 Aug 2020 18:01:25 +0000</pubDate>
      <link>https://dev.to/branmar97/why-you-should-start-pair-programming-2c21</link>
      <guid>https://dev.to/branmar97/why-you-should-start-pair-programming-2c21</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;I spent a lot of time working independently, trying to build a foundation with Ruby, and scratching my head constantly. I finally had my first pair programming experience after the first month of my code boot camp at Flatiron School. That is where I met my good friend and programming partner, Austin. Things started to change. We both buckled down on Ruby labs with our loud birds chirping in the background. There were many great "ah-ha" moments. &lt;/p&gt;

&lt;p&gt;I believe there is a lot we can do independently, but sometimes working with others can be very beneficial. In this blog post, we will discuss the benefits of pair programming and how to do it effectively. Let us start by explaining what pair programming is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Definition
&lt;/h2&gt;

&lt;p&gt;Pair programming consists of two programmers working together to solve problems. Typically, one programmer is the "driver," and the other is the "navigator." The driver is focused on the actual actions of building the application. This is the programmer that is typing on the keyboard and bringing the ideas to life. The navigator figures out which steps to take and the approach to building the application. They can also help catch errors that may go unnoticed by the driver. At times, the driver and navigator may swap roles to take a break from one role and even out the workload. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Benefits
&lt;/h2&gt;

&lt;p&gt;I believe there are three main benefits to pair programming. They are peer review, spreading the load, and engagement. All three of them can go a very long way.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Peer Review
&lt;/h3&gt;

&lt;p&gt;Nobody writes perfect code. If you believe that you only write "clean code" and do not need to check for errors, then it is going to come back to bite you eventually. It is essential to review your code and make sure that everything works as expected. If it is a SaaS application, then this part is even more important to ensure usability and user-friendliness. The good news is that pair programming can make the process of finding and fixing errors much easier. &lt;/p&gt;

&lt;p&gt;You can have your navigator watch over you as you write code to catch errors in realtime. This can help improve workflow and reduce the time spent fixing errors at the end. If you are unable to work together live, then review as you go. &lt;/p&gt;

&lt;p&gt;One way you can do this is by using Github pull requests. These allow programmers to view changes committed to the external repository, review the code line by line, and discuss changes that need to be made before pushing to the main branch. &lt;/p&gt;

&lt;h3&gt;
  
  
  Spreading the Load
&lt;/h3&gt;

&lt;p&gt;At times, programming can feel very intimidating, especially if working independently. Depending on the project, there can be many moving parts to watch. Keeping track of syntax, algorithms, gems, and everything in between can become overwhelming. We can work more efficiently and stress-free by splitting the work with our partner. Not only will productivity increase, but also the quality because you can focus on smaller parts of the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Engagement
&lt;/h3&gt;

&lt;p&gt;Ever spent hours on a project and felt extremely bored and unmotivated? Working with a partner is much more engaging and might help reduce those feelings. Not only do you have support, but someone to chat and bond with. Doing this can provide that much-needed humility. It also helps build trust with your partner because you are relying on them and keeping each other accountable. The projects you work on together begin to feel a lot more real. &lt;/p&gt;

&lt;p&gt;Here are a few tools you can use to stay connected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://slack.com/"&gt;Slack&lt;/a&gt;: Chat rooms organized by topic, groups, audio/video, and private messaging.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://zoom.us/"&gt;Zoom&lt;/a&gt;: A conference app with audio/video meeting capabilities and screen sharing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://skype.com"&gt;Skype&lt;/a&gt;: A conference app similar to Zoom, but a little less light-weight. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Effective Pairing
&lt;/h2&gt;

&lt;p&gt;Pair programming can be a waste of time if it is not done efficiently. Everyone has their preferences, but I will share a few tips that have made my experience better.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find the Right Partner
&lt;/h3&gt;

&lt;p&gt;Finding a partner is sort of like dating because there is a compatibility scale. There are certain things you want to look for in a "partner." You need a partner that you can work well with, does not cross boundaries and has similar availability. It may also be a good idea to work with someone close to your level. If you are a beginner, your best pair programming partner might not be someone who has built 30 web applications. &lt;/p&gt;

&lt;p&gt;I met my partner in my boot camp cohort, which worked out perfectly because we were on the same module and had similar skill levels. At the same time, you want your partner to bring in different perspectives from yours. Go ahead, put yourself out there!&lt;/p&gt;

&lt;h3&gt;
  
  
  Make a Schedule
&lt;/h3&gt;

&lt;p&gt;Set time aside that is strictly for programming. We wish we could pair while binge-watching Netflix, but that does not work too well. Especially when watching Narcos, you would just miss all the subtitles. &lt;/p&gt;

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

&lt;p&gt;Be very strict in following your schedule and try not to cancel often. Making too many excuses can become tiresome for your partner and might cause them to believe you are not serious. Remember that one hour of high intensity focused work is better than four hours of less focused work. It is also much easier to find an hour to work together. Do not make your sessions too long! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://calendar.google.com"&gt;Google Calendar&lt;/a&gt; is a great way to create a schedule that both you and your partner can view and update. Be sure the schedule works for both parties.&lt;/p&gt;

&lt;h3&gt;
  
  
  Switch Roles
&lt;/h3&gt;

&lt;p&gt;Earlier we went over the differences between the driver and the navigator in pair programming. It is important to play both roles. Being a driver improves your skills in execution while being a navigator improves your ability to explain and break down your code. Both of these need practice.&lt;/p&gt;

&lt;p&gt;You also need to give your partner a break from fulfilling one role. If you went on a 24-hour road trip, would you want to be the driver the entire time? Probably not. Divide the work and make things a lot more interesting and less repetitive.&lt;/p&gt;

&lt;p&gt;One way you can do this easily is by using a Pomodoro app like &lt;a href="https://tomato-timer.com/"&gt;TomatoTimer&lt;/a&gt;. It times your work sessions into 25 minute periods. You can use this timer to switch roles and take breaks. There are also many other free apps on the app store and the web. &lt;/p&gt;

&lt;h3&gt;
  
  
  Find a Quiet Place
&lt;/h3&gt;

&lt;p&gt;It can be difficult to accomplish anything without a quiet place to work. Both you are your partner need a suitable environment free of distractions. Steer clear of the room where your three parakeets are, you will not want to be unmuting yourself every time you need to speak. I have had to do this and it distracts everyone. &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Things Up
&lt;/h2&gt;

&lt;p&gt;These are just a few ways to get started on improving your pair programming experience. I hope you can utilize these tips. Do not forget to discuss your pair programming approach with your partner. &lt;/p&gt;




&lt;p&gt;Feel free to share your approach to pair programming. What improved your experience? Did you try anything that did not work? I would love to hear your response!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Don't Get Stuck in Tutorial Hell</title>
      <dc:creator>Brandon Marrero 🇺🇸</dc:creator>
      <pubDate>Wed, 26 Aug 2020 02:22:06 +0000</pubDate>
      <link>https://dev.to/branmar97/don-t-get-stuck-in-tutorial-hell-1pnh</link>
      <guid>https://dev.to/branmar97/don-t-get-stuck-in-tutorial-hell-1pnh</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Have you repeatedly followed tutorials, yet not retain any information? Does your portfolio only consist of tutorial projects? If the answer is yes to these questions, then you might be stuck in the infinite loop known as tutorial hell. I myself have been there, and it is not a great place to be. I spent hours watching tutorials, yet not understanding the material, and then repeating those tutorials again until I just gave up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tutorial Hell...?
&lt;/h2&gt;

&lt;p&gt;Sadly, tutorial hell seems to be one of the leading causes of people giving up on coding, but that does not have to be the case for you. I will start by giving a brief rundown of what tutorial hell is. &lt;/p&gt;

&lt;p&gt;Tutorial hell is what many of us get trapped in when we enter the vicious cycle of watching tutorial videos. You may watch hours upon hours of coding tutorials, but when the time comes to use what you 'learned,' you feel lost. It feels like you are starting from square one. This is a normal way to feel when you are learning something new, especially if it is a challenging experience. The problem is when developers who are lost binge watch and follow more tutorials in an endless cycle. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;       &lt;strong&gt;Interviewer:&lt;/strong&gt; "What are constants? What are some use cases?"&lt;/p&gt;

&lt;p&gt;       &lt;strong&gt;Interviewee in Tutorial Hell:&lt;/strong&gt; "Ummmm..."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Tutorials Are Not Bad!
&lt;/h2&gt;

&lt;p&gt;I am not trying to say tutorials are not a great way to learn. Watching a tutorial for a new tool or concept is a great way to get started, but once you watch that tutorial it is important to use other resources and the information you learned. Try to watch tutorials and implement some parts that you learned into your own projects. Deconstruct the projects you build from tutorials. Poke around with them. Just following along can have you coding blindly and not understanding what you are doing. &lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Out
&lt;/h2&gt;

&lt;p&gt;You CAN get out of tutorial hell. It simply starts with changing your approach to learning. Tutorials alone will cause you lots of confusion and grief. Minimize these feelings by trying a few new things.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start Building
&lt;/h3&gt;

&lt;p&gt;Build your own projects that you know you can finish, as well as some that push your limits and challenge the mind (you do not need to do big projects starting out). This is what I call learning through the struggle. My best learning experiences were those 'ah-ha' moments where I consistently threw everything I had at a problem. It is okay not to know, what matters is learning how to approach problems and solve them. Do not be afraid to try new things or completely break them! &lt;/p&gt;

&lt;h3&gt;
  
  
  Use Your Resources
&lt;/h3&gt;

&lt;p&gt;There are many resources besides video tutorials that teach new concepts, show examples, and help you hit the ground running. The great thing about coding is that your idea has probably been made before. Look up your idea on Google, Github, and Stack Overflow to see if someone has already solved your problem. Many developers even breakdown their code line by line. &lt;/p&gt;

&lt;p&gt;Here are a few resources that have helped me.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.codewars.com/"&gt;Code Wars&lt;/a&gt;: Master code through fun and unique challenges&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://brilliant.org/"&gt;Brilliant&lt;/a&gt;: Contains computer science challenges and other skills&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://stackoverflow.com/"&gt;Stack Overflow&lt;/a&gt;: A community for developers to share information and learn from each other&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Code Wars and Stack Overflow are the two that I used to build a solid foundation with Ruby. I was able to think outside the box by solving Code Wars kata. I could find problems that have already been solved on Stack Overflow when code-curious or if I hit roadblocks. Stack Overflow is generally more reliable than doing a simple Google search because of their upvote system and high-quality answers. You can get some great perspective from viewing other peoples' code. &lt;/p&gt;

&lt;h3&gt;
  
  
  Join a Community
&lt;/h3&gt;

&lt;p&gt;Join a coding community in real-life by using sites like Meetup, Facebook and Craigslist to find meetings. For the introverted folks like myself, you can still get lots of benefits from networking virtually. Discord, Twitter, Facebook and even DEV are great options. You can learn from others, find a mentor, collaborate on projects, and teach others. Do not be afraid to put yourself out there. Connect with others who have similar goals and interests. Having someone you can reach out to when you hit a road bump or just having some friends with similar interests is wholesome and invaluable. It can make things feel more real, and you less alone. &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Things Up
&lt;/h2&gt;

&lt;p&gt;I hope that reading this post provided some useful information, or at least helped motivate and guide you in the right direction. I myself, only watched tutorials for a VERY long time. It was only recently that I started building and breaking things, and I still have not done anything significant. I can say building my own applications for two hours has proven to be much more effective than watching tutorials for four times as many hours. Do not be afraid of failure. Fixing our mistakes provides some of the most valuable learning experiences. Just get started!&lt;/p&gt;




&lt;p&gt;Please feel free to leave comments and feedback. What has your experience been like learning to code? How did you escape tutorial hell? If you are still in it now, what steps will you take to get out? Do not be shy, I truly welcome your perspective!&lt;/p&gt;

</description>
      <category>motivation</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
