<?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: WizardofHause</title>
    <description>The latest articles on DEV Community by WizardofHause (@wizardofhause).</description>
    <link>https://dev.to/wizardofhause</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%2F940614%2F5f0e05a7-1bac-424d-a0af-f840fef2a9dc.png</url>
      <title>DEV Community: WizardofHause</title>
      <link>https://dev.to/wizardofhause</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wizardofhause"/>
    <language>en</language>
    <item>
      <title>TypeScript? But WHY...?</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Fri, 28 Apr 2023 23:58:37 +0000</pubDate>
      <link>https://dev.to/wizardofhause/typescript-but-why-2dbd</link>
      <guid>https://dev.to/wizardofhause/typescript-but-why-2dbd</guid>
      <description>&lt;h2&gt;
  
  
  What &lt;em&gt;is&lt;/em&gt; TypeScript?
&lt;/h2&gt;

&lt;p&gt;It seems like it’s on every job post, listed right after to Python. But… what is it? Well, I know that &lt;em&gt;Java&lt;/em&gt; is NOT &lt;em&gt;JavaScript&lt;/em&gt;, so does that mean that &lt;em&gt;TypeScript&lt;/em&gt; is also decidedly NOT &lt;em&gt;JavaScript&lt;/em&gt; in an annoyingly misleading way? I was happy to hear that NO! TypeScript is like combining Java AND JavaScript together! I know, sounds lame, and in a way it is, but in a &lt;em&gt;good&lt;/em&gt; way… &lt;/p&gt;

&lt;p&gt;TypeScript is basically the &lt;em&gt;well, actuallyyyy&lt;/em&gt; version of JavaScript. In all the ways that JavaScript is free-spirited and liberal with it’s return values and vague with it’s error messages, TypeScript is the nerdy sibling that knows all the rules to the boardgames and is very eager to correct you when you’re wrong. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/26xBEvN97V0zPnx3G/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/26xBEvN97V0zPnx3G/giphy.gif" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The extra cool thing is that all JavaScript is apparently valid TypeScript. The main difference is that in TypeScript, we take the data type assignments -- kinda similar to the syntax used in Java -- and use them to smooth out the &lt;em&gt;adorable&lt;/em&gt; and often &lt;em&gt;incorrect&lt;/em&gt; guessing game that JavaScript sometimes plays with our data types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name = "Frank";
let age = 25;
console.log(name + age) 
//=&amp;gt; "Frank25"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;☝️ This is technically valid JS, but wouldn't it be better if it threw an error message instead of doing that pretty much useless concatenation?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let hasOranges = true; 
hasOranges = 5; // &amp;lt;- A boolean to a number? GROSS! WEIRD!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;☝️ This is &lt;em&gt;also&lt;/em&gt; valid JS, but has the potential to cause some pretty obnoxious problems. That's where TypeScript comes in handy.&lt;/p&gt;

&lt;p&gt;TypeScript basically &lt;em&gt;extends&lt;/em&gt; JavaScript and is intended to encourage us as developers to be more explicit about the data &lt;em&gt;types&lt;/em&gt; that we’re throwing around in our code. That’s where the &lt;em&gt;type&lt;/em&gt; in _Type_Script comes from. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/87jGhdRVzUOJNh2s0q/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/87jGhdRVzUOJNh2s0q/giphy.gif" width="600" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, you can specify a type by annotating it during variable declaration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let playerName: string = 'Kevin';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here &lt;code&gt;playerName&lt;/code&gt; is our variable, and we’re telling our program that &lt;code&gt;playerName&lt;/code&gt; should only be assigned &lt;code&gt;string&lt;/code&gt; values. &lt;/p&gt;

&lt;p&gt;By using a &lt;code&gt;:&lt;/code&gt; and then the type name (&lt;code&gt;string&lt;/code&gt;), we tell Typescript that the variable that we’re initializing should &lt;em&gt;always&lt;/em&gt; be a string.&lt;/p&gt;

&lt;p&gt;Typescript is basically an add-on, or like a JavaScript &lt;em&gt;expansion&lt;/em&gt; if you will, that puts a stronger emphasis on enforcing data type restrictions for variables, so that they cannot be changed.&lt;/p&gt;

&lt;p&gt;But...why would we want to do this? JavaScript already works fine, right? Sure, you’re not wrong. Especially if you’re working on a solo project or within a smaller dev team. But when projects need to scale up, and as teams get larger and larger, TypeScript helps to nail down the data types that are expected in the code of the program or application. It also reduces the time and effort we would normally have to take to debug or make updates to our code, when the need inevitably arises. Nerds save the day, once again. &lt;/p&gt;

&lt;h3&gt;
  
  
  TL;DR
&lt;/h3&gt;

&lt;p&gt;Typescript is really useful for working in teams. There’s less guesswork and it’s more-or-less easier to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ToMjGpRhf96j23aTc5i/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ToMjGpRhf96j23aTc5i/giphy.gif" width="350" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's all for now! This post was intentionally short and sweet, since my last one was such a beast. I'll have more installments on my exploration into TypeScript as I work through the problems &lt;a href="https://typescript-exercises.github.io/"&gt;HERE&lt;/a&gt;. I'm already through the first 4, so stay tuned for more notes!&lt;/p&gt;

&lt;p&gt;As always, if you have any questions, comments, or recommendations for edits, feel free to reach out! You can find me on &lt;a href="https://www.linkedin.com/in/jon-hause/"&gt;LINKEDIN&lt;/a&gt; and I welcome any and all feedback.&lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Life After Bootcamp</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Mon, 10 Apr 2023 23:46:57 +0000</pubDate>
      <link>https://dev.to/wizardofhause/life-after-bootcamp-2c64</link>
      <guid>https://dev.to/wizardofhause/life-after-bootcamp-2c64</guid>
      <description>&lt;p&gt;So you just graduated bootcamp and you have no idea what to do next, right? I mean, you probably have an &lt;em&gt;idea&lt;/em&gt;, but if you’re anything like me, you’ll need more than an idea to keep your head in the game. &lt;/p&gt;

&lt;p&gt;After a few months of experimenting and finding out what &lt;em&gt;doesn't&lt;/em&gt; work, I found a couple of methods and strategies that do. This list might not be your cuppa, and it certainly isn't exhaustive, but it comes from my personal experience and I love making blog posts about things that can't be found from just a simple Google search. &lt;br&gt;
I'll also give a few tips on what I think should be avoided, because often times knowing what NOT to do is more helpful than vague bullshit about what TO do. &lt;/p&gt;

&lt;p&gt;From my experience, there are 5 things that you need to focus on after bootcamp in order to survive in the wild, and they are: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Structure&lt;/li&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;li&gt;Education&lt;/li&gt;
&lt;li&gt;Connection&lt;/li&gt;
&lt;li&gt;Patience&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s break these down, and I’ll show you what I mean.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structure
&lt;/h3&gt;

&lt;p&gt;This one might seem like a no-brainer, but I had to get suuuper granular about this. I found out within the first 2 weeks that, first and foremost, I needed a &lt;em&gt;routine&lt;/em&gt;. I know there are scores of scheduling apps out there -- I'm partial to good ol' Google Calendar -- but if you already have one that works, then you're a step ahead of where I was, so keep that shit up. &lt;/p&gt;

