<?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: spencer-w-mathews</title>
    <description>The latest articles on DEV Community by spencer-w-mathews (@spencerwmathews).</description>
    <link>https://dev.to/spencerwmathews</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%2F878250%2F4d648461-cac0-4bf7-9958-ad4806976eb5.jpg</url>
      <title>DEV Community: spencer-w-mathews</title>
      <link>https://dev.to/spencerwmathews</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/spencerwmathews"/>
    <language>en</language>
    <item>
      <title>Active Record Validations</title>
      <dc:creator>spencer-w-mathews</dc:creator>
      <pubDate>Tue, 13 Sep 2022 19:53:32 +0000</pubDate>
      <link>https://dev.to/spencerwmathews/active-record-validations-44f9</link>
      <guid>https://dev.to/spencerwmathews/active-record-validations-44f9</guid>
      <description>&lt;p&gt;Validations are used in order to ensure that the data persisted to the database is valid. &lt;/p&gt;

&lt;h1&gt;
  
  
  Why Validate?
&lt;/h1&gt;

&lt;p&gt;Validations can help ensure input data is compatible with existing data. They can help assure a valid email address or username is used. They can make sure a data set designed to be integers only stays that way.&lt;/p&gt;

&lt;h1&gt;
  
  
  Common Validations
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;acceptance&lt;/li&gt;
&lt;li&gt;validates_associated&lt;/li&gt;
&lt;li&gt;confirmation&lt;/li&gt;
&lt;li&gt;comparison&lt;/li&gt;
&lt;li&gt;exclusion&lt;/li&gt;
&lt;li&gt;format&lt;/li&gt;
&lt;li&gt;inclusion&lt;/li&gt;
&lt;li&gt;length&lt;/li&gt;
&lt;li&gt;numericality&lt;/li&gt;
&lt;li&gt;presence&lt;/li&gt;
&lt;li&gt;absence&lt;/li&gt;
&lt;li&gt;uniqueness&lt;/li&gt;
&lt;li&gt;validates_with&lt;/li&gt;
&lt;li&gt;validates_each&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sources: &lt;a href="https://guides.rubyonrails.org/active_record_validations.html#validations-overview"&gt;https://guides.rubyonrails.org/active_record_validations.html#validations-overview&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is an API?</title>
      <dc:creator>spencer-w-mathews</dc:creator>
      <pubDate>Tue, 13 Sep 2022 19:29:36 +0000</pubDate>
      <link>https://dev.to/spencerwmathews/what-is-an-api-302m</link>
      <guid>https://dev.to/spencerwmathews/what-is-an-api-302m</guid>
      <description>&lt;p&gt;An API (Application Programming Interface) is the mechanism used to allow the client and server to communicate. The API takes the clients request brings it to the server receives the data from the server and returns it to the client in a way they can read.&lt;/p&gt;

&lt;h1&gt;
  
  
  Real life example:
&lt;/h1&gt;

&lt;p&gt;If you are the client when you walk into a bank then the teller who takes your request and returns you money or information is the API. The API allows the user to communicate with the banks data. &lt;/p&gt;

</description>
      <category>api</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>MVC-What is it?</title>
      <dc:creator>spencer-w-mathews</dc:creator>
      <pubDate>Fri, 12 Aug 2022 22:39:04 +0000</pubDate>
      <link>https://dev.to/spencerwmathews/mvc-what-is-it-2075</link>
      <guid>https://dev.to/spencerwmathews/mvc-what-is-it-2075</guid>
      <description>&lt;p&gt;MVC is a software design pattern that separates the data, layout, and routes. This creates a division of labor or "separation of concerns" that allows for easier maintenance.&lt;/p&gt;

&lt;h1&gt;
  
  
  Model
&lt;/h1&gt;

&lt;p&gt;The model decides what data the app should hold. If data changes then the model will tell the view.&lt;br&gt;
In a rails/react application the models would be located within the app folder and they would be written in ruby.&lt;/p&gt;

&lt;h1&gt;
  
  
  View
&lt;/h1&gt;

&lt;p&gt;The view is the screen of the app the decides which data to display.&lt;br&gt;
In a rails/react application this would be the react portion. The front-end which displays the data to the end-user.&lt;/p&gt;

&lt;h1&gt;
  
  
  Controller
&lt;/h1&gt;

