<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rae Stanton (she/her) on Medium]]></title>
        <description><![CDATA[Stories by Rae Stanton (she/her) on Medium]]></description>
        <link>https://medium.com/@raestanton93?source=rss-98c226de004f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*holcLUx5gXBoxLS8NhfEvg.jpeg</url>
            <title>Stories by Rae Stanton (she/her) on Medium</title>
            <link>https://medium.com/@raestanton93?source=rss-98c226de004f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:28:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raestanton93/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setting up React DND — a basic guide]]></title>
            <link>https://medium.com/@raestanton93/setting-up-react-dnd-a-basic-guide-44f4d55aa872?source=rss-98c226de004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/44f4d55aa872</guid>
            <category><![CDATA[react-drag-and-drop]]></category>
            <category><![CDATA[drag-and-drop]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Rae Stanton (she/her)]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 21:00:57 GMT</pubDate>
            <atom:updated>2023-11-10T21:00:57.753Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up React DND — a basic guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*kqSEdSgFEZYoiRYez0E_mA.jpeg" /></figure><p>In my most recent project, I wanted to implement drag-and-drop functionality for a part of my UI. This was overall fairly straightforward, but I wanted to share a quick overview of the process I used to set up this neat feature. For this, I have already set up a React app front end and a Flask backend. With that noted, let’s get started. You’ll also need a way to fetch data from an endpoint. I used Axios for this project in particular, but other methods would be fine.</p><p><strong>1. Add react-dnd and react-dnd-html5-backend</strong></p><pre>yarn add react-dnd<br>yarn add react-dnd-html5-backend<br><br>OR <br><br>npm install react-dnd<br>npm install react-dnd-html5-backend</pre><p>Either installation method is fine. Now that the install is set up, in your top-level component, wrap your React routes (mine are held in App.js) in the DND-provider.</p><p>Don’t forget to import!</p><pre>import { DndProvider } from &quot;react-dnd&quot;;<br>import { DragDropProvider } from &quot;./DragDropContext&quot;;<br>import { HTML5Backend } from &quot;react-dnd-html5-backend&quot;;<br><br>    &lt;DndProvider backend={HTML5Backend}&gt;<br>      &lt;DragDropProvider&gt;<br>        &lt;Router&gt;<br>          //your routes here<br>        &lt;/Router&gt;<br>      &lt;/DragDropProvider&gt;<br>    &lt;/DndProvider&gt;<br>  </pre><p>From here, we can start setting up our context for drag and drop. For this example, I used useContext to manage my drag and drop state, but Redux would be a great option (and probably a better one!) to implement this functionality. Now, I created a separate file for my Drag and Drop provider and set up context for the actual overall functionality, which also includes making the PATCH requests when something is updated. Roughly, here’s the setup for the provider, held in DragDropContext.js:</p><p><strong>2. Setting up the Context/actual provider</strong></p><pre>import React, { createContext, useContext, useState } from &quot;react&quot;;<br>import axios from &quot;axios&quot;; //axios for retrieving backend endpoint<br><br>const ElementContext = createContext();<br><br>export const useElementContext = () =&gt; useContext(ElementContext);<br><br>export const ElementProvider = ({ children }) =&gt; {<br>  const [draggedElement, setDraggedElement] = useState(null);<br>  const [draggedGroup, setDraggedGroup] = useState(null);<br>  const [dropZone, setDropZone] = useState(null);<br>  const [containerState, setContainerState] = useState([]);<br><br>  const startDragElement = (element) =&gt; setDraggedElement(element);<br><br>  const startDragGroup = (group) =&gt; setDraggedGroup(group);<br><br>  const defineDropZone = (zone) =&gt; setDropZone(zone);<br><br>  const updateContainer = (element, newContainerId, newGroupId) =&gt; {<br>    setContainerState((prevState) =&gt; {<br>      const updatedContainers = prevState.map((container) =&gt; {<br>        // Logic to update container state<br>        // ...<br>        // Return updated container<br>        return container;<br>      });<br><br>      return updatedContainers;<br>    });<br>  };<br><br>  const updateElementLocation = async (<br>    element,<br>    newContainerId,<br>    newGroupId,<br>    newOrder,<br>    onSuccess<br>  ) =&gt; {<br>    // Endpoint and token setup if using session tokens<br>    // I used JWT with Flask, so be sure to set those up for token management<br><br>    try {<br>      const response = await axios.patch(<br>        // URL and request body, here&#39;s where your patch endpoint <br>        // and relevant request will live. <br>      );<br><br>      console.log(response.data.message);<br>      if (response.status === 200) {<br>        updateContainer(element, newContainerId, newGroupId);<br>        onSuccess &amp;&amp; onSuccess(element, newContainerId, newGroupId);<br>      }<br>    } catch (error) {<br>      console.error(&quot;Error updating element location:&quot;, error);<br>    }<br>  };<br><br>  const onDropElement = (element, zone, zoneType, onSuccess) =&gt; {<br>    if (!element || !zone) return;<br><br>    // Resets drag state<br><br><br>    if (zoneType === &quot;container&quot;) {<br>      // Update logic for dropping into a container<br>    } else if (zoneType === &quot;group&quot;) {<br>      // Update logic for dropping into a group<br>    }<br>  };<br><br>  const contextValue = {<br>    // Expose state and handlers<br>  };<br><br>  return (<br>    &lt;ElementContext.Provider value={contextValue}&gt;<br>      {children}<br>    &lt;/ElementContext.Provider&gt;<br>  );<br>};<br><br>export default ElementProvider;</pre><p>Let’s break this down a little bit:</p><ol><li>Context creation — at the beginning of this code, this is where we are setting up our context. This allows the passing of data to other components where DND needs to be used.</li><li>In this snippet, we set up our custom hook for the context:</li></ol><pre>export const useElementContext = () =&gt; useContext(ElementContext);</pre><p><strong>3. Set up your state </strong>— this needs to have the elements you want to change, and a way to update that state. This also needs to have state for where the object is being “picked up” (dragged) and state for being “dropped”. This also has an example for some kind of container that may contain multiple elements. This is detailed with:</p><pre>const [draggedElement, setDraggedElement] = useState(null);<br>const [draggedGroup, setDraggedGroup] = useState(null);<br>const [dropZone, setDropZone] = useState(null);<br>const [containerState, setContainerState] = useState([]);</pre><p>Now, the following functions actually contain our drag and drop logic.<br>startDragElement and startDragGroup are used to set the element or group that is being dragged.</p><p>defineDropZone is used to set the drop zone target. This is where the dragged items end up.</p><p>updateContainer is the function that updates the state of the containers when an element is moved.</p><p><strong>4. Set up your async function.</strong></p><pre>const updateElementLocation = async (<br>  element,<br>  newContainerId,<br>  newGroupId,<br>  newOrder,<br>  onSuccess<br>) =&gt; {...</pre><p>With Axios, this is where you’ll need to set up your PATCH request to whatever endpoint you have set up. This PATCH is to update the location of the elements. For example, moving an item into a different category, or something like that.</p><p><strong>5. Set up your “drop” handler.</strong></p><p>This is the actual function that handles the “drop” event. In the above, this is notated with:</p><pre>const onDropElement = (element, zone, zoneType, onSuccess) =&gt; {</pre><p>This will reset the drag state and calls updateElementLocation to update the element&#39;s location.</p><p><strong>6. Set up the Context Provider.</strong></p><pre>&lt;DragDropContext.Provider value={contextValue}&gt;<br>  {children}<br>&lt;/DragDropContext.Provider&gt;</pre><p>This allows any of the children components to access the context we set up for the Drag and Drop.</p><p><strong>7. Set up any extra components for drag and drop functions. I set up a </strong><strong>Draggable and a </strong><strong>Droppable component to handle extra logic needed.</strong></p><p>In DraggableElement.js:</p><pre>import React from &#39;react&#39;;<br>import { useDrag } from &#39;react-dnd&#39;;<br>import { Types } from &#39;./Types&#39;;<br><br>export const DraggableElement = ({ element, children }) =&gt; {<br>  const [{ isDragging }, drag] = useDrag({<br>    type: Types.GENERIC_TYPE,<br>    item: { id: element.id },<br>    collect: monitor =&gt; ({<br>      isDragging: monitor.isDragging(),<br>    }),<br>  });<br><br>  return React.Children.map(children, (child) =&gt;<br>    React.isValidElement(child)<br>      ? React.cloneElement(child, {<br>          ref: drag,<br>          style: { ...child.props.style, opacity: isDragging ? 0.5 : 1 },<br>        })<br>      : child<br>  );<br>};</pre><p>Here’s what’s happening in the DraggableElement component:</p><ul><li>Types.GENERIC_TYPE is used as a placeholder for the type of item being dragged. I have this set up in a separate component, but it’s not necessary.</li><li>The item object now only has an id property, making it more generic.</li><li>The collect function creates an object containing the isDragging state, which affects the element&#39;s opacity.</li></ul><p>Now, in DroppableContainer.js :</p><pre>import React from &#39;react&#39;;<br>import { useDrop } from &#39;react-dnd&#39;;<br>import { Types } from &#39;./Types&#39;;<br>import { useElementContext } from &#39;./ElementContext&#39;;<br><br>export const DroppableContainer = ({ onDropElement, children }) =&gt; {<br>  const { onDrop } = useElementContext();<br><br>  const [, dropRef] = useDrop({<br>    accept: Types.GENERIC_TYPE,<br>    drop: (element, monitor) =&gt; {<br>      if (monitor.isOver()) {<br>        onDropElement(element);<br>      }<br>    },<br>    collect: monitor =&gt; ({<br>      isOver: !!monitor.isOver(),<br>    }),<br>  });<br><br>  return (<br>    &lt;div ref={dropRef} className=&quot;droppable-container&quot;&gt;<br>      {children}<br>    &lt;/div&gt;<br>  );<br>};</pre><p>What’s going on in the DroppableContainer component:</p><ul><li>Types.GENERIC_TYPE is used again to specify what type of draggable elements this container accepts.</li><li>The drop function now takes an element and calls onDropElement if the element is over the container.</li><li>The collect function creates an object that tracks whether a draggable element is over the container.</li></ul><p><strong>8. Lastly, import to your child component where the drag and drop functionality is actually happening.</strong></p><pre>import React, { useState, useEffect } from &quot;react&quot;;<br>import axios from &quot;axios&quot;;<br>import { Container, Row, Col } from &quot;react-bootstrap&quot;;<br>import { DraggableElement } from &quot;./DraggableElement&quot;;<br>import { DroppableContainer } from &quot;./DroppableContainer&quot;;<br>import { useElementContext } from &quot;./ElementContext&quot;;<br><br>function Dashboard() {<br>  const [elements, setElements] = useState([]);<br>  const { onDrop } = useElementContext();<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      // Placeholder for fetching data logic<br>    };<br><br>    fetchData();<br>  }, []); <br>  // Dependency array is empty, meaning this effect runs once on mount,<br>  // Change this if you dare....<br><br>  if (!elements.length) return &lt;p&gt;Loading...&lt;/p&gt;;<br><br>  return (<br>    &lt;Container&gt;<br>      &lt;Row&gt;<br>        {/* Mapping through the fetched data to create a droppable container */}<br>        {elements.map((container) =&gt; (<br>          &lt;DroppableContainer key={container.id} onDropElement={onDrop}&gt;<br>            &lt;Col&gt;<br>              {/* Mapping through items within each container to make them draggable */}<br>              {container.items.map((element) =&gt; (<br>                &lt;DraggableElement key={element.id} element={element}&gt;<br>                  {/* Placeholder for the draggable element */}<br>                &lt;/DraggableElement&gt;<br>              ))}<br>            &lt;/Col&gt;<br>          &lt;/DroppableContainer&gt;<br>        ))}<br>      &lt;/Row&gt;<br>    &lt;/Container&gt;<br>  );<br>}<br><br>export default Dashboard;</pre><p>In here, all you need to add is importing the relevant components and context, then add your Drag and Drop to your data. This is probably the easiest step. I added it within a map function to grab specific user data, but this is a simpler example of that.</p><p>Phew! This seems like a *lot* of steps, but I promise, it’s not terribly complicated. Now you should be able to drag and drop elements all around the place with ease. Happy coding! ⚛️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44f4d55aa872" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Party in the front, business in the back — how I organize simple full-stack webapps.]]></title>
            <link>https://medium.com/@raestanton93/party-in-the-front-business-in-the-back-how-i-organize-simple-full-stack-webapps-c2e95ed98feb?source=rss-98c226de004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2e95ed98feb</guid>
            <category><![CDATA[full-stack-developer]]></category>
            <dc:creator><![CDATA[Rae Stanton (she/her)]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 22:08:34 GMT</pubDate>
            <atom:updated>2023-11-01T16:01:28.539Z</atom:updated>
            <content:encoded><![CDATA[<h3>Party in the front, business in the back — how I organize simple full-stack webapps.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kN4IIIcp9hhwN-5xlV1K4A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lautaro Andreani</a> on <a href="https://unsplash.com/photos/a-computer-screen-with-a-logo-on-it-xkBaqlcqeb4?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>When you log into any place on the internet, have you ever thought about how these sites came to life? What planning and re-planning had to happen to create the most basic form of these mega-corporation websites? While some of it is fairly simple in theory, the task of actually creating something even where someone just logs into a website and sees a different screen is, well, daunting the first (or even the second or more) time you go to create one.</p><p>So, on the other side of a few of these applications, I wanted to share some core things I learned through *pain* and a lot of late, over-caffeinated nights and yawn-filled mornings.</p><p>Starting with the back end (AKA, the “business”) side:</p><p>While this isn’t always the first thing I start writing, I do like to plan out the overall structure of the application before I even create a GitHub repo. As I have mentioned previously, I love planning out projects in FigJam. To start, I will write out the core functionality that a user will have (a user’s “story”, if you will). This can be something like:</p><p>“When you visit this page, you’ll see a home page with the name of the application and something about what it is. It will have some way to easily get to the core of the site, where a user will register and be able to log in and log out to get around. The site will be able to offer *x* as a service, and will allow a user to interact with this in *x* way. This could solve a problem they have, or just be a fun way to find something.”</p><p>From there, I begin sketching out databases. I like to start this off as close to writing sentences in English as possible. Something like “a user will have a name, an email, and a password. There will also be plants, which will somehow belong to a user. Plants will have a name, a type, and an amount of time to grow. A user will also have a way to add plants to a wish list, and the wish list will belong to users and have plants added to them”. From there, I find it pretty simple to write out the tables themselves. In a simplified example, this may start off with just a couple of basic tables, such as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfhDe-7VR4ZHvzTMMlnY6A.png" /></figure><p>Obviously, this is not enough data, but being able to translate some of the plain English into tables is really useful. If it doesn’t make sense to me writing it out normally, it probably won’t make sense in my database.</p><p>After I have a lot of my back end planned out, I start working on getting a rough idea of how I want things to look and feel. I don’t plan out much more outside of rough sketches of how things will flow at first. Things definitely change constantly, so I don’t sweat it at this point. I will still get a rough idea of what I want in my navigation and basic pages throughout. Do I want a separate dashboard when someone logs in? Is there a separate landing page depending on where they are coming from in the application? Asking yourself WHY that part of the application exists and WHAT you want your program to do can help plan for the front end (AKA, in my opinion, the “party” side of the application(yes, I also think the back end is a party, but nobody really gets to see your awesome schema.)) In earnest, a flow chart is helpful for me to start planning the overall structure of what someone will see when they get to my application. This is always a very rough draft, and often changes as I figure things out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I7Qie3qLJVrF-cwP7kXL4g.png" /></figure><p>So at this point, I have planned out some basic data structures and basic front end user “stories”. NOW it’s time to write code. How do I get these things to talk to each other? This really depends on what I decide to use for my back and front end. No two frameworks and libraries are exactly equal in setting things up, but after making a decision on both sides of the application, it’s time to create the application, GitHub, and write that sweet, sweet “hello, world”. Ya gotta start somewhere.</p><p>Overall, the TLDR steps are:</p><ul><li>Brainstorm what the app will do</li><li>From there, brainstorm some of your data and back end</li><li>After that, start thinking of your front end and how the front/back will “talk to each other”</li><li>Plan a flow</li><li>Create that app and write some code! (Also, branch and commit often!)</li><li>WRITE TESTS FOR YOURSELF. Don’t push changes that break things unless you enjoy pain.</li></ul><p>Is this also the perfect setup? Gods, no, it’s just ONE way to structure getting things ready to set yourself up for success!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2e95ed98feb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tools of Collaboration — my top picks as a software developer.]]></title>
            <link>https://medium.com/@raestanton93/tools-of-collaboration-my-top-picks-as-a-software-developer-ca127b635744?source=rss-98c226de004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca127b635744</guid>
            <category><![CDATA[kanban]]></category>
            <category><![CDATA[figjam]]></category>
            <category><![CDATA[collaboration-tools]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[figma]]></category>
            <dc:creator><![CDATA[Rae Stanton (she/her)]]></dc:creator>
            <pubDate>Fri, 29 Sep 2023 20:22:42 GMT</pubDate>
            <atom:updated>2023-09-29T20:22:42.542Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tools of Collaboration — my top picks as a software developer.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGvrVsp3nYmj4Uu92Oxpng.jpeg" /><figcaption>Photo credit: Photo by <a href="https://unsplash.com/@jstrippa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">James Harrison</a> on <a href="https://unsplash.com/photos/vpOeXr5wmR4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Throughout my short 10-ish months of learning how to code, I have come across a plethora of different tools to make the collaboration and overall development process way, way easier. Some of them are <em>way</em> more user-friendly right out of the box, but I wanted to share a few of my favorites I’ve found along the way, in no particular order. A lot of these have made things much more clear, enabling a streamlined planning phase and all phases in between.</p><p>The first of these tools is <a href="http://trello.com/">Trello</a>. This really clean Kanban board is one of the first things I used to collaborate on my very first project with a mentor. It was so easy to categorize in “epics” (basically, the overall larger chunk of the project that needed to get completed) and subcategorize those into smaller bite-sized pieces of work. This allowed simpler visualization and I still use this tool to organize my work or notes today.</p><p>The next tool is <a href="https://desktop.github.com/">GitHub Desktop</a>. I know this isn’t *necessarily* a tool of collaboration as much as the others, but this clean GUI made visualizing my Git flow MUCH easier and eliminated complex command line processes like squashing commits, rebasing, and much more. This made my commits much cleaner and easier to follow — plus, the ability to swap branches easily is really handy to collaborate on GitHub.</p><p>Now, this tool is one I recently adapted to record live demos of projects to showcase visual changes and also any functionality changes that I can present —<a href="http://loom.com/"> loom</a>. Loom is a simple video and screen recording tool that allows you to video record your voice, camera and your screen right from your browser. It’s SO simple and clean, and I love being able to easily share what I am working on when words just aren’t quite enough.</p><p>My favorite tool of all time, though, is <em>definitely</em> <a href="http://figma.com/">Figma/FigJam</a>. I cannot rave enough about the plethora of tools (including a kanban plugin right in the app!) to collaborate live with yourself or with your team. I think this is the ultimate tool to show the flow of your work, brainstorm, create sample database tables if you need to write it out before you even need to update or create your DB and more. This is also excellent for planning out a better user interface, giving you the ability to upload any photos needed and seeing your team’s updates in real time. Plus, the cute cat stickers are a bonus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HkQGsyQ0TjrzAhN2pOx9Ag.png" /></figure><p>Hello?! So cute! Who doesn’t want to see cats hanging out and helping you hack away? I know I sure do.</p><p>There you have it! These are just a few tools that have really helped me be a more effective collaborator and a more organized developer overall.</p><p>What tools do you enjoy using? Are some of these your favorites? If so, what parts do you enjoy the most? Feel free to share yours below.</p><p>Thanks for reading, and I hope these prove useful to you, too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca127b635744" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React as a layered cake]]></title>
            <link>https://medium.com/@raestanton93/react-as-a-layered-cake-cdece0a415a0?source=rss-98c226de004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdece0a415a0</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Rae Stanton (she/her)]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 20:34:09 GMT</pubDate>
            <atom:updated>2023-09-08T20:35:20.783Z</atom:updated>
            <content:encoded><![CDATA[<h4>Taking React and making it extra tasty.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tos5w44w-fk4W6xadCSU_w.png" /></figure><p>After taking a much deeper dive into the world of React lately, I wanted to find a way to simplify things. Being a hobby baker, I thought immediately of a layered cake. Let’s begin with our React app itself.</p><p>The full application is, simply, the whole cake. It contains all of the main components, your flavor, and all of your decorations. It’s the full, glorious package.</p><p>Then, moving into slicing through the full cake, you can see the inner workings that bring it all together. I like to think of this as importing and exporting. The overall flow of the layers and frosting all stacked up and “communicating” together in individual layers, working together in our applications are what makes them all work as a cake.</p><p>The actual layers, though, are the React components. You could have a purple component that houses anything related to creating that one portion of the application — maybe that’s just rendering information to some cards on a page, maybe that’s implementing a search — all of the smaller bites that make sense living in their own little layer make up the purple layer.</p><pre>import React from &#39;react&#39;;<br><br>function PurpleCakeComponent() {<br>  return (<br>    &lt;div style={{ border: &#39;1px solid purple&#39;, borderRadius: &#39;10px&#39;, padding: &#39;20px&#39;, textAlign: &#39;center&#39;, backgroundColor: &#39;lavender&#39; }}&gt;<br>      &lt;h1 style={{ color: &#39;purple&#39; }}&gt;Purple Cake&lt;/h1&gt;<br>      &lt;p style={{ color: &#39;purple&#39; }}&gt;A delightful purple cake layer for your special occasion.&lt;/p&gt;<br>      &lt;img <br>        src=&quot;path/to/your/purple-cake-image.jpg&quot; <br>        alt=&quot;Purple Cake&quot; <br>        style={{ maxWidth: &#39;100%&#39;, borderRadius: &#39;10px&#39; }} <br>      /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default PurpleCakeComponent;</pre><p>The blue layer may take a part of the purple layer, and maybe this part builds on top of the cards. We could import the purple layer and, now, they can build on top of each other.</p><pre>import React from &#39;react&#39;;<br>import PurpleCakeComponent from &#39;./PurpleCakeComponent&#39;;<br><br>function BlueComponent() {<br>  return (<br>    &lt;div style={{ border: &#39;1px solid blue&#39;, borderRadius: &#39;10px&#39;, padding: &#39;20px&#39;, textAlign: &#39;center&#39;, backgroundColor: &#39;lightblue&#39; }}&gt;<br>      &lt;h1 style={{ color: &#39;blue&#39; }}&gt;Blue Component&lt;/h1&gt;<br>      &lt;PurpleCakeComponent /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default BlueComponent;</pre><p>But before we can get to the layers, though, we need ingredients, right? Those are what I think props are. This makes the components behave &amp; render in a certain way, just the same way eggs, flour, butter, lime zest, and sugar may be part of making a lime flavored cake. Yum.</p><p>Speaking of flavor, I think that’s where our conditionals come into play. Say we used the lime. “If” I add just vanilla, it would be a vanilla cake. “Else”, if I were to add the lime zest, I would have a lime flavored cake. If I don’t add any flavor, well… that would just be sad.</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function FlavorComponent() {<br>  const [flavor, setFlavor] = useState(&#39;vanilla&#39;);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;button onClick={() =&gt; setFlavor(&#39;vanilla&#39;)}&gt;Vanilla&lt;/button&gt;<br>      &lt;button onClick={() =&gt; setFlavor(&#39;lime zest&#39;)}&gt;Lime Zest&lt;/button&gt;<br>      <br>      {flavor === &#39;vanilla&#39; ? (<br>        &lt;p&gt;You chose vanilla! A basic choice.&lt;/p&gt;<br>      ) : flavor === &#39;lime zest&#39; ? (<br>        &lt;p&gt;You chose lime zest! A tangy, refreshing choice.&lt;/p&gt;<br>      ) : (<br>        &lt;p&gt;Please select a flavor.&lt;/p&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default FlavorComponent;</pre><p>Last, but certainly not least, once we have all of our layers of cake talking to each other, we need some decorations! Utilizing smaller, easier to read css components represent all of the decorations we need. In this case, it’s our rainbow ombre css component, it’s our piping work component, and sprinkles component — maybe represented with a gradient, borders, and specifically styling buttons. Importing smaller css components into the relevant components makes it much, much easier to parse, in my opinion.</p><p>So, there you have it! A simple (and delicious) explanation of how React works together to make an awesome App Cake.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdece0a415a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rubber Ducking & Pseudocode — coding before you code.]]></title>
            <link>https://medium.com/@raestanton93/rubber-ducking-pseudocode-coding-before-you-code-70066685b139?source=rss-98c226de004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/70066685b139</guid>
            <category><![CDATA[rubber-duck-debugging]]></category>
            <category><![CDATA[rubber-ducking]]></category>
            <category><![CDATA[pseudocode]]></category>
            <dc:creator><![CDATA[Rae Stanton (she/her)]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 19:34:43 GMT</pubDate>
            <atom:updated>2023-08-18T19:34:43.004Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rubber Ducking &amp; Pseudocode— coding before you code.</h3><p>I am a fond user of two “coding” languages that don’t involve actually writing any code right away.<br>1) Rubber Ducking.<br>2) Pseudocode.</p><p>What are these two things, and why are they helpful for EVERYONE, no matter where you are in your career?</p><p>Let’s start with number one, and a photo of my actual rubber duck. I haven’t given them a name yet, but I loved the unicorn duck I got at RailsConf ATL 2023 this year, so here’s mine:</p><figure><img alt="a rubber duck that has a unicorn horn and purple hair in front of lines of code." src="https://cdn-images-1.medium.com/max/1024/1*CBG0A_UbAAnciTiO3UmWNg.jpeg" /></figure><p>Ok, Rae, why are you showing me a rubber duck?</p><p>Maybe I’m forever a child at heart, but I want to explore the beauty of verbalizing everything you need to do while you’re in your own thoughts. This concept is known as “rubber ducking”. No, you do not have to have an actual rubber duck in front of you, but I believe one of the best ways to get yourself unstuck faster is talking about what you need to accomplish, out loud, to a “rubber duck”.</p><p>Imagine (and I’m sure most of us can imagine this quite easily) you have spent a significant chunk of time trying to diagnose a bug or issue in your code. You’ve thrown it into ChatGPT, you’ve used GitHub Co-Pilot, you’ve tried StackOverflow and any documentation you can think of. What IS it that you’re missing? Cue the spiral, cue imposter syndrome, cue…. ugh just what *are* you missing?</p><p>Enter First Officer DuckyCorn of the Starship CoderPrise. (I think I just found my name.)</p><p>DuckyCorn is asking what you’re trying to accomplish, in plain language.</p><p>“I am trying to render an image on a webpage.” you say to DuckyCorn.</p><p>DuckyCorn says nothing. DuckyCorn is made of some kind of plastic.</p><p>But to you, in your brain, DuckyCorn asks “what have you already DONE?”</p><p>“Well, I have written this function, but it isn’t rendering! …. and then I tried this other thing … and I just can’t figure it out!” you reply, flustered.</p><p>DuckyCorn says chill out, Captain, go through it step by step.</p><p>You tell DuckyCorn everything, trying to recount all of the details, and then, DuckyCorn asks “now, what have you tried that makes you think you’re closer to what you need? what do you THINK you need?”</p><p>I could go on about you and your First Officer, but the idea is the same. Telling DuckyCorn what you’ve done and what you need to do — that’s rubber ducking, friend. Verbalizing what you have written or need to write is so key in making sense of it all when reading line 18 over and over in your head just isn’t doing it.</p><p>Pseudocode, engage!<br>Now that you know where you’re headed (thanks, Number One) you can begin your planning in pseudocode.</p><p>Take all of the things you need to accomplish. Let’s say you need to take information from a database of some kind, then show it, then make some kind of action on that data. Taking your brilliant recommendations from First Officer DuckyCorn, let’s start to write that out!</p><p>This can look something like:<br>What do I need to do? (top level overview)</p><p>How do I break this down into smaller bites?<br>- Create objects in DB (see below!) <br>- grab data from DB (use fetch GET, for example) <br>- create some kind of view (index.html &amp; index.js)<br>- and add desired features to that view (render to the DOM, add event listeners, etc)</p><p>Now, we can begin by creating your `db.json` object to start. For example:</p><pre><br>{<br>  &quot;recipes&quot;: [<br>    {<br>      &quot;id&quot;: 1,<br>      &quot;name&quot;: &quot;Vegan Spaghetti Carbonara&quot;,<br>      &quot;ingredients&quot;: [<br>        &quot;Spaghetti&quot;,<br>        &quot;Vegan bacon or smoked tempeh&quot;,<br>        &quot;Tofu (as egg substitute)&quot;,<br>        &quot;Nutritional yeast (for cheesy flavor)&quot;,<br>        &quot;Black pepper&quot;,<br>        &quot;Salt&quot;,<br>        &quot;Garlic&quot;,<br>        &quot;Parsley&quot;<br>      ],<br>      &quot;isLiked&quot;: false<br>    },<br>    {<br>      &quot;id&quot;: 2,<br>      &quot;name&quot;: &quot;Vegan Chickpea Curry&quot;,<br>      &quot;ingredients&quot;: [<br>        &quot;Chickpeas (instead of chicken)&quot;,<br>        &quot;Onions&quot;,<br>        &quot;Garlic&quot;,<br>        &quot;Ginger&quot;,<br>        &quot;Curry powder&quot;,<br>        &quot;Canned tomatoes&quot;,<br>        &quot;Coconut milk&quot;,<br>        &quot;Salt&quot;,<br>        &quot;Cilantro&quot;<br>      ],<br>      &quot;isLiked&quot;: true<br>    },<br>    {<br>      &quot;id&quot;: 3,<br>      &quot;name&quot;: &quot;Vegan Caesar Salad&quot;,<br>      &quot;ingredients&quot;: [<br>        &quot;Romaine lettuce&quot;,<br>        &quot;Vegan croutons&quot;,<br>        &quot;Vegan parmesan cheese&quot;,<br>        &quot;Tahini-based dressing&quot;,<br>        &quot;Garlic&quot;,<br>        &quot;Capers (as anchovy substitute)&quot;,<br>        &quot;Mustard&quot;,<br>        &quot;Lemon juice&quot;,<br>        &quot;Olive oil&quot;,<br>        &quot;Salt &amp; pepper&quot;<br>      ],<br>      &quot;isLiked&quot;: false<br>    }<br>  ]<br>}</pre><p>Now that you have your back end, you can start working on manipulating that information by using a simple GET request using fetch, which can be in pseudocode first:</p><pre>//fetch data from localhost:3000/recipes<br>//console log that to see if it worked<br>//console log if theres an issue getting that data <br>//append to the DOM next</pre><p>This is a plain language way of taking your thoughts and organizing them into smaller bites. Sometimes, you already have the exact process committed to memory and can write out some code then and there. Sometimes, though, you may need a little more time to research what *exactly* you are looking for in order to make what you want to happen, well, /happen/. This makes it much easier to perform the actual request, like so:</p><pre>//fetch from localhost:3000/recipes<br>const apiUrl = &#39;http://localhost:3000/recipes&#39;;<br><br>// Use fetch to make a GET request<br>fetch(apiUrl)<br>  .then(response =&gt; {<br>    // Check if the response is successful<br>    if (!response.ok) {<br>      throw new Error(`HTTP error! Status: ${response.status}`);<br>    }<br>    // Parse the JSON data from the response<br>    return response.json();<br>  })<br>  .then(data =&gt; {<br>    // Log the recipes to the console<br>    console.log(data);<br><br>    // If you want to do something with the data (displaying recipes...?)<br>    data.recipes.forEach(recipe =&gt; {<br>      console.log(recipe.name); // Logs each recipe name<br>    });<br>  })<br>  .catch(error =&gt; {<br>    // Handle any errors that occur during the fetch<br>    console.error(&#39;Fetching data failed:&#39;, error);<br>  });<br>// now I need to create a function for rendering it<br>// I need to grab elements or make them<br>// I need to make sure those elements are added to the DOM<br><br></pre><p>As you see here, the comments represent your pseudocoded steps. Now you can go on to creating your `index.html` if you haven’t already, and pseudocode your way into oblivion. Talk it out, read your code out loud, and make sure it makes sense. This is the hand-in-hand combination of rubber ducking and writing pseudocode that will help debug, create, and refactor your code from start to finish.</p><p>It’s so easy for us to get lost in the sauce of throwing objects and random functions and everything else at the wall until it (maybe?????) sticks. However, with mastering talking to First Officer DuckyCorn and writing out your thoughts into pseudocode, I believe you’ll find your code simpler, more thoughtful, and save you a whole lot of time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70066685b139" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>