&lt;p&gt;But for me, I needed &lt;em&gt;specificity,&lt;/em&gt; I was a lost child in a busy shopping mall and I needed an adult. So I broke out the good ol' pen-and-paper and wrote down everything I was going to do for every hour throughout the day. If I was going to research something, I wrote down &lt;em&gt;specifically&lt;/em&gt; what I was going to research and did nothing else. If I was going to take a break, I wrote down &lt;em&gt;specifically&lt;/em&gt; what I was going to do &lt;em&gt;during that break&lt;/em&gt; and nothing else. If I was going to eat, I wrote down &lt;em&gt;specifically&lt;/em&gt; what I was going to eat and nothing else. The way I figured, making decisions takes time, so I wanted to take as much of my brain out of the decisions as I could. If I made all my daily decisions when I was writing my schedule, I wouldn't get overwhelmed by decision fatigue from the little things. &lt;/p&gt;

&lt;p&gt;Unfortunately, I found out quickly that this technique wasn't enough, that I needed to get EVEN MORE specific, and I found ultimate clarity from the book &lt;a href="https://2hourjobsearch.com/"&gt;The 2-Hour Job Search&lt;/a&gt;. Y'all...I really can't recommend this book enough. Instead of regurgitating vague tips from some shitty blog post(!), this book gave me step-by-step action items to focus my job search and prioritize my time effectively. Stop right now, get yourself a copy, and read it. Your whole life will thank you for it and you'll stop wasting time on &lt;em&gt;satisficing&lt;/em&gt; strategies.&lt;/p&gt;

&lt;p&gt;TIME is the most valuable resource we have, especially as job seekers. So in that regard, I also gotta give a shoutout to the &lt;a href="https://en.wikipedia.org/wiki/Pomodoro_Technique"&gt;Pomodoro Technique&lt;/a&gt; for managing time (this method is particularly effective for those of us with more of a &lt;em&gt;deficit&lt;/em&gt; in our &lt;em&gt;attention&lt;/em&gt;). Basically you set a timer for 25 minutes and during those 25 minutes you DO A THING. Once the timer is up, you take a break for 5 minutes to DO NOT DO THE THING. I typically spend this break stretching, filling water bottles, getting snacky, or doing small chores. The trick is to stick to the timer as best as you can without turning into your own Drill Sargent. You gotta give yourself grace ALWAYS, which brings me to the next point...&lt;/p&gt;

&lt;h3&gt;
  
  
  Motivation
&lt;/h3&gt;

&lt;p&gt;This is a big one, and it's potentially the most fragile. When motivation isn't there, the job search just becomes like a form of self-terrorism, and we don't negotiate with terrorists folks. So I try to find motivation anywhere and everywhere, but I find it most useful to have something concrete to draw on when I'm feeling like a frump-a-dump and don't wanna do &lt;em&gt;anything.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Podcasts are usually my first source. Shows like &lt;a href="https://www.codenewbie.org/podcast"&gt;CodeNewbie&lt;/a&gt; and &lt;a href="https://parsity.io/podcast/"&gt;Develop Yourself&lt;/a&gt; both offer a really great perspective on how to approach the tech industry as a career changer, and are specifically geared toward us recent bootcamp grads and tech n00bz. I have to add a personal disclaimer though; podcasts are great, and they're a fantastic way to get tips and tricks for tackling the job search, but just like watching code tutorials on YouTube, they are by no means a substitution for actually doing the thing yourself. Take that as a word of warning, Future Self. Because I love podcasts. &lt;/p&gt;

&lt;p&gt;My second source is social media influencers, which feels lame to admit, but I don't have time for feeling lame if it works. One of my favorites is &lt;a href="https://www.linkedin.com/in/markallenthompson/"&gt;Mark Thompson&lt;/a&gt;, who is the Senior Developer Relations Engineer at Google, so he literally does this for a living. He's energizing and insightful, and I really look forward to his #GoodMorningWithMark motivation posts on LinkedIn.&lt;/p&gt;

&lt;p&gt;Another great source is a Twitch Streamer &amp;amp; YouTuber, &lt;em&gt;his name is Michael Paulson,&lt;/em&gt; but he's better known as &lt;a href="https://www.twitch.tv/theprimeagen"&gt;ThePrimeagen&lt;/a&gt;. His approach is a little more off-the-cuff and is definitely not for the feint of heart, but I appreciate his blunt honesty and "non-traditional" style. He's also got a fantastic DS&amp;amp;A course on &lt;a href="https://frontendmasters.com/courses/algorithms/"&gt;Frontend Masters&lt;/a&gt;, which is a great segue to the next point...&lt;/p&gt;

&lt;h3&gt;
  
  
  Education
&lt;/h3&gt;

&lt;p&gt;This one is a lot more open-ended, and the pool of available resources is a goddamn &lt;em&gt;ocean.&lt;/em&gt; From &lt;a href="https://www.algoexpert.io/product"&gt;AlgoExpert&lt;/a&gt; to &lt;a href="https://www.trywilco.com/"&gt;Wilco&lt;/a&gt;, there is no shortage of platforms to choose from. EdTech is a huge industry (and one that I would be very interested in joining 😅), but no matter what route you choose, you gotta keep those skills sharp. The top three that I've used most-often and continue to go back to are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/"&gt;Udemy&lt;/a&gt; - The whole catalog is great and super expansive, but any class by Colt Steele is a winner in my book. He's got a witty and fresh approach to learning and is great at translating abstract concepts into human-speak. He's got a cat named Blue and he regularly talks shit about himself. He gets it. &lt;br&gt;
BONUS! If you're a Colorado resident, you can get FREE ACCESS to ALL UDEMY COURSES with a &lt;a href="https://link.gale.com/apps/UDEMY?u=denver"&gt;Denver Public Library Card&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.scrimba.com/"&gt;Scrimba&lt;/a&gt; - This is 100% front-end material, but any and every course is awesome because their interface is awesome. You can pause the screencasts and futz with the instructor's code right in your browser. They even have a little in-cast browser that you can test your code on. You can save your code snippets in the screencast, and it’s just a really fabulous platform to get your hands dirty with no environment setup. I went for the full subscription and I use it more often than I use my Crunchyroll account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.edx.org"&gt;edX&lt;/a&gt; - This is a great platform for literally hundreds of different courses, but &lt;a href="https://www.edx.org/course/introduction-computer-science-harvardx-cs50x"&gt;Harvard's CS50&lt;/a&gt; is a great place to start. It's an Intro to Computer Science class and gives you a more in-depth understanding of how all this crazy computer stuff works, altogether. You can sign up for the course to get access to the full materials and labs and stuff, but alternatively all the videos are on &lt;a href="https://www.youtube.com/channel/UCcabW7890RKJzL968QWEykA"&gt;YouTube&lt;/a&gt; if you just want to passively observe. They also have a Discord channel where you can connect to the full community of CS50 students, which is yet another fabulous segue to the next point...&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Connection
&lt;/h3&gt;