&lt;p&gt;The controller possesses logic with the ability to update the models and/or view in response to actions from the end-user.&lt;br&gt;
In a rails/react application the controllers would be located within the app folder and they would be written in ruby.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RYVYxZyc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctwk10p79wozm30b2ppg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RYVYxZyc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctwk10p79wozm30b2ppg.png" alt="Image description" width="311" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;sources: &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/MVC"&gt;https://developer.mozilla.org/en-US/docs/Glossary/MVC&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mvc</category>
      <category>react</category>
      <category>ruby</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Information Flow in React.js</title>
      <dc:creator>spencer-w-mathews</dc:creator>
      <pubDate>Fri, 15 Jul 2022 12:53:10 +0000</pubDate>
      <link>https://dev.to/spencerwmathews/information-flow-in-reactjs-2e19</link>
      <guid>https://dev.to/spencerwmathews/information-flow-in-reactjs-2e19</guid>
      <description>&lt;p&gt;&lt;strong&gt;Why is information flow in React.js different from JavaScript?&lt;/strong&gt;&lt;br&gt;
    In traditional JS programming a single page document was used to accomplish all actions. This means scope of variables is the only barrier for communication from function to function. React.js allows the use of components which significantly increase the organization and readability of the JavaScript in the application. React.js grants the ability to make a component hierarchy or tree of components. This tree of components need a way of communicating with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to pass information down the tree&lt;/strong&gt;&lt;br&gt;
    Information passes from the parent component to child component with the use of props. &lt;br&gt;
These props have to be passed to child:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react"
import Child from "./Child"

function Parent(){
const x="this is from my parent"
return(
   &amp;lt;Child x={x}/&amp;gt;
)
}

export default Parent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, accepted by the child:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react"

function Child({x}){
return(
   console.log(x)
)
}

export default Child;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The console.log in this Child component would output the string assigned to x from the parent function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to pass information back up the tree&lt;/strong&gt;&lt;br&gt;
    Passing information back up the tree otherwise known as inverse data flow gets a little more complicated. To do this a function from the parent component must be passed to the child and then called with the data needed in the parent component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react"
import Child from "./Child"

function Parent(){
  function getName(nameFromChild){
    console.log(name)
  }
return(
   &amp;lt;Child getName={getName}/&amp;gt;
)
}

export default Parent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, accepted by the child:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react"

function Child({getName}){
  const name="Steve"
  getName(name)
}

export default Child;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return a console.log of "Steve".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
  The woes of information flow may seem daunting at first. After passing hundreds of props and callback functions up and down component trees it feels like second nature, and the gains you receive in terms of organization and readability far outweigh the slight learning curve. Thank you for reading!!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding Scope In JavaScript</title>
      <dc:creator>spencer-w-mathews</dc:creator>
      <pubDate>Thu, 16 Jun 2022 19:28:58 +0000</pubDate>
      <link>https://dev.to/spencerwmathews/understanding-scope-in-javascript-40e3</link>
      <guid>https://dev.to/spencerwmathews/understanding-scope-in-javascript-40e3</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is scope in JavaScript?&lt;/strong&gt;&lt;br&gt;
  Every variable within JavaScript has a scope. The scope of the variable governs the variables accessibility. The accessibility of the variable is where you are able to access the variable within the JavaScript you are working with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Different types of scope&lt;/strong&gt;&lt;br&gt;
        &lt;strong&gt;Global Scope&lt;/strong&gt;&lt;br&gt;
             Global scope occurs when a variable is accessible from anywhere within the file. When a variable is declared outside of any function the variable will be accessible globally.&lt;br&gt;
The three ways to declare a variable (var, let, const) will all act the same when declared globally.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let name = "foo"&lt;br&gt;
//name variable can be accessed&lt;br&gt;
function whatsName(){&lt;br&gt;
//name variable can be accessed&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
        &lt;strong&gt;Function Scope&lt;/strong&gt;&lt;br&gt;
             Functions all have Function Scope. Function scope means variables declared within a function are accessible only within the function. Just as with Global Scope the three ways to declare a variable (var, let, const) will all act the same when declared globally.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function functionScope() {&lt;br&gt;
  let = "variable";   // Function Scope&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
        &lt;strong&gt;Block Scope&lt;/strong&gt;&lt;br&gt;
             Block Scope denies access to variables declared within an {} block from outside. This wasn't established until 2015. Block Scope is only possible with const and let. Var allows variables to be accessed from outside the {} block.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
  let variable = 2;&lt;br&gt;
}&lt;br&gt;
// variable can not be accessed here&lt;br&gt;
{&lt;br&gt;
  var variable = 2;&lt;br&gt;
}&lt;br&gt;
// variable can be accessed here&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do you need to understand scope?&lt;/strong&gt;&lt;br&gt;
      Understanding the scope of each variable declared within a JavaScript file lets the author of the code to be more agile and accurate. Scope can cause headaches and hang-ups. Not having a solid understanding of scope costs time. Hopefully, this blog post adds to your understanding of Scope.&lt;/p&gt;

&lt;p&gt;source(s): &lt;a href="https://www.w3schools.com/js/js_scope.asp"&gt;W3 Schools&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