&lt;p&gt;With all the tools I've already listed, I still find it reeeeally easy to slip into my head and let the imposter syndrome take hold. With the amount of rejection letters I'm getting and level of information that I &lt;em&gt;should be learning,&lt;/em&gt; it's an easy trap to fall into. Fortunately, I found the cure for this in &lt;em&gt;positive human interaction.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;I started by integrating this concept slowly. I was applying anywhere and everywhere and getting nothing but rejection emails from robots, which just murdered my motivation. So instead of counting the number of applications I was sending in week-over-week, I started tracking the number of &lt;em&gt;people&lt;/em&gt; that I was interacting with and reaching out to. I quickly got comfortable with virtual meetings and awkward informational interviews, and it got easier and easier each time. What's more is that I would get a huge boost in confidence from talking to people, regardless of whether they had a job opportunity for me or not. Before long, I was ready to attend in-person tech events, &lt;em&gt;alone.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As awkward and terrifying as most of them seem at first, I really can't recommend in-person events enough. Attending online events is one thing, but awkwardly stumbling through an introductory conversation with a stranger in-person is very, very rewarding. It helps break down those social anxiety barriers and gets me better acquainted with the awkwardness of talking to strangers. It’s weird, and it’s hard to get used to, but it's had a genuine positive net effect on my networking skills. I still hate it, and it still makes me anxious to go out to random meetups by myself, but each time it gets a little easier and even if the meetup isn’t what I'd hoped, I still put in the effort and got myself out there, and even that alone is progress.  &lt;/p&gt;

&lt;p&gt;Also, as a bootcamp grad, it really helps me to touch base with my cohort. I really like keeping those contacts fresh because they’re going through the same things that I am, and can offer a helpful dose of perspective. &lt;/p&gt;

&lt;p&gt;Keep in mind that another person’s success does not inherently diminish your own! Rather it builds momentum and gives energy to the overall process that helps everyone to grow. And what's that? Another segue!&lt;/p&gt;

&lt;h3&gt;
  
  
  Patience
&lt;/h3&gt;

&lt;p&gt;The Great Mark Thompson recently had a post where he talks about what he calls &lt;a href="https://www.linkedin.com/posts/markallenthompson_goodmorningwithmark-activity-7046103584165302272-TUgU?utm_source=share&amp;amp;utm_medium=member_desktop"&gt;The Formula&lt;/a&gt;. Essentially, the path to achievement is &lt;code&gt;discipline + grace = success&lt;/code&gt; and it has been tremendously helpful for me. I have to stay disciplined and make sure that I'm keeping my eyes on the prize, but if I have an off day, or I miss an opportunity, I have to be able to take that in stride and learn from it. I can't be 100% perfect, 100% of the time, but &lt;em&gt;consistency&lt;/em&gt; is much more valuable than &lt;em&gt;perfection.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Job hunting SUCKS! And with all the added distractions and negative news stories and layoffs and recessions and &lt;a href="https://www.nytimes.com/2023/02/17/podcasts/hard-fork-bing-ai-elon.html"&gt;AI bots falling in love with us&lt;/a&gt;, it's easy to get overwhelmed and lose hope. But if I remember to take it easy on myself and remember that even if today didn't go so well, I still have tomorrow to learn and grow and move forward towards my goal of becoming a software engineer. &lt;/p&gt;

&lt;p&gt;Honestly, I've made plenty of mistakes and I've gotten a lot wrong on my job search so far, but I know that learning happens by making errors. Also, being a beginner in this space is &lt;em&gt;liberating&lt;/em&gt; because nobody cares! One of my career coaches told me early on that being overly considerate and excessively gracious doesn't do me any favors. I can fuck everything up on purpose and come out better for it if I keep a &lt;a href="https://www.youtube.com/watch?v=hiiEeMN7vbQ"&gt;growth mindset&lt;/a&gt;. &lt;br&gt;
Give. Yourself. Grace.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Do's &amp;amp; Don'ts
&lt;/h3&gt;

&lt;p&gt;Fresh-faced devs are prime targets for predators. I learned early on to watch out for things like places that guarantee job placement, but only after an extended period of minimum-wage "paid training," or that have a weird catch boiled in like a relocation &lt;em&gt;requirement&lt;/em&gt; or a percentage cut from your future salary. I won't mention these places by name because I'm certain that some people find success through them, but in my experience, I quickly discovered that if I needed to sign a contract that I have to pay to get out of, then it's not for me. &lt;/p&gt;

&lt;p&gt;Long story short, do your research, Google &lt;em&gt;every. single. company.&lt;/em&gt; that sends you an offer. Read the reviews, and talk to other devs to get their perspective. Most of the time, if it seems too good to be true, or they're making an unsolicited offer, then there's probably a huge catch. &lt;/p&gt;

&lt;p&gt;Finally, do whatever you can to optimize your physical health. Learn from my mistakes. Don't smoke cigarettes. Don't fuck around with your sleep schedule. Don't stay inside all day long. Develop a solid &lt;a href="https://youtu.be/gR_f-iwUGY4"&gt;morning routine&lt;/a&gt; and stick to it. &lt;br&gt;
Meditate. Drink water. Get sunlight.&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing Thoughts
&lt;/h3&gt;

&lt;p&gt;Life after bootcamp is tough, and it’s not easy to stay focused after all the structure falls away. Thankfully, there are plenty of resources out there to help you. &lt;/p&gt;

&lt;p&gt;Also, here’s a link to &lt;a href="https://www.youtube.com/watch?v=Yo1V2FFvaQQ"&gt;Life After Lisa by Bowling for Soup&lt;/a&gt;, which was in my head the entire time I was writing this blog post and is apparently turning 23-years-old this year. Shout out to Butch Walker for making all the catchy tunes of my misbegotten youth. &lt;/p&gt;

&lt;p&gt;And that's that! Thank you so much for making it this far. I know this is kind of a beefy post, but I've learned a lot in the last few months and I think it's definitely worth sharing.&lt;/p&gt;

&lt;p&gt;As always, if you have any questions or recommendations for edits, feel free to reach out. I welcome any and all feedback.&lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>learning</category>
    </item>
    <item>
      <title>ERRORS: Bang, Rescue, Repeat.</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Mon, 12 Dec 2022 19:54:12 +0000</pubDate>
      <link>https://dev.to/wizardofhause/errors-bang-rescue-repeat-1j4c</link>
      <guid>https://dev.to/wizardofhause/errors-bang-rescue-repeat-1j4c</guid>
      <description>&lt;p&gt;So let's assume that we've got our Rails API all set up, our models in place, and everything is working hunky-dory. Except for when it isn't. Our validations are set up, and they definitely work...but how do we know??&lt;/p&gt;

&lt;p&gt;Server-Side Validations define how our application communicates with the server and determines what data is returned. So, let's explore how these validations are sent to the controller and displayed on the &lt;em&gt;client-side.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Through our &lt;strong&gt;controller actions&lt;/strong&gt; we can use the method &lt;code&gt;.valid?&lt;/code&gt; inside of a conditional &lt;code&gt;if...else&lt;/code&gt; statement to determine whether or not our program should render json data, or an error message. We can think of it like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before saving an Active Record object, Rails runs our validations. If these validations produce any errors, Rails does not save the object.&lt;/li&gt;
&lt;li&gt;We can also run these validations on our own. &lt;a href="https://api.rubyonrails.org/v7.0.4/classes/ActiveRecord/Validations.html#method-i-valid-3F"&gt;valid?&lt;/a&gt; triggers our validations and returns true if no errors were found in the object, and false otherwise.

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://api.rubyonrails.org/v7.0.4/classes/ActiveModel/Validations.html#method-i-invalid-3F"&gt;invalid?&lt;/a&gt; is the inverse of &lt;code&gt;valid?&lt;/code&gt;, it triggers our validations, returning true if any errors were found in the object, and false otherwise.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7C_no03I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zj3l9os6ofwzj3qtx84t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7C_no03I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zj3l9os6ofwzj3qtx84t.png" alt="Example if...else" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;create&lt;/code&gt; action is now saying… &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;if&lt;/code&gt; the parameters that the user passed through as input values to &lt;code&gt;book_params&lt;/code&gt; are valid and &lt;code&gt;book.valid?&lt;/code&gt; evaluates as &lt;code&gt;true&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;then render the object as created and persist the data to our database.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;else&lt;/code&gt; if the parameters did not pass our validation, and &lt;code&gt;book.valid?&lt;/code&gt; evaluates as &lt;code&gt;false&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;then the application returns all of the error message as an array of strings&lt;/li&gt;
&lt;li&gt;and sets the status code to &lt;code&gt;422 :unprocessable_entity&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The thing that was tough to grasp as a beginner was, using the if...else statement above does not persist our data to the database when a validation fails, but instead returns a &lt;em&gt;nil object&lt;/em&gt;, or an empty object that looks 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;=&amp;gt; #&amp;lt;Book id: nil, title: nil, author: nil, description: nil, page_count: nil, year: nil, created_at: nil, updated_at: nil&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important thing to identify here is &lt;strong&gt;id: nil&lt;/strong&gt;. Other values may be different, but &lt;strong&gt;id: nil&lt;/strong&gt; tells us that this object did not receive an id when it was created, so its data has not persisted to our database. &lt;/p&gt;

&lt;p&gt;…which is confusing. Because even though our instance did in fact fail our validations, we still received what looks like a valid object as a return value. How are you supposed to know if it passed? Check &lt;em&gt;every single id???&lt;/em&gt; Of course not, silly goose. That’s where .create!() comes in to &lt;em&gt;rescue&lt;/em&gt; us &lt;em&gt;from&lt;/em&gt; nil objects!&lt;/p&gt;

&lt;p&gt;.create!() does not create an instance object with nil values, but instead raises an exception, or a return value that includes all our validation error messages, which looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**ActiveRecord::RecordInvalid (Validation failed: Title can't be blank, Author can't be blank, Description can't be blank, Page Count can't be blank, Year can't be blank, Page count is not a number, Year is not a number)**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This return helps us to identify that our instance failed by returning error codes instead of an object that looks like it’s valid, but isn’t. &lt;/p&gt;

&lt;p&gt;We can use &lt;code&gt;rescue&lt;/code&gt; from within our create controller action to render the exception’s error message as a JSON response&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F5OMOL5D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in0g5n1gl9bvbt6qlgpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5OMOL5D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in0g5n1gl9bvbt6qlgpb.png" alt="rescue Example" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ALTERNATIVELY we can refactor and make this cleaner by using the method rescue_from to give specific instructions to our application for what to do when any exception is raised within our model, for any controller action. &lt;/p&gt;

&lt;p&gt;We identify the exception using a specified name (i.e. ActiveRecord::RecordInvalid) and associating a private method called a validation helper and &lt;strong&gt;with&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tCD3EJnF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5c7ernlox43hvy8zog6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tCD3EJnF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5c7ernlox43hvy8zog6.png" alt="rescue_from example" width="800" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.record&lt;/code&gt; is a built-in method, used to retrieve the record which did not validate.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.errors&lt;/code&gt; is a built-in method, through which we can drill down into the various details of each error. After Active Record has performed validations, any errors found can be accessed through the &lt;a href="https://api.rubyonrails.org/v7.0.4/classes/ActiveModel/Validations.html#method-i-errors"&gt;errors&lt;/a&gt; instance method.

&lt;ul&gt;
&lt;li&gt;Returns a &lt;em&gt;collection of errors&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;An object is &lt;code&gt;valid&lt;/code&gt; if the returned collection is &lt;em&gt;empty&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using method-chaining with &lt;code&gt;.record.errors&lt;/code&gt;  renders our parameter names (&lt;code&gt;:title, :author, ...&lt;/code&gt;) and their associated error messages in JSON format. It also sets the status code to &lt;code&gt;422: :unprocessable_entity&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, our helper method is &lt;code&gt;render_unprocessable_entity()&lt;/code&gt; and takes in a single argument; an object that contains all of the errors that were triggered by the newly created class instance, called an &lt;strong&gt;exception&lt;/strong&gt;.  &lt;/p&gt;




&lt;p&gt;Client-side routing is different than server-side routing - the customer experience is very very different compared to what the chef is doing - though they are, in an abstract way, still connected, they are not directly dependent on one another.  &lt;/p&gt;

&lt;p&gt;In order to get our React App to render our error responses, we need to modify the fetch request. For example, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P3HfONuL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk9fbs7rafewdgrjhvut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P3HfONuL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk9fbs7rafewdgrjhvut.png" alt="POST example" width="800" height="966"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: &lt;code&gt;response.ok&lt;/code&gt; contains a &lt;em&gt;boolean value&lt;/em&gt; stating whether the response was successful (status in the range 200-299) or not.&lt;/p&gt;

&lt;p&gt;We have to use &lt;code&gt;Object.entries&lt;/code&gt; to create our mappable array in this case because of how our &lt;code&gt;errors&lt;/code&gt; data is &lt;em&gt;nested&lt;/em&gt; inside of an &lt;em&gt;array&lt;/em&gt;, inside of an &lt;em&gt;object&lt;/em&gt;, inside of a &lt;em&gt;&lt;strong&gt;hash.&lt;/strong&gt;&lt;/em&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Data is nested in a hash with errors listed individually, and their messages as arrays…&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{errors: {”title”: [”can’t be blank”]}, {"author": ["can't be blank"]}, ...}&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Because of this, if we call &lt;code&gt;Object.entries&lt;/code&gt; on our errors, it turns our content into an &lt;em&gt;array of arrays&lt;/em&gt; with the key of a particular value in the first index and the error message in a nested array that looks like:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Object.entries(data.errors) --&amp;gt; 

[[title, ["can't be blank"]], [author, ["can't be blank"]], [page_count, ["can't be blank", "is not a number"]]...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;With this nested array, we can call &lt;code&gt;.map&lt;/code&gt; on each individual entry and use string interpolation to create an array of errors as strings that we can map through, using their index.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.map(error =&amp;gt; `${error[0]}: ${error[1]}`)

errors = ["title: can't be blank", "author: can't be blank", "page_count: can't be blank,is not a number"...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We can then use a conditional ternary statement within our component to display the error messages, if any exist.&lt;/li&gt;
&lt;li&gt;This newly created &lt;code&gt;errors&lt;/code&gt; array is then set to &lt;em&gt;state&lt;/em&gt; using our &lt;code&gt;setErrors&lt;/code&gt; function, which causes our component to re-render&lt;/li&gt;
&lt;li&gt;When the component re-renders, it checks the &lt;code&gt;errors&lt;/code&gt; state array to see if there’s anything inside of it&lt;/li&gt;
&lt;li&gt;If there is, it renders each item in the &lt;code&gt;errors&lt;/code&gt; array inside of a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's all there is for errors! From server to client side, hopefully that all makes some kind of sense. &lt;/p&gt;

&lt;p&gt;If you have any questions or recommendations for edits, feel free to reach out. I welcome any and all feedback.&lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Ruby...Covered in CRUD.</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Mon, 21 Nov 2022 01:10:55 +0000</pubDate>
      <link>https://dev.to/wizardofhause/rubycovered-in-crud-4i0h</link>
      <guid>https://dev.to/wizardofhause/rubycovered-in-crud-4i0h</guid>
      <description>&lt;p&gt;Now that we’ve made it past the halfway point at Flatiron, I'm starting to understand a lot more about what blogs are and what their basic utility is, especially for beginners. &lt;/p&gt;

&lt;p&gt;The point of blogs - at least from my perspective at this point - is to find those diamonds in the rough that hold your hand and spell out the little bits of code you‘re missing, or fire up the right light bulbs in your brain to give you the right &lt;em&gt;ah-HA!&lt;/em&gt; moment get your program working. Then you copy-paste what you can, curse at the rest, add it to your bookmarks under &lt;em&gt;Blogs &amp;amp; Stuff&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But feelings come first. And I've gotta say that starting Ruby was tough, and I think that this phase was probably the one that I struggled the most with, but in that same vein, I also learned the most. It’s gratifying and humbling at the same time, and I’m kind of in love with the feeling, but I digress...&lt;/p&gt;

&lt;p&gt;For this entry, I’ll assume that the reader is here for the same things I was looking for during Phase 3, that they also have a fair understanding of Ruby, ActiveRecord, Sinatra, and a sprinkle of SQL, and that really they’re just looking for that diamond...or &lt;em&gt;ruby&lt;/em&gt;. As such, the following are some helpful snippets that I learned during my back-end brigade. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;DATA MIGRATIONS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The order of operations for establishing our migrations and creating our tables starts by creating the migration files. Open the terminal and navigate to the project's directory. Once there, type into the console:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:create_migration create_table_name&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;NOTE: Our table names should be PLURAL, because they are tables, and they hold many instances of a single thing...they are large, they contain multitudes. For example, my group and I created a mock eCommerce website for our final project, and we needed to create a table of data for our ITEMS, so we ran: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:create_migration create_items&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This creates a time-stamped migration files that determine how the tables are set up. Inside of those files, we assign data types and the associated symbol to each 'row' of our table. &lt;/p&gt;

&lt;p&gt;For example, for our Items table, we needed a name, price, description, image URL, brand, and category. After creating our migration file, our table looked like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Km2F7GHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usr6vvki2a67tdegfzt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Km2F7GHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usr6vvki2a67tdegfzt4.png" alt="Items Table" width="528" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can assign the data types to whatever we like. Other available types are &lt;code&gt;float, decimal, numeric, datetime, time, date, timestamp, binary, primary_key, boolean, bigint,&lt;/code&gt; &amp;amp; &lt;code&gt;text&lt;/code&gt;, but integer and string seem to be the most common in BeginnerLand. And don't forget to add &lt;code&gt;end&lt;/code&gt; at the end of the &lt;code&gt;create_table&lt;/code&gt; method! Once our tables are all set up, run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:migrate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If successful, we should have a new file called &lt;code&gt;schema.rb&lt;/code&gt; in the db folder. Next, we needed to establish our relationships so our data can get to know each other and be friends. For our project &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VLWxUYap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzr64ggnmfu8qe4byhbx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VLWxUYap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzr64ggnmfu8qe4byhbx.png" alt="User Relationships" width="409" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F-Y2DIVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6bjrm6dxj4uea8875ln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F-Y2DIVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6bjrm6dxj4uea8875ln.png" alt="Item Relationships" width="409" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are 'one-to-many' relationships, as in this ONE ITEM, HAS MANY USERS that leave REVIEWS on it. So for the syntax we say &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Item has_many :reviews, through: :users&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;...and, as always, we pay extra special attention to where we put our colons. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T3M1OhNE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jea5ut6gi3r641kqo8sb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T3M1OhNE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jea5ut6gi3r641kqo8sb.png" alt="Reviews description" width="365" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is our 'many-to-many' relationship. Notice how the use of &lt;code&gt;item&lt;/code&gt; and &lt;code&gt;user&lt;/code&gt; are both SINGULAR here! That makes sense - a review can only be for ONE item and can only be written by ONE user. Once these relationships are set up we can create our SQL tables by running this code in the console:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:migrate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we have a seed file, that's amazing. If we don't, I somewhat recommend using &lt;a href="https://github.com/faker-ruby/faker"&gt;faker&lt;/a&gt; to help out. It's great for making random seeds, but my project group and I ran into some trouble manipulating the output data as beginners, so I'd say it's handy, but only to a certain degree. Once our seeds are filled in, run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake db:seed&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and that should fill up our SQL tables will some nice juicy data that we can do whatever we like with...well, whatever we know how to do. Which as beginners isn't that much, but WE GOT THIS!&lt;/p&gt;

&lt;p&gt;The next step is to set up Sinatra, which you can find much better-explained in their docs &lt;a href="https://sinatrarb.com/intro.html"&gt;HERE.&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;CREATE, READ, UPDATE, DELETE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So what about CRUD?! Well, I'm not going to give up &lt;em&gt;everything&lt;/em&gt;, but it starts with setting up the paths within our application controller. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rONvXs-m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuvlzdscya86et65knut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rONvXs-m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuvlzdscya86et65knut.png" alt="Item Methods" width="538" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those are simple GET requests. We can check our work using an application like &lt;a href="https://www.postman.com/downloads/"&gt;Postman&lt;/a&gt;, or by running &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;in the terminal, and opening up &lt;a href="http://localhost:9292"&gt;http://localhost:9292&lt;/a&gt; in the browser, followed by whatever our path name is. For example, to route to our item_all path, we would type into the browser:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:9292/item_all/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The real money-maker here is the associations within our Object-Oriented-Program. When we pull data using Sinatra ActiveRecord, we can also pull the data that that data is associated with by using &lt;code&gt;include:&lt;/code&gt;. So, if we make a route to pull a single item's data, we can also pull the &lt;em&gt;reviews&lt;/em&gt; for that item AND the &lt;em&gt;user&lt;/em&gt; data for those &lt;em&gt;reviews&lt;/em&gt;, like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E0pfvakE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm3lnlzxd9ase20jeuae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E0pfvakE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm3lnlzxd9ase20jeuae.png" alt="Find Item" width="758" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one route now allows us access to literally every bit of data that we added to our tables. That's...super neat y'all.&lt;/p&gt;

&lt;p&gt;Now what does this look like on the front end? Well we made a component that displays the details of an individual item, AS WELL AS all the &lt;em&gt;reviews&lt;/em&gt; associated with that item, AS WELL AS all of the &lt;em&gt;user data&lt;/em&gt; for whatever user wrote the review. We'll need &lt;code&gt;useState, useEffect&lt;/code&gt; and &lt;code&gt;useParams&lt;/code&gt; like so: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6hLedFZP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6xhgocj4zzvgn11qm0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6hLedFZP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6xhgocj4zzvgn11qm0p.png" alt="Imports" width="545" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our component function we set our &lt;code&gt;item&lt;/code&gt; state:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gkK_rwfd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0nic35qv06gouczjjfp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gkK_rwfd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0nic35qv06gouczjjfp.png" alt="State Setter" width="460" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we implement useEffect and add a catch if we have any trouble rendering our data for any reason. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rbQsLmE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbeqn8o207xue2bgrbif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rbQsLmE4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbeqn8o207xue2bgrbif.png" alt="Fetch &amp;amp; Catch" width="700" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then after a little destructuring, we can add our data to our JSX...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ooVwBWyw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxl3hbzcl4u5utgryk8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ooVwBWyw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxl3hbzcl4u5utgryk8o.png" alt="Destructuring &amp;amp; Building" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sweeeeeeeeeeeeeeeeeeet! Rendering data is so cool. It's trending. Or...&lt;em&gt;trendering!&lt;/em&gt; &lt;/p&gt;




&lt;p&gt;To get the rest of the CRUD, my project group and I ended up setting the list of item reviews as its own separate component, and then each individual review as a card within the component. So we had Details.js which was a parent of ReviewsList.js, which was a parent of ReviewCard.js. This allowed for us to manipulate all the data we were handling without making a huge mess out of the variable names and turning our Details file into callback hell. When in doubt, make another component.&lt;/p&gt;

&lt;p&gt;Figuring out the rest was a matter of passing through the correct data using HTTP in our Application_Controller.rb, making the correct handler functions in the correct React Component, and making sure the fetch was doing everything we needed it to do... &lt;/p&gt;

&lt;p&gt;For DELETE our application_controller.rb path was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C2jLOHy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/297ayd09br5kvdxlz6uu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C2jLOHy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/297ayd09br5kvdxlz6uu.png" alt="DELETE Path" width="393" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our HandlerFunction was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eue7YLFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fszk8cbzqhoszextsgs7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eue7YLFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fszk8cbzqhoszextsgs7.png" alt="DELETE Handler" width="708" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the accompanying fetch:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--atFxaRac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du77r35yxk05g9japkqc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--atFxaRac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du77r35yxk05g9japkqc.png" alt="DELETE Fetch" width="530" height="182"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;For POST our path was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VNanjQA8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf1onlwuvxmolvwcy344.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VNanjQA8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf1onlwuvxmolvwcy344.png" alt="POST Path" width="406" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The POST HandlerFunction was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rHsyMArb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0waeabxfd1rz7tp52upc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rHsyMArb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0waeabxfd1rz7tp52upc.png" alt="POST Handler" width="675" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the POST Fetch was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vhhoujjj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s389xlrv0ryfka59nyeh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vhhoujjj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s389xlrv0ryfka59nyeh.png" alt="POST Fetch" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;And the tricksiest little Hobbitses of them all...the PATCH path looked like:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VgRC_TpD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni4q3zlav71p5a7vqnqz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VgRC_TpD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni4q3zlav71p5a7vqnqz.png" alt="PATCH Path" width="409" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HandlerFunction was:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xISJr0Kf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpij3kwyvflhr2p7zgml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xISJr0Kf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpij3kwyvflhr2p7zgml.png" alt="PATCH Handler" width="682" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the Fetch:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TVCb4e-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsgotj1w7fqqdsu1fb2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TVCb4e-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsgotj1w7fqqdsu1fb2w.png" alt="PATCH Fetch" width="645" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... This, of course, isn't the entirety of the code for our React components, but I think it covers more than enough to get the gears turning, especially for my fellow Flatironeers.&lt;/p&gt;




&lt;p&gt;And that's it - thanks so much for making it this far! I went lighter on the gifs and heavier on the content this time. &lt;/p&gt;

&lt;p&gt;Hopefully this was helpful, especially to my fellow Flatironeers that are having trouble finding a blog where all of this stuff is literally spelled out for you. That blog now exists!&lt;/p&gt;

&lt;p&gt;If you have any questions or recommendations for edits, feel free to reach out. I welcome any and all feedback.&lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>activerecord</category>
      <category>sinatra</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>So...what is React?</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Thu, 03 Nov 2022 20:41:33 +0000</pubDate>
      <link>https://dev.to/wizardofhause/sowhat-is-react-50ae</link>
      <guid>https://dev.to/wizardofhause/sowhat-is-react-50ae</guid>
      <description>&lt;p&gt;Good day and welcome! Thank you for tuning in, let's get right to it...&lt;/p&gt;

&lt;p&gt;We just finished up with Phase-2 at Flatiron, rounding out our Front-End adventure with a jaunty sojourn to the land of React. &lt;/p&gt;

&lt;p&gt;"React," you say? Why...what's THIS? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ZpNEeC9UmJw9AOGoSb/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ZpNEeC9UmJw9AOGoSb/giphy.gif" width="480" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And better yet...why should we care? We already know how to use JavaScript, HTML, and CSS - isn't that everything there is to learn? &lt;/p&gt;

&lt;p&gt;I mean, aren't ALL websites and applications written in an overly-complicated, nightmare-vortex of JavaScript-callback-Hell from which there is no escape? &lt;br&gt;
Doesn't it take &lt;em&gt;teams&lt;/em&gt; of programmers &lt;em&gt;months and &lt;strong&gt;months&lt;/strong&gt;&lt;/em&gt; to diagnose a resolve a few lines of buggy code? &lt;br&gt;
Don't developers completely re-write their programs from the ground-up if they need to modify a few elements? &lt;br&gt;
....WHY NOT?!&lt;/p&gt;

&lt;p&gt;I hear you. And as logically sound as all of those arguments are, there is actually a reason to care. To put it simply, we use React because we love to RECYCLE!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/MwiArrrm4SlVMqLn8Y/giphy-downsized.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/MwiArrrm4SlVMqLn8Y/giphy-downsized.gif" width="384" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From React's own website - &lt;a href="https://reactjs.org/blog/2013/06/05/why-react.html"&gt;reactjs.org&lt;/a&gt;, "React is a library for building composable user interfaces. It encourages the creation of reusable UI components which present data that changes over time." &lt;/p&gt;

&lt;p&gt;So what does that mean for us humans that speak with human words? Well think of it this way; React combines the readability of HTML with the functionality of JavaScript. &lt;/p&gt;

&lt;p&gt;HTML is great, but it's also super rigid and difficult to update if we need to. Pages aren't very interactive, and manipulating their layout is a pain. &lt;/p&gt;

&lt;p&gt;One way to solve this issue is by rendering HTML elements using JavaScript and DOM manipulation, but...vanilla JavaScript sucks. It's hard to read, and everyone knows it. Vanilla JS has no friends. Like the person that invented the false X on ad windows in game apps. &lt;/p&gt;

&lt;p&gt;But since JavaScript has been around for a while, a bunch of smarty-pants people have pretty much already written all the JavaScript rules and stuff that we could ever need to render HTML elements or manipulate the DOM...mostly. I mean, chances are if you need to do a thing in JavaScript, someone else has already figured out how to do that thing. &lt;/p&gt;

&lt;p&gt;So why re-invent the wheel? Why not collect all of those JavaScript chunks together into some kind of massive library that we can access and use whenever we want? &lt;/p&gt;

&lt;p&gt;That's more-or-less what React helps us to do (even though it's not a library &lt;em&gt;per se,&lt;/em&gt; it's actually a &lt;em&gt;framework&lt;/em&gt; 🙄). As developers, we use React to call on all those rules and stuff, and make a little hybrid franken-baby chunk of code that looks &lt;em&gt;kiiiiinda&lt;/em&gt; like JS and &lt;em&gt;kiiiiiiiinda&lt;/em&gt; like HTML. &lt;/p&gt;

&lt;p&gt;React also allows us to trim our HTML to just a single file. Neat right? But wait, there's more! We can ALSO take all those persnickety little JavaScript functions and separate them out into their own little containers, where we can control their individual behavior. Then, we can pull all of those containers together into one big group - potentially using some of those containers more than once depending on their functionality - and it's that group of containers that collectively makes up our webpage. &lt;/p&gt;

&lt;p&gt;We call these little containers &lt;strong&gt;components&lt;/strong&gt;, which are basically files that hold JavaScript functions and return an HTML/JavaScript syntax mashup called JSX. From &lt;a href="https://reactjs.org/blog/2013/06/05/why-react.html"&gt;reactjs.org&lt;/a&gt;, "&lt;strong&gt;Components&lt;/strong&gt; let you split the UI into independent, reusable pieces, and think about each piece in isolation.” &lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/introducing-jsx.html"&gt;&lt;strong&gt;JSX Components&lt;/strong&gt;&lt;/a&gt; combine the markup of HTML with the logic of JavaScript to define an aspect or group of elements within a specific chunk of the user interface on our webpage.&lt;/p&gt;

&lt;p&gt;These Components all feed into one another in the same tree-like structure we’ve come to know so well. Much like literally everything else up to this point that we’ve covered, the internal structure resembles a tree, with the top of our dependency tree (typically an index.js file) importing each branched file. Developers. Love. Trees. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/vZqughbxxFLi/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/vZqughbxxFLi/giphy.gif" width="625" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React uses index.js to &lt;em&gt;render&lt;/em&gt; our components into our HTML file by using the .render method. We use document.getElementById("root") to identify a pre-existing &lt;strong&gt;div&lt;/strong&gt; element in our HTML file with the id="root", and append our JSX components to it. When our program runs, React renders our JSX components as the Children to the Parent &lt;strong&gt;div&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;The bare-bones structure of index.js looks 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;import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";
import "./index.css";

ReactDOM.render(&amp;lt;App /&amp;gt;, document.getElementById("root"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The top-parent component is conventionally named "App.js" and is imported here with the line &lt;code&gt;import App from "./components/App";&lt;/code&gt; Here's an example App 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 ExampleComponent from "./ExampleComponent";
import OtherExampleComponent from "./OtherExampleComponent";

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Welcome to React!&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;In React apps, we write JSX - 
it looks like HTML, and uses a lot of HTML syntax
...but it also looks like JavaScript, and uses a lot of JavaScript syntax...
&amp;lt;/p&amp;gt;
      &amp;lt;ExampleComponent /&amp;gt;
      &amp;lt;OtherExampleComponent /&amp;gt;
      &amp;lt;OtherExampleComponent /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Here, App is importing two children components of its own - &lt;strong&gt;ExampleComponent&lt;/strong&gt; and &lt;strong&gt;OtherExampleComponent&lt;/strong&gt; - and renders them as siblings to a &lt;strong&gt;p&lt;/strong&gt; and an &lt;strong&gt;h1&lt;/strong&gt;, all contained within a parent &lt;strong&gt;div&lt;/strong&gt;. We even have &lt;strong&gt;OtherExampleComponent&lt;/strong&gt; rendering twice! WHAAAAT?! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/PjsRHq04WuRk8U4uJo/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/PjsRHq04WuRk8U4uJo/giphy.gif" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The internal structure of ExampleComponent and OtherExampleComponent is defined within their respective JSX functions, in separate individual files. At the bottom of our &lt;strong&gt;App&lt;/strong&gt; component, we put &lt;code&gt;export default App&lt;/code&gt; so that our index.js file is able to import it to use and ultimately render that &lt;strong&gt;App&lt;/strong&gt; component.     &lt;/p&gt;

&lt;p&gt;This...is a lot. But the basic structure is a quasi-Russian-Doll-esque sort of functionality, where interconnected components can pass information and behavior back and forth as needed. For more on that, check out the React documentation on &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;props&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In a nutshell, React helps us to simplify what's called the &lt;strong&gt;boilerplate code&lt;/strong&gt;. In computer programming, boilerplate code, or simply &lt;em&gt;boilerplate,&lt;/em&gt; are sections of code that are repeated in multiple places with little to no variation. When using languages that are considered &lt;em&gt;verbose&lt;/em&gt; (overly wordy - &lt;em&gt;cough&lt;/em&gt; JAVASCRIPT &lt;em&gt;cough&lt;/em&gt;), the programmer must write a lot of boilerplate code to accomplish only minor functionality. &lt;/p&gt;

&lt;p&gt;Until React comes along, takes one look at all that absurd boilerplate and dares to ask...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/s239QJIh56sRW/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/s239QJIh56sRW/giphy.gif" width="480" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React helps us re-use things that have already been made, and saves us from having to make them ourselves the long way. In the land of the DRY code, the programmer with React is king. &lt;/p&gt;

&lt;p&gt;-- ONE FINAL NOTE! --&lt;/p&gt;

&lt;p&gt;If you're just starting out, I HIGHLY HIGHLY recommend &lt;a href="https://scrimba.com/learn/learnreact"&gt;these videos on Scrimba&lt;/a&gt; for learning the fundamentals. &lt;/p&gt;

&lt;p&gt;Bob Ziroll is AWESOME and really takes the time to flesh out all the basics of React and how it behaves. Scrimba's videos are HANDS DOWN the best resource I found for learning introductory React stuff. Scrimba allows you to manipulate the instructor's JSX code directly in the video window, and even saves your edits as notes, which I found remarkably helpful for my comprehension.&lt;/p&gt;

&lt;p&gt;And that's it - thanks so much for making it this far! If you have any questions or recommendations for edits, feel free to reach out. I welcome any and all feedback.&lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ    &lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Approach Your Problems Like An Expert Beginner</title>
      <dc:creator>WizardofHause</dc:creator>
      <pubDate>Tue, 11 Oct 2022 02:33:25 +0000</pubDate>
      <link>https://dev.to/wizardofhause/first-post-for-expert-beginners-only-1a74</link>
      <guid>https://dev.to/wizardofhause/first-post-for-expert-beginners-only-1a74</guid>
      <description>&lt;p&gt;Hello, and welcome, to my very first developer blog post! I'm currently a student at Flatiron School's Software Engineering Bootcamp, and we just finished up the first of five course phases. All things considered, being a beginner coder is equal parts nightmare-horror-story and equal parts...SCRUMTRULESCENT! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/26hiscTVQxNAwPatG/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/26hiscTVQxNAwPatG/giphy.gif" width="480" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I mean, one minute I feel like I'm achieving Kanye-level genius (jeen-yuhs?) when my first 'click' event listener finally works, and the next minute I'm taking my fifth cry-break because the nonsense CSS "rules" I wrote keep breaking the whole webpage (CSS guesses make for CSS messes). Like learning any new skill, it's a rollercoaster of emotion, and I'm definitely along for the ride. &lt;/p&gt;

&lt;p&gt;But the most basic thing that really threw sand in my gears right at the beginning, was &lt;em&gt;how do I even get started?&lt;/em&gt; All the code-alongs in the world fell short when I was alone and faced with the stark void of an empty VS Code file. But after some helpful insight from my instructors and this &lt;a href="https://www.geeksforgeeks.org/how-to-approach-a-coding-problem/"&gt;blog&lt;/a&gt;, I found that the right approach to a code problem can be broken down into 6 (relatively) simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understand your problem &lt;/li&gt;
&lt;li&gt;Break the problem into manageable bits&lt;/li&gt;
&lt;li&gt;Write your process out in human words and leave lots of comments&lt;/li&gt;
&lt;li&gt;Use available tools to sample and test stuff you forgot &lt;/li&gt;
&lt;li&gt;Slowly fill in the comments with actual code&lt;/li&gt;
&lt;li&gt;Simplify and optimize for clarity and dynamic use&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Understand your problem&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://i.giphy.com/media/6wUw9wQn85dqoSVvpWa/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/6wUw9wQn85dqoSVvpWa/giphy.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;br&gt;
If you think about it, this is really a good rule for life in general, but it also applies pretty well to coding. (In my experience, this almost always boiled down to &lt;strong&gt;READ THE README!&lt;/strong&gt;) In general, you need to know what your problem is asking for, before you start flinging out solutions. Before I started writing, I would pump the brakes and ask myself, "What are the known variables? What things do I need to manipulate or change? What are my desired outputs?" Knowing ALL the specifics of a problem helped me to get closer to finding the solution. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Break the problem into smaller parts&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/GLkQ1upVWKdeo/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/GLkQ1upVWKdeo/giphy.gif" width="300" height="225"&gt;&lt;/a&gt;&lt;br&gt;
Most coding problems were presented in big, complex, unapproachable formats that were tough to decipher. Breaking down the code into smaller bits helped me to cut through the confusion. Once I divided the problem into smaller, more manageable micro-problems that I actually DID know how to solve, it was that much easier for me to then connect the dots. This also helped me to make my code more dynamic - when I wrote functions that were smaller, and more general in scope, it was easier to implement them as re-usable code throughout the program/application (more on that later). &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Write your process out in human words, leave lots of comments&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/Dh5q0sShxgp13DwrvG/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/Dh5q0sShxgp13DwrvG/giphy.gif" width="600" height="370"&gt;&lt;/a&gt;&lt;br&gt;
Once I had everything all organized, I would literally write out, in full sentences, exactly &lt;em&gt;what&lt;/em&gt; I wanted the code to do, and &lt;em&gt;how&lt;/em&gt; I wanted it to do it. These notes weren't necessarily pretty, but were just some human-readable syntax that even non-developers could understand. Putting code into literal words this way helped me to clear the mental cobwebs and make sense out of what I was trying to do. I also found that leaving my outline in place as &lt;em&gt;comments&lt;/em&gt; helped me to stay organized while I was putting everything together, AND it ultimately made my code easier for others to read. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Use available tools to sample and test stuff you forgot&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/gKJXyl1Pl3PvfRS3RP/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/gKJXyl1Pl3PvfRS3RP/giphy.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;br&gt;
If you're unsure if your function will work or if your syntax is correct, you can always test out your code with an online app like &lt;a href="https://replit.com/languages/javascript"&gt;Replit,&lt;/a&gt; or with the VERY helpful developer tools built into &lt;a href="https://developer.chrome.com/docs/devtools/"&gt;Chrome's Dev Tools&lt;/a&gt;. Remove even more of the guess work by tapping in to the multitude of testing tools that are totally free to use. As a beginner, the amount of rules and methods and syntax and little itsy bitsy things you have to remember is absurd. I could not keep track of all of them, and even if I looked them up, I would have trouble remembering exactly how they got implemented. (e.g. Does this method return &lt;em&gt;values&lt;/em&gt; or an &lt;em&gt;array of values?&lt;/em&gt; Does this method &lt;em&gt;mutate&lt;/em&gt; my original data set or make a new one?) Using a REPL to test these little bits of my code was a life-saver, and helped to really layer-in those concepts. I can't even count how many bogus arrays and objects I have made just to check if I was using the right iterator methods. No shame! Tools are there to be used!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Slowly fill in the actual code&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/fwbZnTftCXVocKzfxR/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/fwbZnTftCXVocKzfxR/giphy.gif" width="500" height="354"&gt;&lt;/a&gt;&lt;br&gt;
Once the problem has been clearly defined and parsed out using the strategies above, I would finally start to write up my code and develop a solution. It's at this point, however, that I personally had to use the most caution and take care to go slowly. It was deceptively easy for me to lose my place while writing up the solution and get frustrated. The good thing is, if the comments and notes from before are organized well, staying on track is a breeze. Just be aware, keeping the end goal in mind is critical during this step - don't lose focus! You're almost there!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Simplify and optimize for clarity and dynamic use&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://i.giphy.com/media/KEYEpIngcmXlHetDqz/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/KEYEpIngcmXlHetDqz/giphy.gif" width="480" height="284"&gt;&lt;/a&gt;&lt;br&gt;
This one is kind of pro-level, but when it's all said-and-done the difference between just okay code and &lt;em&gt;hallelujah-oh-mah-freakin-lawdy&lt;/em&gt; code, depends on how dynamic it is, or how re-usable. Ask yourself, can your functions be seamlessly used by other functions as callbacks? Or are they all hyper-specialized, monster-style, mega-functions that only have real use in one particular instance? I know from just my little experience, that the more efficient the solution is, the cleaner and easier the code is to read, and the easier it is to replicate. This one is definitely an on-going, long-term kind of goal to always strive for, but it seems like the sooner you try to implement a more dynamic style into your code, the better time everyone will have. &lt;/p&gt;

&lt;p&gt;And that's it! Super simple, right? Well...sort of. Putting these strategies to use now could ultimately help take the tension out of the job interview process down the road (I'm told), and it can definitely help with comprehension while learning new concepts. &lt;/p&gt;

&lt;p&gt;Thanks so much for making it this far! If you have any questions or recommendations for edits, feel free to reach out. I welcome any and all feedback. &lt;/p&gt;

&lt;p&gt;Keep fightin' the good fight! ʕ•ᴥ•ʔ &lt;/p&gt;

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