<?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 R HD on Medium]]></title>
        <description><![CDATA[Stories by R HD on Medium]]></description>
        <link>https://medium.com/@rhalde?source=rss-c7b7d6a31c75------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sZsFgS9KBtuYKbSFl_QpOg.jpeg</url>
            <title>Stories by R HD on Medium</title>
            <link>https://medium.com/@rhalde?source=rss-c7b7d6a31c75------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:13:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rhalde/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[Coding Bootcamp Week 10: Frontend Project, Error Handling, Custom Hooks & Class-Based Components]]></title>
            <link>https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/46f81fe0ff56</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 13:26:40 GMT</pubDate>
            <atom:updated>2023-03-25T09:52:29.090Z</atom:updated>
            <content:encoded><![CDATA[<h4>Frontend development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mALjTfSa9AH5ko94" /><figcaption>Photo by <a href="https://unsplash.com/@rahuulmiishra?utm_source=medium&amp;utm_medium=referral">Rahul Mishra</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Frontend Project ✨</h3><p>I developed a React application for my frontend project that displays articles from a backend project I completed two weeks ago.</p><p>You can take a look at my application <a href="https://newsreactproject.netlify.app/">here</a>. I must note that since I am currently on a free trial on Render, there might be a delay in the loading of data.</p><p>You can check out my <a href="https://github.com/reemhd/fe-news-app">GitHub repo</a> for more info.</p><h3>Error Handling ⚠️</h3><p>React error handling is important when building a frontend connected to an API as errors can occur during the process. Errors can be either client-side or server-side, and it’s necessary to handle them on the front-end and provide meaningful feedback to the user.</p><p>Default routes can be set up in react-router Route components to handle undefined user URLs Error Components can be created to catch and display errors.</p><pre>import { Route, Switch } from &#39;react-router-dom&#39;;<br>import { ErrorPage } from &#39;./ErrorPage&#39;<br><br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;Switch&gt;<br>        &lt;Route exact path=&quot;/&quot; component={HomePage} /&gt;<br>        &lt;Route path=&quot;/about&quot; component={AboutPage} /&gt;<br>        &lt;Route component={ErrorPage} /&gt;<br>      &lt;/Switch&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>// ErrorPage.jsx<br>export const ErrorPage = () =&gt; {<br>  return &lt;div&gt;Sorry, this page does not exist.&lt;/div&gt;;<br>}</pre><p>Error components can be reusable and can receive error messages and codes from the API to provide helpful feedback to the user. Examples of errors to look out for include missing post information, badly formatted request URLs, and unauthorised user access.</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function ExampleComponent() {<br>  const [data, setData] = useState(null);<br>  const [error, setError] = useState(null);<br><br>  useEffect(() =&gt; {<br>    fetch(&#39;https://exampleapi.com/data&#39;)<br>      .then((response) =&gt; response.json())<br>      .then((data) =&gt; setData(data))<br>      .catch((error) =&gt; setError(error));<br>  }, []);<br><br>  if (error) {<br>    return &lt;ErrorComponent error={error} /&gt;;<br>  }<br><br>  return &lt;div&gt;{data &amp;&amp; data.message}&lt;/div&gt;;<br>}<br><br>function ErrorComponent({ error }) {<br>  return &lt;div&gt;{error.message}&lt;/div&gt;;<br>}</pre><p>In the above example, ExampleComponent is fetching data from an external API and sets the data state with the result. If there is an error during the API call, it sets the error state with the error object. The ErrorComponent component receives the error object as a prop and displays the error message to the user.</p><h3>Custom Hooks</h3><p>Custom React Hooks allow us to extract component logic into reusable functions. A custom hook is a function whose name starts with “use” and may call other hooks within itself.</p><p>The rules of hooks must be followed when writing custom hooks. Custom hooks work like components but don’t have a set return value, and can return any data structure.</p><p>By extracting logic into hooks, it can be reused by any component and can be called multiple times. Hooks allow for the re-use of stateful logic, while to share state we should use other mechanisms such as Context or a composed component.</p><h3>Class Based Components</h3><p>Prior to React version 16.8, functional components could not handle certain features, such as holding values in state or performing side effects, which required the use of class based components.</p><p>However, with the introduction of hooks, functional components can now achieve the same goals as class based components. Class based components can still be used and are often found in legacy projects.</p><pre>import React from &#39;react&#39;;<br><br>class Greeting extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {<br>      name: props.name<br>    };<br>  }<br><br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;h1&gt;Hello, {this.state.name}!&lt;/h1&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}<br><br>export default Greeting;</pre><p>In this example, we have created a Greeting component that extends the React.Component class. The component has a constructor that initializes the component&#39;s state with a name property based on the name prop that was passed to the component. The render method returns JSX that displays the name property in a heading.</p><p>It is generally recommended to use functional components with hooks for new projects and to update existing class-based components to use hooks if possible.</p><p>Hooks offer a simpler and more intuitive way of managing state and lifecycle in React components, and they also encourage a more functional programming style which can make code easier to reason about and test.</p><h3>Emotional check 🤖</h3><p>Having now completed both my backend and frontend projects, I find myself reflecting on the journey thus far and wonder whether it is appropriate to call myself a ‘developer’ now. The challenges posed by these projects were stimulating and engaging, almost akin to playing a game with a concrete goal in mind. The process of translating my ideas into finished products has been immensely satisfying, and has boosted my confidence.</p><p>The next phase of the bootcamp involves a three-week team project where I will have the opportunity to collaborate with four to six other developers. I am excited for this new challenge, as it will allow me to further hone my skills and gain valuable experience working within a team.</p><p>As my bootcamp draws to a close, I also have CV, interview, and tech test preparation to attend to. It is a bittersweet feeling, as I have learned so much over the course of these past three months. I am grateful for the skills and confidence that this program has instilled in me, and am looking forward to the opportunities that lie ahead.</p><h3>Leap through time ⏲</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React — Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: 👀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46f81fe0ff56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 9: API Calls, React — Router, Context & Optimistic Rendering]]></title>
            <link>https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5b4609900e6</guid>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 14:34:21 GMT</pubDate>
            <atom:updated>2023-03-25T09:51:42.843Z</atom:updated>
            <content:encoded><![CDATA[<h3>Coding Bootcamp Week 9: API Calls, React — Router, Context &amp; Optimistic Rendering</h3><h4>Frontend Development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*myHt0--RfUY6ZmYj.png" /></figure><h3>Fetch | Axios</h3><p>There several different ways in which API calls can be made, which is a process of sending a request to an API endpoint and receiving a response.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">Fetch API</a> is a promise-based interface which means it uses async programming and the first argument passed is the url and the method defaults to GET. We also need to parse our json body before it can be used.</p><pre>fetch(&#39;https://itunes.apple.com/search?term=badbadnotgood&#39;)<br>  .then(response =&gt; response.json())<br>  .then(body =&gt; console.log(body));</pre><p>We can also configure properties such as the method and headers to our request as below.</p><pre>fetch(&#39;https://www.example.com/api/people&#39;, {<br>  method: &#39;POST&#39;,<br>  headers: {<br>    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>  },<br>  body: JSON.stringify({ name: &#39;Mary&#39; }),<br>}).then((response) =&gt; response.json());</pre><p><a href="https://axios-http.com/docs/intro">Axios</a></p><p><em>Promise based HTTP client for the browser and node.js</em></p><p>There are several reasons why using axios is more beneficial than fetch: ease of use, handling errors, automatic serialising and deserialising of the response data and compatibility with browser and Node.js environments.</p><p>To use it, you need to install it and import it into your file, since it is promise-based, you would need to chain .then() and .catch() methods to access the http response. Unlike fetch, axios will reject the returned promise if the status code is not 2**.</p><pre>import axios from &#39;axios&#39; // after you run this &gt; npm install axios<br><br>axios<br>  .get(&#39;https://api.songList.com/v1/Aphex_Twin&#39;)<br>  .then((response) =&gt; {<br>    console.log(response);<br>  })<br>  .catch((error) =&gt; {<br>    console.log(error);<br>  })</pre><p>You can also deal with queries like filter items by category and sort by price:</p><pre>import axios from &#39;axios&#39;<br><br>// a custom axios instance to make several requests to same api<br>const api = axios.create({<br>  baseURL: `https://vintage-shop.onrender.com/api/`,<br>});<br>api.get(&#39;/items&#39;, {<br>  params: {<br>    category: &#39;Relic&#39;,<br>    sortBy: &#39;price&#39;<br>  }<br>})<br>  .then(response =&gt; console.log(response.data))<br>  .catch(error =&gt; console.log(error));</pre><p>The url would look like this &gt; <a href="https://vintage-shop.onrender.com/api/items?category=Relic&amp;sortBy=price.">https://vintage-shop.onrender.com/api/items?category=Relic&amp;sortBy=price.</a></p><p>For post request, the second argument will be the request body.</p><pre>api.post(&#39;/users&#39;, { firstName: &#39;Mary&#39;, lastName: &#39;Doe&#39; })</pre><h3>useEffect</h3><p>This hook is used to manage side effects in functional components. Side effects are any external interactions that your component might have, such as fetching data from an API, updating the browser’s title, or setting up event listeners.</p><p>The purpose of the useEffect hook is to allow you to perform side effects in your component without breaking the rules of React&#39;s rendering cycle.</p><p>It takes two arguments, the first one is the effect to run and second argument is the dependencies (an array of variables which allows the effect to run again should the variables values change). If there are no dependencies for this effect, the array can be left blank.</p><pre>import { useEffect } from &#39;react&#39;;<br>import { fetchUserById } from &#39;../utils/api.js&#39; <br><br>// userId passed as props<br>const UserProfile = ({ userId }) =&gt; {<br>  const [user, setUser] = useState({});<br>  useEffect(() =&gt; {<br>    fetchUserById(userId).then((userFromApi) =&gt; {<br>      setUser(userFromApi);<br>    });<br>  }, [userId]);<br>  return &lt;section&gt;<br>    &lt;h2&gt;{user.username}&lt;/h2&gt;<br>&lt;section&gt;<br>};</pre><p>In React, the useEffect hook can also be used to perform cleanup after a side effect. If a side effect requires cleanup, such as closing a connection to an external resource or removing an event listener, you can return a function from the useEffect hook that will be run just before the component is removed from the page (unmounted). This can help prevent memory leaks and ensure that your application runs smoothly.</p><p>In the example below, we use the useEffect hook to set up an interval that increments the count state variable every second. We return a cleanup function from useEffect that clears the interval when the component is unmounted.</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function Timer() {<br>  const [count, setCount] = useState(0);<br>  useEffect(() =&gt; {<br>    const intervalId = setInterval(() =&gt; {<br>      setCount((count) =&gt; count + 1);<br>    }, 1000);<br>    // Return a cleanup function to clear the interval<br>    return () =&gt; {<br>      clearInterval(intervalId);<br>    };<br>  }, []);<br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default Timer;</pre><h3>Loading patterns</h3><figure><img alt="loading image.." src="https://cdn-images-1.medium.com/max/700/0*TE-qZJ_qQ158YcjZ" /></figure><p>When making HTTP requests in React, they will be asynchronous and may take some time to complete. To give users feedback that the page is loading, it’s common practice to use visual loading patterns.</p><p>To implement a loading pattern, you can use state to track whether or not the data has been loaded. Once the data has been received and set in state, the loading message is replaced with the actual data. By using <a href="https://reactjs.org/docs/conditional-rendering.html">conditional rendering</a>, the loading message is rendered conditionally based on whether the data has been loaded or not.</p><pre>import { useEffect } from &#39;react&#39;;<br><br>const Users = () =&gt; {<br>  const [users, setUsers] = useState([]);<br>  const [isLoading, setIsLoading] = useState(true);<br>useEffect(() =&gt; {<br>    fetchUsers()<br>    .then((usersFromApi) =&gt; {<br>      setUsers(usersFromApi);<br>      setIsLoading(false)<br>    });<br>  }, []);<br>  if (isLoading) return &lt;p&gt;Loading...&lt;/p&gt;<br>  return &lt;ul&gt;<br>    {users.map((user) =&gt; {<br>      //  render each user<br>    })}<br>  &lt;/ul&gt;<br>};</pre><h3>Router</h3><p>React applications are generally single page applications (SPAs) where all the JavaScript required to construct the website is sent in one go, instead of individual HTML pages.</p><p>This means that the path of the URL does not matter, as everything is sent on the home path anyway. However, this has two major <em>drawbacks</em>: different areas of the application are not individually addressable, and we lose the use of the browser’s history.</p><p>React Router is a library that allows client-side routing, which is different from server-side routing.</p><p>In server-side routing, the server has views for every single route of our app, and the browser sends a GET request to the server for each view.</p><p>In contrast, in client-side routing used in to modern web development/ React, the server provides a single HTML file and a bundle of JavaScript. The rendering of the application happens client-side, and we can use a router to catch changes in the URL and render different components accordingly.</p><h3>BrowserRouter, Routes and Route</h3><p>BrowserRouter component must be wrapped around our entire app, and we can then use other components from React Router to render our components on specific paths.</p><p>The Routes component takes one or more Route components as children, and it will render the Route that matches the current path. The Routecomponent takes a path prop, which is compared to the current URL. When a match is found, the component that the Route wraps will be rendered.</p><p>By using these components, we can create a multi-page app-like experience within a single-page application. The browser’s history is also updated accordingly, so users can use the back and forward buttons to navigate between pages.</p><pre>&gt; npm i react-router-dom<br><br>// src/index.js<br>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom/client&#39;;<br>import { BrowserRouter } from &#39;react-router-dom&#39;;<br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(<br>  &lt;BrowserRouter&gt;<br>    &lt;App /&gt;<br>  &lt;/BrowserRouter&gt;<br>);<br>// src/App.js<br>import { Routes, Route } from &#39;react-router-dom&#39;;<br>const App = () =&gt; {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;h1&gt;My App &lt;/h1&gt;<br>      &lt;Routes&gt;<br>        &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;<br>      &lt;/Routes&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>// src/components/Home.jsx<br>const Home = () =&gt; (<br>  &lt;div&gt;<br>    &lt;h2&gt;Home Page&lt;/h2&gt;<br>  &lt;/div&gt;<br>);</pre><h3>Link</h3><p>In <a href="https://reactrouter.com/en/main">React Router</a>, using anchor tags&lt;a&gt;to link between pages will cause the entire application to reload, which defeats the purpose of using a single-page application.</p><p>To avoid this default behavior, React Router provides a &lt;Link&gt; component that removes the need for a page reload when navigating between routes. The to prop is used to set the URL, and the &lt;Link&gt; component can be used in a NavBar component, for example.</p><pre>&lt;nav&gt;<br>  &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;<br>  &lt;Link to=&quot;/about&quot;&gt;About&lt;/Link&gt;<br>  &lt;Link to=&quot;/topics&quot;&gt;Topics&lt;/Link&gt;<br>&lt;/nav&gt;</pre><h3><a href="https://reactrouter.com/en/main/hooks/use-params">useParams</a></h3><p>React Router allows for parametric endpoints, which are routes that contain variables that can be passed in through the URL.</p><p>React Router will extract the values of these variables and make them accessible through the [match.params] prop. To make use of these variables in a functional component, we can use the useParams hook provided by React Router, which returns an object containing the URL parameters.</p><p>This can be useful for fetching data from an API based on the URL parameters. To make API calls reusable and easier to manage, it is a good idea to separate them into their own module. React Router also provides additional features such as nested routing, styling active links, and redirects.</p><pre>// src/App.js<br>import { Routes, Route } from &#39;react-router-dom&#39;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;h1&gt;My App &lt;/h1&gt;<br>      &lt;Routes&gt;<br>        &lt;Route path=&quot;/topics&quot; element={&lt;Topics /&gt;} /&gt;<br>        &lt;Route path=&quot;/topics/:topic_slug&quot; element={&lt;SingleTopic /&gt;} /&gt;<br>      &lt;/Routes&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>// src/components/SingleTopic.jsx<br>import { useParams } from &#39;react-router-dom&#39;;<br>const SingleTopic = () =&gt; {<br>  const { topic_slug } = useParams(); <br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;Rendering {topic_slug}&lt;/h2&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><h3><a href="https://reactrouter.com/en/main/hooks/use-search-params">useSearchParams</a></h3><p>The useSearchParams hook in React Router allows us to access and modify queries in the URL of our application. We can access the queries by calling the hook, and it returns an instance of the URLSearchParams constructor.</p><p>We can then call methods like get to retrieve the values of specific queries. The example below is for when the client makes a request to /topics?sort_by=title</p><pre>// src/components/Topics.jsx<br>import { useSearchParams } from &#39;react-router-dom&#39;;<br><br>const Topics = () =&gt; (<br>  const [searchParams, setSearchParams] = useSearchParams();<br>  console.log(searchParams); // URLSearchParams {}<br>  const sortByQuery = searchParams.get(&#39;sort_by&#39;); // &quot;title&quot;<br>  &lt;section&gt;<br>    &lt;h2&gt;Topics&lt;/h2&gt;<br>  &lt;/section&gt;<br>);</pre><p>If we need to update the queries programmatically, we can use the setSearchParams function that is returned by the hook.</p><p>React Router also provides the useNavigate hook, which returns a function to navigate programmatically to a specified path or to go back or forward a specified number of steps in the browser history. This function can be useful, for example, when we need to navigate to a ‘thank you’ page after submitting a form.</p><h3><a href="https://reactjs.org/docs/context.html">Context</a></h3><p>The Context API in React is a way to share state between components without passing it through props. It’s useful for state that needs to be shared by multiple components or that can be considered global.</p><p>Examples include logged-in users, themes, or language settings.</p><p>Contexts can be created using createContext(), and a context value can be provided to a component using a Context.Provider. The useContext hook is then used to access the context value within a component.</p><h3>Optimistic Rendering</h3><figure><img alt="like button image" src="https://cdn-images-1.medium.com/max/700/0*pTUz7RSPymzM1uzR" /></figure><p>When making updates to the data via other methods such as POST or PATCH, it is important to decide whether to refresh the data or perform the UI update locally with the existing data. In cases where it is not necessary to wait for a response from the API, an optimistic approach can be taken, where UI updates are made immediately assuming that the request will be successful, example liking a post.</p><p>Error handling is also crucial when making API requests, and appropriate feedback should be given to users in case of errors. A combination of both optimistic and non-optimistic approaches can be used depending on the situation, and developers should carefully consider the impact of their decisions on user experience.</p><h3>Emotional check ✖️_✖️</h3><p>The bootcamp is intense, with a deluge of information being imparted to me incessantly, week after week. But we have an upcoming frontend project week, during which we will construct our React frontend page to interface with our backend project.</p><p>I am looking forward to it but I cannot deny that I am also in need of a longer weekend, to partake in some restorative slumber and perhaps some social activities for a refreshing change.</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React — Components, State &amp; Hooks</a></li><li>Week 9 👀</li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5b4609900e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 8: DOM, React – Components, State & Hooks]]></title>
            <link>https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/f15d710d7a25</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 15:07:18 GMT</pubDate>
            <atom:updated>2023-03-25T09:52:59.864Z</atom:updated>
            <content:encoded><![CDATA[<h4>Frontend Development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XfOYK56qflBdKmxn" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Document Object Model | DOM</h3><p>DOM is a programming interface for web documents that allows programs to dynamically access and manipulate the content, structure, and style of web pages.</p><p>The DOM is an object-oriented representation of the web page, which can be modified with a scripting language such as JavaScript.</p><p>It represents the web page as a hierarchical tree-like 🌲 structure, with each element of the page (such as paragraphs, headings, images, and links) represented by a node in the tree.</p><pre>// changing element content<br>const paragraph = document.getElementById(&quot;my-paragraph&quot;);<br>paragraph.innerHTML = &quot;New text&quot;;<br><br>// Adding and removing elements<br>const div = document.getElementById(&quot;my-div&quot;);<br>const button = document.createElement(&quot;button&quot;);<br>button.innerHTML = &quot;Click me&quot;;<br>button.addEventListener(&quot;click&quot;, function() {<br>  alert(&quot;Button clicked!&quot;);<br>});<br>div.appendChild(button);</pre><p><a href="https://www.w3schools.com/jsref/dom_obj_event.asp">HTML DOM events</a></p><h3><a href="https://reactjs.org/">React</a></h3><h4>Introduction</h4><blockquote>“A JavaScript library for building user interfaces” — React</blockquote><p>Manipulating the DOM can be slow and complex due to its tree structure, requiring recursive traversal. React provides a virtual DOM, allowing us to create User Interface (UI) declaratively with JavaScript without using browser DOM methods.</p><p>The virtual DOM provided by React is faster and more efficient than the traditional DOM since it checks for updates based on the declared UI, only updating what is necessary. This enables React to easily “hydrate” a page with data from API requests on the client side.</p><p><a href="https://reactjs.org/docs/introducing-jsx.html#embedding-expressions-in-jsx">JSX</a> is a syntax extension of JavaScript that allows us to write HTML syntax inside their JavaScript files. <a href="https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&amp;build=&amp;builtIns=false&amp;corejs=3.21&amp;spec=false&amp;loose=false&amp;code_lz=JYWwDg9gTgLgBAJQKYEMDGMAiB5AsnAMyghDgHIpUMBaAExLIG4AoZtCAOwGd4kAbJCCQd4AXjgAeABYBGAHwAJfnwgAaOAHdofWhID0suS3bd4xCGMRUseAHRpKKGEgQQLACnpoArkJG2AcyQYAFEBPxgAIQBPAEladwo3GDIASlTmcxhbSg5aJCh3fkFhGFTGIA&amp;debug=false&amp;forceAllTransforms=false&amp;modules=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env%2Creact%2Cstage-2&amp;prettier=false&amp;targets=&amp;version=7.21.2&amp;externalPlugins=&amp;assumptions=%7B%7D">Babel</a> is a JavaScript compiler that converts modern ES6 JavaScript syntax into browser-compatible JavaScript, and can also automatically import jsx-runtime, making JSX code look like normal JavaScript values.</p><pre>import ReactDOM from &#39;react-dom&#39;;<br><br>const element = &lt;h1&gt;Hello, world&lt;/h1&gt;;<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;))<br>root.render(element);</pre><p>React 17 and later versions automatically import jsx-runtime, while previous versions required the import of React in order to use JSX.</p><p>JavaScript can be embedded within JSX using curly braces.</p><pre>const person = {<br>  name: &#39;Mary&#39;,<br>  age: 24,<br>};<br><br>return (<br>  &lt;section&gt;<br>    &lt;h1&gt;{person.name}&lt;/h1&gt;<br>    &lt;p&gt;{person.age} years old&lt;/p&gt;<br>  &lt;/section&gt;<br>);</pre><h4>Components</h4><p>React components are independent and reusable units that allow us to split our apps into smaller, more manageable pieces.</p><p>Components can be either function or class-based, but before the introduction of <a href="https://reactjs.org/docs/hooks-intro.html">React hooks</a>, class-based components were the primary way to manage state within React.</p><p>However, functional components can now handle state using hooks, making them a more versatile option for developers.</p><p>React components can be rendered using &lt;&gt; brackets, similar to HTML elements.</p><pre>// App.js<br>import { Header } from &#39;./Header&#39;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;Header /&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;))<br>root.render(&lt;App /&gt;);<br><br>// Header.jsx<br><br>export const Header = () =&gt; {<br>  return &lt;h1&gt;App Title&lt;/h1&gt;;<br>};<br></pre><p>Components can also render child components, forming a parent-child relationship. To pass information between components, React provides a mechanism called props, which are key-value pairs similar to HTML attributes. Props are passed from the parent component to the child component, but not vice versa.</p><pre>const App = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;Book title={&#39;To Kill a Mockingbird&#39;} author={&#39;Harper Lee&#39;} /&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>const Book = (props) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;{props.title}&lt;/h2&gt;<br>      &lt;p&gt;{props.author}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>As the complexity of an app increases, we can isolate and work on individual components to deal with one piece of functionality at a time.</p><h4>State</h4><p>React state is used to keep track of any data in applications that may need to change over time, making the app dynamic. By using state, we can update the information rendered on a page, which otherwise would remain static.</p><p>React’s useState hook allows us to create a state variable that can be updated over time, making it more dynamic by tracking changes over time. This hook takes one argument, the initial value of the state, and returns an array with two elements: the current state value and a function to update the state value, which can be accessed using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">destructuring assignment</a>.</p><pre>import { useState } from &#39;react&#39;;<br><br>const Counter = () =&gt; {<br>  const [count, setCount] = useState(0);<br><br>  const handleIncrement = () =&gt; {<br>    setCount(count + 1);<br>  };<br><br>  const handleReset = () =&gt; {<br>    setCount(0);<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Counter&lt;/h1&gt;<br>      &lt;p&gt;{count}&lt;/p&gt;<br>      &lt;button onClick={handleIncrement}&gt;Increment&lt;/button&gt;<br>      &lt;button onClick={handleReset}&gt;Reset&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>In this example, the Counter component initialises a state variable called count with an initial value of 0. Two functions, handleIncrement and handleReset, update the count state variable when called by incrementing or resetting it, respectively.</p><p>The component renders the current value of count and two buttons, ‘Increment’ and ‘Reset’ that trigger the corresponding state update functions when clicked. As count changes, React automatically updates the rendered HTML to reflect the new value.</p><p>The setCounter functions can be called in two ways: directly passing the new value of the state, or passing a function that returns the new state value.</p><p>When the new state value depends on the current value, it&#39;s recommended to use the function approach to ensure that the value is correct even when the state is updated multiple times quickly.</p><p>In more complex cases, it&#39;s recommended to extract the state updates into helper functions. The example below shows a counter component that increments and decrements a count value.</p><pre>const App = () =&gt; {<br>  const [count, setCount] = useState(0);<br><br>  const incrementCount = (increment) =&gt; {<br>    setCount((currCount) =&gt; {<br>      return currCount + increment;<br>    });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Count : {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; incrementCount(1)}&gt;Increase Count&lt;/button&gt;<br>      &lt;button onClick={() =&gt; incrementCount(-1)}&gt;Decrease Count&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>React state is designed to be replaced, not mutated. We should use the setState functions to replace old values instead of directly mutating them.</p><p>We can pass any value from a parent component to a child component via props in React. This allows us to extract functionality into separate components.</p><p>The child components can update their parent’s state through the use of the setState functions, which can be passed as a prop. We should keep in mind that the rules of state still apply, and we should never mutate state directly.</p><p>A good rule of thumb is to <em>place your state as low as possible, but as high as necessary.</em></p><p>When organizing data in React state, it’s important to consider factors such as avoiding duplicate data, deriving necessary information, keeping data flat, use cases in your application, extensibility, and performance.</p><p>The state should be a complete representation of the UI, but unnecessary information should be avoided. It’s also possible to derive data from the state instead of adding additional state variables.</p><p>This can be done by creating functions that extract the necessary information from the state. Testing these functions can help ensure their accuracy.</p><h4>Controlled components</h4><p>Controlled components are used to keep the state as the source of truth and to be in control of what value the input has.</p><p>A component is controlled if its value is set with a prop and changes to that value are handled by React.</p><p>Uncontrolled components keep their own internal state and can be useful for integrating React into non-React projects.</p><p>A React onChange event is triggered by any change to the inputs value and inside the onChange function, the event.target.value is used to read the incoming change and update the React state accordingly.</p><pre>import React, { useState } from &#39;react&#39;;<br><br>const NameForm = () =&gt; {<br>  const [name, setName] = useState(&#39;&#39;);<br><br>  const handleSubmit = (event) =&gt; {<br>    event.preventDefault();<br>    console.log(&#39;Name submitted: &#39;, name);<br>  };<br><br>  return (<br>    &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;label&gt;<br>        Name:<br>        &lt;input<br>          type=&quot;text&quot;<br>          value={name}<br>          onChange={(event) =&gt; setName(event.target.value)}<br>        /&gt;<br>      &lt;/label&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>};<br><br>export default NameForm;</pre><p>In this example, we have a NameForm component that renders a form with a single input field for the user to enter their name.</p><p>The input value is stored in the name state variable, which is updated whenever the user types in the input field using the onChange handler.</p><p>When the form is submitted, the handleSubmit function is called, which prevents the default form submission behavior and logs the entered name to the console.</p><h3>Emotional check ⏩</h3><p>Transitioning from backend to frontend in a rapid manner has proven to be quite challenging, given more time, I would have preferred to solidify my understanding of backend concepts more thoroughly.</p><p>However, the nature of bootcamps requires a swift pace in order to cover a wide range of topics. The accelerated learning pace has been valuable too and I have absorbed a great deal of information in a short period of time.</p><p>The bootcamp offers a multitude of hands-on mini-projects, which provide ample opportunities to gain practical experience. As long as I grasp the underlying concepts, I believe that continued practice will eventually result in greater confidence and proficiency in implementation.</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8 👀</li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f15d710d7a25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 7: Backend Project, Async Await & CICD]]></title>
            <link>https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/26ec33bf2507</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 19:13:11 GMT</pubDate>
            <atom:updated>2023-03-25T09:51:05.986Z</atom:updated>
            <content:encoded><![CDATA[<h4>Backend development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*maaX102MWLL37g3U" /><figcaption>Used Kanban for project workflow management</figcaption></figure><h3>Backend Project — News API ✨</h3><p>For my backend project I chose to create a news API that allows users to retrieve information on topics, articles, users and comments.</p><p>I set up an instance of my database using <a href="https://www.elephantsql.com/">ElephantSQL</a> and hosted my API using <a href="https://render.com/">Render</a>.</p><p>You can check out my <a href="https://github.com/reemhd/News-API">GitHub repo</a> for more info.</p><h3>Async/Await ⏲</h3><p>The async / await pattern is syntactic sugar which allows promise-based asynchronicity to be written in a way that looks like synchronous code. It is much easier to read and understand and helps you avoid callback hell.</p><p>The keyword is used to declare a function as asynchronous. When a function is marked as async, it always returns a promise. Inside an async function, you can use the await keyword to wait for the completion of an asynchronous operation before proceeding with the next line of code. The await keyword can only be used inside an async function.</p><pre>async function getSomeData() {<br>  const data = await fetchData();<br>  return data;<br>}<br><br>getSomeData()<br>  .then(data =&gt; console.log(data))<br>  .catch(error =&gt; console.error(error));</pre><p>In the code above, fetchData() returns a promise, the await keyword is used to wait for the promise to resolve and return the result.</p><p>Once the result is available, it is assigned to the data variable, and then the function returns the data.</p><p>Then getSomeData() function is called and the results is logged to the console and if an error occurs then the error is logged instead.</p><p>It could also be written in a try / catch block as below.</p><pre>async function main() {<br>  try {<br>    const data = await getSomeData();<br>    console.log(data);<br>  } catch (error) {<br>    console.error(error);<br>  }<br>}<br><br>main();</pre><h3>CICD</h3><p>CI/CD stands for Continuous Integration and Continuous Delivery/Deployment, and it is an approach to software development that involves automating the testing and delivery of code changes.</p><p>The goal of CI/CD is to enable faster, more frequent releases of software with higher quality and less risk. It does this by automating the process of building, testing, and deploying code changes, making it possible to quickly detect and fix issues before they become major problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*23Fh1tq2pofQMaitepMjtg.png" /></figure><p>Here is an example workflow for implementing CI/CD:</p><ol><li>Developer writes code and pushes changes to GitHub repository.</li><li>CI server detects changes and pulls code from GitHub.</li><li>CI server runs automated tests to ensure code quality.</li><li>If tests pass, the CI server automatically builds and packages the code.</li><li>CD server deploys the new code package to a staging environment.</li><li>QA team performs additional testing and verifies the code quality.</li><li>If the code passes testing, CD server deploys the code to production.</li></ol><p>GitHub Actions is a powerful tool for automating software workflows. You can use it to create a continuous integration and delivery (CI/CD) pipeline that automatically builds, tests, and deploys your code to a target environment whenever changes are made to the repository.</p><h3>Emotional check 💻</h3><p>This has been an incredible week for me, I’ve had numerous deep work sessions, resulting in a high level of productivity.</p><p>Even though we have previously worked on smaller functions with specific purposes, this week I got to witness the code come to life and comprehend how everything fits together. Plus, I now possess the ability to construct an API from scratch.</p><p>However, we are starting with frontend development next week, and I feel like I haven’t explored the backend fully yet. I found it extremely satisfying to create the server-side logic, and I wish to delve deeper into it.</p><p>That being said, I am also excited to work on the frontend as it will provide me with an opportunity to unleash my creative side. 🌱</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7 👀</li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26ec33bf2507" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 6: Node Postgres, Supertest & Error Handling with Express]]></title>
            <link>https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/278b283aecfc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 14:37:43 GMT</pubDate>
            <atom:updated>2023-05-17T04:29:51.429Z</atom:updated>
            <content:encoded><![CDATA[<h4>Backend development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NjtKXhFizpPOSNge" /><figcaption>Complexity arises from simplicity</figcaption></figure><h4>Node-Postgres</h4><p>Also known as <em>pg</em>, is a popular PostgreSQL client library for Node.js. It provides a way to connect to a PostgreSQL database from a Node.js application and perform various database operations.</p><p>One of the key features of <em>pg</em> includes <strong>connection pooling</strong>, which is a technique used to improve the performance and scalability of database applications by reusing database connection instead of creating new connection for each request. This maintains a pool of open database connections that are shared among clients.</p><pre>// db/index.js<br>const { Pool } = require(&quot;pg&quot;);<br><br>if (!process.env.PGDATABASE) {<br>  throw new Error(&quot;No PGDATABASE configured&quot;);<br>}<br><br>module.exports = new Pool();</pre><p><strong><em>pg</em> with express</strong></p><p>After installing <em>pg </em>and<em> express</em>, you can set up an app.js file as below. Using MVC model, the controller is where we deal with the request | response cycle and the model is interacting with the database via connection pool.</p><pre>// app.js<br>const express = require(&#39;express&#39;);<br>const { sendSnacks } = require(&#39;./controllers/snacks.js&#39;)<br>const app = express();<br><br>app.get(&#39;/api/snacks&#39;, sendSnacks);<br><br>// controllers/snacks.js<br>const selectSnacks = require(&#39;../models/snacksDb.js&#39;)<br><br>exports.sendSnacks = (req, res) =&gt; {<br>  snacksDb()<br>  .then(snacks =&gt; res.status(200).send({ snacks }));<br>}<br><br>// models/snacksDb.js<br>const db = require(&#39;../db/index.js&#39;)<br>exports.snacksDb = () =&gt; {<br> return db.query(&#39;SELECT * FROM snacks_table&#39;)<br>        .then(results =&gt; return results.row);</pre><p>When working with specific parametric endpoints like ‘/snacks/:snack_id’, we can access the request parameters using <em>req.params</em> in the controller function. We avoid using string template literals or string concatenation as it could lead to <a href="https://www.youtube.com/watch?v=ciNHn38EyRc">SQL injection</a>.</p><p>Instead we could use the following code:</p><pre>// models/snacks.js<br>exports.selectSnackById = (snack_id) =&gt; {<br>  return db<br>    .query(&quot;SELECT * FROM snacks WHERE snack_id = $1;&quot;, [snack_id])<br>    .then((result) =&gt; result.rows[0]);<br>};</pre><p>Everything above was for a get request, we can follow the same for post, put, delete methods too. For a post/put method, the controller is then responsible for passing the request body (<em>req.body</em>) to the model, and sending the newly inserted/updated snack to the client.</p><p>We want to use a body-parser middleware to parse the request body.</p><h4>Seeding databases</h4><p>Populating databases manually is time-consuming so we do this programatically instead using <a href="https://node-postgres.com/features/queries#parameterized-query">parameterised query</a>, which uses placeholders or parameters to pass values to the query at runtime.</p><p>We can install <em>pg-format</em> for this, allowing us to insert multiple values as below:</p><pre>const format = require(&#39;pg-format&#39;);<br>const db = require(&#39;../db/index.js&#39;);<br><br>const itemsInsertStr = format(<br>  `INSERT INTO items<br>    (item_name, quantity)<br>  VALUES<br>    %L<br>  RETURNING *;`,<br>  nestedArrOfValues // [[&#39;item-A&#39;, 3], [&#39;item-B&#39;, 5], [...], ...]<br>);<br><br>db.query(itemsInsertStr).then((itemsInsertResult) =&gt; itemsInsertResult.rows[0]);</pre><p>format takes two arguments — SQL query and nested array of the values that you can create using map function.</p><p>We can create a seed function which drops tables, creates tables and populates a database with initial data.</p><h4>Supertest</h4><p>Up to this point we have been carrying out unit testing with Jest as part of TDD, <strong>integration testing</strong> ensures that multiple parts of a project work cohesively together. Supertest is a type of integration testing used in conjunction with Jest to make request to the server and test the response is correct.</p><p>Install <a href="https://www.npmjs.com/package/supertest">supertest</a> and jest a dev dependency as they are specifically used for testing and not the actual operation of the application.</p><p>To make a test request to the app, the request variable (supertest) is passed the app as an argument within the jest test block - if the server is not already listening for connections then it is bound to a temporary port, so there is no need to keep track of ports.</p><pre>describe(&#39;GET /api/items&#39;, () =&gt; {<br>  it(&#39;responds with object containing all items&#39;, () =&gt; {<br>    return request(app)<br>    .get(&#39;/api/items&#39;)<br>    .expect(200)<br>    .then((res) =&gt; {<br>      expect(res.body.items.length).toBe(4);<br>    });<br>  });<br>});</pre><p>As we continue testing different endpoints especially post or put that modifies the original data, our testing may become unreliable so we can reseed the database by using the following in out test suite:</p><pre>beforeEach(() =&gt; seed(data));<br><br>afterAll(() =&gt; db.end());</pre><p>beforeEach functions allows to reseed the database with our seed function and afterAll function ensures the connection to the pool is closed and make it available for reuse by other clients in the pool.</p><h4>Error Handling with Express</h4><p>We can send an error from the controller if things don’t go as planned but it will get repetitive to do this for every controller. Instead we can make use of <em>next()</em> which can invoked with an argument to send it to an error-handling middleware or without an argument which moves on to the next middleware function.</p><p>Express has a default error handler for if another error-handling-middleware function has not been defined, which by default will send a status 500 with the error that <em>next</em> has been invoked with.</p><p>PSQL throws error too but they are not the same as HTTP status codes example ‘22P02’ error represents invalid_text_representation so we can create error handling middleware to send an appropriate response.</p><pre>// app.js<br>app.use((err, req, res, next) =&gt; {<br>  if (err.code === &#39;22P02&#39;) {<br>    res.status(400).send({ msg: &#39;Bad Request&#39; });<br>  } else res.status(500).send({ msg: &#39;Internal Server Error&#39; });<br>});</pre><p>If there is no error with the SQL query, but the query does not return any data/rows then we can create a custom error handler.</p><h4>Databases for Testing and Development</h4><p>pg finds which database to connect through from the environmental variables which is normally set in the package.json scripts but there is an npm package called <a href="https://www.npmjs.com/package/dotenv"><em>dotenv</em></a> that can help us configure environmental variables.</p><p>After installing it, we create a file with a ‘.env’ extension to store our variables and add it to gitignore file to prevent it from being pushed to GitHub.</p><p>Once we set up the connection to the database via pool, we can require dotenv and invoke config method as below:</p><pre>const { Pool } = require(&#39;pg&#39;);<br><br>const ENV = process.env.NODE_ENV || &#39;development&#39;;<br><br>require(&#39;dotenv&#39;).config({<br>  path: `${__dirname}/../.env.${ENV}`,<br>});<br><br>if (!process.env.PGDATABASE) {<br>  throw new Error(&#39;PGDATABASE not set&#39;);<br>}<br><br>module.exports = new Pool();</pre><p>ENV is either set to either test when run through supertest or development.</p><pre>// .env.development <br>PGDATABASE=database_name_developement<br>// .env.test<br>PGDATABASE=database_name_test</pre><p>We have separate database for testing so that users don’t experience unexpected changes to the data every time it is re-seeded or if the test makes changes to the database.</p><p>Plus developers can use smaller data which is more manageable subset of the development data, which means seeding can happen more quickly.</p><p>You can create one reusable seed function that can seed both the test database and development database.</p><h3>Links for the Week</h3><ul><li><a href="https://www.postgresql.org/docs/current/errcodes-appendix.html">PSQL error codes</a></li><li><a href="https://node-postgres.com/">Node Postgres</a></li></ul><h3>Emotional check 🌏</h3><p>This past week has been a whirlwind of learning, with a lot of complex backend concepts to absorb. Despite the intensity, all of the pieces will come together next week when I will be starting project week, during which I’ll be building a server from scratch to connect with my frontend project a few weeks down the line.</p><p>I’m glad that I made the decision to write these weekly articles, as they serve as a helpful summary of everything I’ve learned and understood over the past week and hopefully it makes sense to anyone reading them and provide some insight into the different concepts and topics.</p><p>After a week of blurry vision, I got my eyes tested and turns out my vision is actually improving but my lenses were crazed i.e. the reflective coating cracked due to high temperatures. If you wear glasses, remember not to shower with them on.</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6 👀</li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=278b283aecfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 5: HTTP, Express, Model-View-Controller (MVC) Pattern & SQL]]></title>
            <link>https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a22de2a0ce3</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 12 Feb 2023 12:50:22 GMT</pubDate>
            <atom:updated>2023-03-25T09:50:46.318Z</atom:updated>
            <content:encoded><![CDATA[<h4>Backend development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEt_JNsBVMSELV851kRoRA.jpeg" /></figure><p>I was slightly apprehensive starting week 5, mainly because of my limited experience in backend development, though the uncertainty made it all the more exciting.</p><h3>HTTP</h3><p>We first started with building a server from scratch by using <em>.createServer() </em>method and used .listen() on the desired port.</p><pre>const http = require(&#39;http&#39;)<br><br>const server = http.createServer((request, response) =&gt; {<br>  response.setHeader(&#39;Content-Type&#39;, &#39;application/json&#39;);<br>  response.statusCode = 200;<br>  response.write(JSON.stringify({ msg: &#39;hello world&#39; }));<br>  response.end();<br>  if (url === &#39;/users&#39; &amp;&amp; method === &#39;GET&#39;) {<br>    // logic to retrieve users data and send back to the client on the response body<br>  }<br>  if (url === &#39;/users&#39; &amp;&amp; method === &#39;POST&#39;) {<br>    // logic to add the new user from the request body to the data and send the appropriate response<br>  }<br>});<br><br>server.listen(9090, (err) =&gt; {<br>  if (err) console.log(err);<br>  else console.log(&#39;Server listening on port: 9090&#39;);<br>});</pre><p><a href="https://insomnia.rest/">Insomnia</a> was used for testing and debugging HTTP requests. The app allows to create and send requests to web servers, view responses, and analyse the results. It is commonly used in web development and API testing.</p><p>A lot of code has to be written in order to send a response to the client/application and also needs to ‘end’ so the client is not left hanging. We also need to state url paths and type of method used.</p><p>Additionally when dealing with post/patch/put requisitions, the body of the request needs to be pieced together as data is received in packets, similar to collecting the packets of data that form the body of a response when making requests using http.</p><p>But express abstracts away a lot of the above, presenting cleaner and concise code.</p><h3>Express</h3><p>Express.js is a popular open-source web application framework for Node.js. It provides a set of features and tools for building web applications and APIs, including middleware, routing, and templating.</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.status(200).send({ msg: &#39;Welcome&#39; });<br>});<br><br>app.listen(9090, () =&gt; {<br>  console.log(`Server is listening on port 9090...`);<br>});</pre><p>In the code above, the second argument passed to the app.get() method is referred to as a middleware function.</p><p>Middleware functions in Express.js are functions that have access to the request and response objects in the application’s request-response cycle. They can perform various operations on the request and response objects or modify them in some way.</p><p>The code is far more succinct than using http.createServer routing.</p><p>REST (Representational State Transfer) is a software architectural style that defines a set of constraints and principles for building web services.</p><p>RESTful routing typically follows a convention over configuration approach, where the URL structure and HTTP methods used for each resource follow a consistent pattern that is easy to understand and maintain.</p><p>Example: instead of having /fetch-cats and /add-cats, /cats can use both a GET and a POST method on the same route.</p><pre>// get<br>app.get(&#39;/cats&#39;, (req, res) =&gt; {<br>  const { cheeky } = req.query;<br>  // we would then get our cheeky or not cheeky cats from the data<br>  // and then send the response<br>});<br><br>app.use(express.json());<br><br>//post<br>app.post(&#39;/cats&#39;, (req, res) =&gt; {<br>  console.log(req.body);<br>});</pre><p>In order to access the body of the request that is made to the sever, we need to use application-level middleware.</p><p>express.json() is a built in middleware function that will parse incoming request JSON bodies, making them available under the req.body property in the controller functions.</p><p>The next function is used to pass control to the next middleware function in the stack. Middleware functions are executed in the order in which they are defined, and the next function is used to pass control to the next middleware function in the stack.</p><p>** You can add <a href="https://www.npmjs.com/package/nodemon">nodemon</a> which restarts the server automatically anytime the JS file is modified. **</p><h3>MVC architecture</h3><p>Writing different endpoints with different routers can make the code very lengthy and hard to debug but MVC pattern can make servers more manageable by handling different aspects of the application with different functions.</p><ul><li>Model — represents the data and business logic of the application. It manages the data, defines how the data should be stored, and provides methods for accessing and modifying the data.</li><li>View — represents the presentation of the data to the user. It defines the layout and appearance of the user interface and displays the data to the user in a way that is understandable and visually appealing.</li><li>Controller — acts as an intermediary between the Model and View. It receives input from the user and updates the Model and View accordingly. It also contains the business logic for handling user input and controlling the flow of the application.</li></ul><pre>// app.js - our server<br>app.get(&#39;/api/cats/:catId&#39;, getCatById);<br><br>// controllers.js - responsible for handling the request, invoking the model, and sending the response<br>exports.getCatById = (req, res) =&gt; {<br>  const { catId } = req.params;<br>  selectCatById(catId).then((cat) =&gt; {<br>    res.status(200).send({ cat });<br>  });<br>};<br><br>// models.js - responsible for interacting with the data and sending data back to the controller (in this case using return). It then catches any error and returns it by using a &#39;catch&#39; block. <br>const { readFile } = require(&#39;fs/promises&#39;)<br>exports.selectCatById = (catId) =&gt; {<br>  return readFile(`data/cats/${catId}.json`, &#39;utf8&#39;).then((catString, err) =&gt; {<br>      const parsedCat = JSON.parse(catString);<br>      return parsedCat<br>    }).catch((err) =&gt; {<br>      return err<br>    })<br>  };;</pre><p>The benefits of using the MVC pattern include increased maintainability, reusability, and modularity of the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rSuCjQwLzjqCJIBuxOBKFA.png" /><figcaption>MVC Flow</figcaption></figure><h3>SQL</h3><p>I have experience with SQL from doing a course on <a href="https://www.codecademy.com/learn/learn-sql">Codecademy</a> and through <a href="https://cs50.harvard.edu/x/2023/weeks/7/">CS50x</a>, it was a good recap and reminder how tedious SQL can be.</p><p>But we looked at the difference between Relational vs Non-Relational Databases, used PostgreSQL CLI to create/delete databases, CRUD operations on SQL tables, SQL relations and join/aggregate functions.</p><h3>Links for the Week</h3><ul><li><a href="https://devdocs.io/node/http#httpcreateserveroptions-requestlistener">DevDocs HTTP</a></li><li><a href="https://devdocs.io/express/">DevDocs Express</a></li><li><a href="https://www.pgexercises.com/questions/basic/">PostgreSQL exercises</a></li><li><a href="https://http.cat/">Status codes</a></li></ul><h3>Emotional check ⭕️</h3><p>All’s well and good, with the abundance of work provided by the bootcamp, concepts eventually solidifies in one’s mind. I am enjoying the intensity akin to progressive overload during weight training, the brain’ plasticity seems to be well adjusted to any increase in complexity.</p><p>Pair programming, despite its challenges, has proven to serve as a valuable source of social interaction. Rather than solely focusing on productivity, it provides an opportunity to learn how to effectively collaborate on code with another individual. Even if it can be frustrating at times, it can help improve emotional intelligence.</p><p>However, I do find myself longing for structured deep work sessions, where distractions are minimized, and focus is solely on the task at hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1u13nPwDx-f8iYNs" /><figcaption>Revisited deep work by Cal Newport over the weekend</figcaption></figure><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5 👀</li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a22de2a0ce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 4: Review day, Asynchronous Callbacks, Internet & Promises]]></title>
            <link>https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/d24dffee842e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 05 Feb 2023 22:51:13 GMT</pubDate>
            <atom:updated>2023-03-25T09:50:35.948Z</atom:updated>
            <content:encoded><![CDATA[<h4>JavaScript Fundamentals</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AwvTMB0W_vRrKhbK" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The week began with a monthly review which consisted of a coding sprint on previously learnt topics such as array methods, object-oriented programming, closures, and recursion.</p><p>We employed a test-driven development approach to demonstrate our understanding of the topics and of good TDD practices.</p><h4>CallBack</h4><p>We learnt the significance of callbacks and the distinction between blocking and non-blocking input/output operations.</p><p>We delved into the intricacies of asynchronous functions, how they work in terms of background threads, the event loop, and the task queue.</p><p>Background threads are managed by the Node API, which stores delayed or async functions. Once the data is received or the time has lapsed, the function is added to the task/callback queue (First In First Out), rather than the call stack (Last In First Out), to ensure that it is not invoked immediately.</p><p>The event loop in Node.js is tasked with checking whether the call stack is empty and then pushing the first function in the queue onto the call stack, allowing it to be invoked.</p><p>We also covered the handling of errors, multiple asynchronous requests, response ordering, and inversion of control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*nMxbDRtYXM5wUmKYzsjhYw.jpeg" /><figcaption>Callback Hell | Pyramid of Doom</figcaption></figure><h4>How the Internet Works</h4><p>We covered how data is sent over the internet from client to server by using CRUD (Create, Read, Update, and Delete) methods to make requests.</p><p>I summarised most of this in my — <a href="https://medium.com/@rhalde/network-basics-a02cad65a22">Network Basics</a> article.</p><p>Here’s a <a href="https://www.youtube.com/watch?v=Dxcc6ycZ73M&amp;list=PLzdnOPI1iJNfMRZm5DDxco3UdsFegvuB7&amp;index=1">series</a> on how the internet works.</p><pre>const https = require(&quot;https&quot;);<br><br>const options = {<br>  hostname: &quot;***.com&quot;,<br>  path: &quot;/api/***&quot;,<br>  method: &quot;GET&quot;,<br>};<br><br>const request = https.request(options, (response) =&gt; {<br>  // do something with response<br>});<br><br>request.end();</pre><h4>Promises</h4><p>Promises are a layer of abstraction over callbacks and avoids you getting into callback hell. We use promises as placeholders for async process, the .then() and .catch() methods are used to handle resolved states of a promise.</p><pre>const inquirer = require(&#39;inquirer&#39;)<br>const axios = require(&#39;axios&#39;)<br><br>function getSinglePokemon() {<br>   return inquirer<br>     .prompt([<br>       {<br>         type: &quot;input&quot;,<br>         name: &quot;number&quot;,<br>         message: &quot;Enter a number&quot;,<br>       },<br>     ])<br>     .then(({ number }) =&gt; {<br>       return axios<br>         .get(`https://pokeapi.co/api/v2/pokemon/${number}`)<br>         .then((response) =&gt; {<br>           console.log(response.data.name);<br>         })<br>         .catch((err) =&gt; {<br>            if (err.response.status === 404) console.log(&#39;Pokemon does not exist&#39;)<br>           else console.log(err);<br>         });<br>     });<br>}<br><br>getSinglePokemon()</pre><p>The function above uses third-party promise-based libraries — axios is used to make HTTPS requests and inquirer for interactive prompts. When invoked, the function asks the user to input a number and finds the name of the Pokemon at that number.</p><h4>Links for the Week</h4><ul><li><a href="https://www.codecademy.com/learn/asynchronous-javascript/modules/javascript-promises/cheatsheet">Codecademy Promises</a></li><li>A series on <a href="https://www.youtube.com/watch?v=Dxcc6ycZ73M&amp;list=PLzdnOPI1iJNfMRZm5DDxco3UdsFegvuB7&amp;index=1">How the Internet Works</a></li><li><a href="https://www.oreilly.com/library/view/javascript-with-promises/9781491930779/ch01.html">Asynchronous JS</a></li><li><a href="https://github.com/SBoudrias/Inquirer.js#installation">Inquirer</a></li><li><a href="https://github.com/axios/axios#example">Axios</a></li></ul><h4>Emotional check ✔️</h4><p>As the weeks progress, the learning experience becomes increasingly intense and interesting. The different concepts are taught in rapid successions, which can mean that sometimes it is challenging to fully solidify the previous knowledge before moving on to the next.</p><p>But I guess that is the nature of a bootcamp, fast-paced. I spent some time over the weekend to revisit some topics that required a deeper understanding.</p><p>Next week, we embark on a new journey — Backend.</p><p>I enjoyed pair programming this week, mostly for its social aspect but I also appreciate gaining a unique perspective on how others approach problem-solving.</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4 👀</li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d24dffee842e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 3: Recursion, Object Oriented Programming, Data Structures — Stacks & Queues]]></title>
            <link>https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/371cb632a2ab</guid>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 29 Jan 2023 20:04:36 GMT</pubDate>
            <atom:updated>2023-03-25T09:50:26.527Z</atom:updated>
            <content:encoded><![CDATA[<h4>JavaScript Fundamentals</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LpO7oiyu62KkebU2" /></figure><p>It has been a content heavy week, but my prefrontal cortex loves a challenge. I can see the benefits of using Test-Driven Development with every code written, not only does it ensure the intended functionality of the code but also allows for better understanding of concepts.</p><h4><a href="https://www.youtube.com/watch?v=aCPkszeKRa4">Recursion</a></h4><p>It is an interesting concept to grasp, it becomes clearer and more comprehensible when it is explained in the context of its function within the call stack and the distinctions between global and local execution.</p><p>In recursion, multiple calls may build up on the call stack which operates on a last in, first out principle (LIFO) and waits for the base case to be met, then the previous calls can evaluate and resolve.</p><p>Base case + Recursive step + Recursive call.</p><pre>// Recursively adding numbers from 1 to num<br><br>function sum (num) {<br>    if (num === 1) return 1; // base case<br>    return num + sum(num - 1); // recursion<br>};</pre><h4>Object-Oriented Programming (OOP)</h4><p>We started with building factory function using TDD and completed a coding sprint on data structures — <a href="https://medium.com/@_jmoller/javascript-data-structures-stacks-and-queues-ea877d72a5f9">stacks</a> and <a href="https://www.freecodecamp.org/news/how-javascript-implements-oop/">queues</a>.</p><p>The principles of Object-Oriented Programming (OOP) in JavaScript are:</p><ol><li>Abstraction: Hiding the implementation details and exposing only the necessary information to the user.</li><li>Encapsulation: Wrapping data and behavior within an object to protect its state from outside interference.</li><li>Inheritance: Creating new objects based on existing objects, which can inherit properties and behavior.</li><li>Polymorphism: Allowing objects to take on many forms, such as a single method having multiple implementations based on context.</li></ol><p>OOP exploits the fact that objects in JavaScript can hold data in properties and hold ‘behaviours’ as methods/functions.</p><p>If we want to create lots of objects that all have the same basic blueprint, we can create a factory function. This function can return a new object every time it&#39;s called, where each one is initialised with the same template.</p><p><em>This</em> keyword: represents the context of the function. Whenever a function is called as a method of an object, the <em>this</em> inside of it gets implicitly bound to whatever object is calling the function (i.e. the object left of the dot).</p><p>Example of factory function:</p><pre>function factoryFn(name) {<br>  const newUser = {}<br>  newUser.username = name;<br>  newUser.basket = [];<br>}<br><br>fuction addToBasket(item) {<br>  this.basket.push(item)<br>}<br><br>const mandy = createUser(&quot;Mandy&quot;)<br>mandy.addToBasket(&#39;pear&#39;) // adds pear to basket<br></pre><p>mandy is an instance of factoryFn and owner of the function addToBasket, so any occurrences of <em>this</em> within that function act as placeholder for the mandy object.</p><h4>Prototypes</h4><p>So in the example above, we can see that function addToBasket() is just floating around in the void so to encapsulate it, we can use prototype, a property of an object that allows you to share properties and methods among different instances of the same object.</p><pre>const userPrototype = {<br>  addToBasket: fuction (item) {<br>  this.basket.push(item)<br> }<br>  deleteLastItem: function () {<br>  this.basket.pop()<br> }<br>}<br><br>function newUser(name) {<br>  const newUser = Object.create(userPrototype)<br>  newUser.username = name;<br>  newUser.basket = [];<br>}<br><br>const mandy = newUser(&#39;Mandy&#39;)<br>mandy.addToBasket(&#39;pear&#39;) <br>mandy.deleteLastItem()<br>// mandy.basket would return []</pre><p>The prototypal object called userPrototype has methods declared in there that are shared across all instances of the factory functions.</p><p>In order to assign this as a prototypal object for our factory functions we will make use of the Object.createmethod.</p><p>But then enters Class…</p><h4>Class</h4><p>Classes are syntactic sugar that abstracts away all of days 2 and 3 away. When we create a class, we also create a constructor within it, which is a method that is called when <em>instantiating</em> the class with the ‘new’ operator.</p><pre>class User {<br>  constructor(name) {<br>  this.name = name;<br>  this.online = false<br> }<br>  <br>  greet() {<br>    console.log(&#39;Hello&#39;, this.name)<br>  }<br>}<br><br>const user1 = new User(&#39;Mandy&#39;)<br>user1.greet() // outputs &#39;Hello Mandy&#39;<br></pre><p>So now we have our ‘factory function’ and prototype all in the class and user1 is an instance of that class that has all the properties and methods from that class.</p><p>Classes can inherit and extend from other classes too.</p><h4>Get &amp; Set</h4><p>A getter is a method used to retrieve the value of an object’s property and a setter is a method used to change the value of an object’s property.</p><pre>class Person {<br>  constructor(name) {<br>    this._name = name;<br>  }<br>  get name() {<br>    return this._name;<br>  }<br>  set name(newName) {<br>    this._name = newName;<br>  }<br>}<br><br>const person = new Person(&quot;John&quot;);<br>console.log(person.name); // outputs &quot;John&quot;<br>person.name = &quot;Jane&quot;;<br>console.log(person.name); // outputs &quot;Jane&quot;</pre><p>We can create private fields which cannot be accessed outside of the class declaration by using # name.</p><pre>class TimeSheet {<br> #hoursWorked = 0;<br> #hourlyRate;<br> #shiftLength = 8;<br><br> constructor(name, hourlyRate) {<br>  this.name = name;<br>  this.#hourlyRate = hourlyRate;<br> }<br>}<br><br>davidsTimeSheet.name; // &quot;David&quot; - public field<br>davidsTimeSheet.hoursWorked; // undefined - private field</pre><h4>Links for the week</h4><p>I am more of a visual/reading type of learner so I found referring to textbooks helped with the low-level understanding of how OOP worked.</p><ul><li><a href="https://pepa.holla.cz/wp-content/uploads/2015/11/The-Principles-of-Object-Oriented-JavaScript.pdf">The principles of OOP JS byNicholas Zakas</a></li><li><a href="https://github.com/sugarac/JS-Books/blob/master/Mastering%20JavaScript%20Object-Oriented%20Programming.pdf">Mastering JS OOP by Andrea Chiarelli</a></li><li><a href="https://www.freecodecamp.org/news/how-javascript-implements-oop/">OOP by fcc</a></li></ul><h4>Emotional/Limbic Check-In 👁🩸</h4><p>I suffered with blurry vision by the end of this week, so I rotated my desk to face my window to use the 20–20–20 rule (every 20 minutes, look at something 20 feet away for 20 seconds).</p><p>The Pokémon game sprint was fun but I was paired with someone who had no intention of becoming a software developer or learning JS so we ended up with spaghetti code. I slithered my way out of the pairing and spent a decent amount of time untangling the mess but was able to implement the game in the end.</p><p>I really appreciate the complexity of video games. I am currently playing Cyberpunk 2077 and I find myself consistently delving into the thought processes behind the mechanics, striving to comprehend the logic that went into its creation.</p><h4>computerSci.concat(biologySci) 🔗</h4><p>Learning about Object-Oriented Programming has made me contemplate whether humans are merely instances of the class HomoSapiens, sharing similar experiences but executing our “methods” differently.</p><p>We all evolved from the same prototypic eukaryote cell and eventually diverged into various taxonomic categories.</p><p>This can be observed in our close relatives, the chimpanzees, with whom we share a 98.7% similarity in DNA, a result of the 1.3% divergence/polymorphesim that occurred when our species extended from a common ancestor (inheritance).</p><p>Just a philosophical analogy to help me understand the concept, or perhaps also highlighting similarities in structure and behaviour between the digital and physical realm.</p><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3 👀</li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=371cb632a2ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 2: Node.js, NPM, Test Driven Development, Pair Programming & Closure]]></title>
            <link>https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/3029a6069794</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 21:53:54 GMT</pubDate>
            <atom:updated>2023-03-25T09:50:13.746Z</atom:updated>
            <content:encoded><![CDATA[<h4>JavaScript Fundamentals</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tkUifuA6EveZ02KU" /></figure><p>This week we were dived into the realm of unit testing utilising Jest and have been consistently using it in our daily development processes.</p><p>We started with pair programming and learnt the importance of it by collaborating in pairs, which proved to be the most challenging aspect of the week.</p><p>Test Driven Development Cycle: Red -&gt; Green -&gt; Refactor. <a href="https://www.youtube.com/watch?v=Jv2uxzhPFl4">Fireship</a> gotchu.</p><h4>Links</h4><ul><li><a href="https://medium.com/javascript-scene/what-every-unit-test-needs-f6cd34d9836d">How to Write Better Tests</a></li><li><a href="https://docs.npmjs.com/about-npm">NPM Docs</a></li><li><a href="https://jestjs.io/docs/getting-started">Getting started with Jest</a></li></ul><p><a href="https://www.youtube.com/watch?v=-hBJz2PPIVE">Value vs Reference</a> and <a href="https://www.youtube.com/watch?v=TkFN6e9ZDMw">Scope</a>.</p><p><a href="https://www.youtube.com/watch?v=fYbhD_KMCOg">Pure functions</a>.</p><p>We referenced <a href="https://lodash.com/">Lodash</a> documentation to implement TDD on our own versions of the functions. Also utilised <a href="https://jestjs.io/docs/mock-functions">Jest Mock Functions</a> in my code.</p><h4>Additional Links</h4><ul><li><a href="https://www.w3schools.com/js/js_function_closures.asp">Closure examples</a></li><li>More on <a href="https://www.freecodecamp.org/news/lets-learn-javascript-closures-66feb44f6a44">Closure</a></li><li>Another one on <a href="https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36#.szp9dswih">closure</a></li></ul><h4>Emotional Check-In ☢️</h4><p>This week, I had the opportunity to collaborate with two different people on my course, which was good in terms of socialising, but resulted in less productive work.</p><p>On the positive side, I have noticed a marked improvement in my ability to communicate code.</p><p>I must admit that my focus has been solely on coding, leaving little room for other pursuits, but I am not complaining, getting the work done is top priority.</p><figure><img alt="coder in the dark" src="https://cdn-images-1.medium.com/max/1024/0*VFi5B4NMzBdsX75A" /><figcaption>// my lyf rn</figcaption></figure><h3>Leap through time</h3><ul><li>Week 1: <a href="https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139">Command line, Git &amp; GitHub, JavaScript Basics &amp; Introduction to HTML/CSS</a></li><li>Week 2 👀</li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3029a6069794" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Bootcamp Week 1: Command line, Git & GitHub, JavaScript Basics & Introduction to HTML/CSS]]></title>
            <link>https://medium.com/@rhalde/what-i-learnt-at-a-coding-bootcamp-week-1-744fb3f53139?source=rss-c7b7d6a31c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/744fb3f53139</guid>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[R HD]]></dc:creator>
            <pubDate>Sun, 15 Jan 2023 11:22:31 GMT</pubDate>
            <atom:updated>2023-03-25T09:49:52.335Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction week</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SOExlBLLFCgEfD6b" /><figcaption>Photo by <a href="https://unsplash.com/@florianolv?utm_source=medium&amp;utm_medium=referral">Florian Olivo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to my 13-week journey of becoming a software developer. I started my bootcamp on Monday, January 9th, and I’m sharing my experiences and insights so it can help other emerging developers.</p><p>One of the things that I struggled with when learning to code on my own was the lack of structure and application of knowledge.</p><h4>What I did before starting the bootcamp</h4><p><a href="https://www.codecademy.com/learn/learn-python-3">Python</a>, <a href="https://www.codecademy.com/learn/paths/data-science">Machine Learning</a>, <a href="https://www.codecademy.com/learn/learn-the-command-line">Command line</a>, <a href="https://cs50.harvard.edu/x/2023/">CS50x</a>, <a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/">JavaScript</a>, <a href="https://www.codecademy.com/learn/learn-html">HTML</a> &amp; <a href="https://www.codecademy.com/learn/learn-css">CSS</a>.</p><p>And lots practice on <a href="https://leetcode.com/">leetcode</a> and <a href="https://www.codewars.com/dashboard">codewars</a>!</p><p>I use iTerm and Visual Studio Code and I set up my development environment by downloading:</p><ul><li><a href="https://brew.sh/">Brew</a></li><li><a href="https://nodejs.org/en/">Node</a> via <a href="https://github.com/nvm-sh/nvm#install--update-script">NVM</a></li><li><a href="https://www.postgresql.org/">PSQL</a></li><li><a href="https://www.zsh.org/">zsh</a></li><li><a href="https://ohmyz.sh/">oh-my-zsh</a></li></ul><p>I would suggest doing the freecodecamp JS course as majority of the first week was a recap of its content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KoJxbbUndPe09Ajq" /><figcaption>Photo by <a href="https://unsplash.com/@synkevych?utm_source=medium&amp;utm_medium=referral">Roman Synkevych 🇺🇦</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><a href="https://www.youtube.com/watch?v=RGOj5yH7evk&amp;t=105s">Git and GitHub</a></h4><p>Learnt about Git and GitHub and practiced the following:</p><ul><li>Started a project locally on my computer then moved it to Github</li><li>Created a repository(repo) on Github/ forked a repo and cloned it on my device</li><li>Practiced push and pull requests</li></ul><p>I also found <a href="https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZF9C0YMKuns9sLDzK6zoiV">this</a> series offered a clear and concise explanation of the concepts and provided hands-on exercises to practice the skills.</p><h4><a href="https://www.youtube.com/watch?v=jS4aFq5-91M">JavaScript Basics</a></h4><p>Part 1 — Data, variables, expressions, conditional logic, iteration and functions.</p><p>Downloaded Node and ran JS files by writing ‘node filename.js’ in the terminal window to test my code.</p><p>Part 2 — Objects and array, and understanding errors.</p><p><strong>Part 3 — </strong>Higher order array methods, regular expression and <a href="https://www.youtube.com/watch?v=cRHQNNcYf6s">export &amp; require</a>.</p><p>We also looked at what happens under the hood in a <em>Call Stack</em> which is explained well <a href="https://www.youtube.com/watch?v=-G9c4CMMUKc">here</a>.</p><p>Use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">MDN</a> documentation to peruse through it all.</p><h4>Intro to HTML and CSS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lnolQcLH0d8g7v8-" /><figcaption>Photo by <a href="https://unsplash.com/@jacksonsophat?utm_source=medium&amp;utm_medium=referral">Jackson Sophat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I found the course on codecademy useful for HTML/CSS but the fcc course is good too.</p><p>They asked us to make a simple webpage on anything and here’s what I made, please bear in mind the page is not responsive so will look different on different screen size&gt; <a href="https://astounding-kitsune-ea803b.netlify.app/">https://astounding-kitsune-ea803b.netlify.app/</a></p><p>You can use Netlify or Github pages to deploy your static webpages.</p><h4>Here are some additional links for the week</h4><ul><li><a href="https://www.atlassian.com/git/tutorials/what-is-version-control">Learn Git</a></li><li><a href="https://oliverelliott.org/article/computing/tut_unix/">Command-Line</a></li><li><a href="https://javascript.info/">JS explanations</a></li><li><a href="https://devdocs.io/">DevDocs</a></li><li><a href="https://regexr.com/">Regex pattern matcher</a></li><li><a href="https://vscode-shortcuts.com/">VSCode shortcuts</a></li></ul><h4>Emotional Check-In 🌊</h4><p>During the past week, I encountered difficulty in articulating even the most simplest of concepts such as a for loop. This was due to my reliance on my finger’s muscle memory and a lack of prior experience in verbalizing code.</p><p>This has brought to light the disconnection between my cognitive ability to solve problems and my ability to express code verbally, a gap that I hope I can bridge through practice and improvement.</p><p>And with all the upcoming pair programming that is on the horizon, communicating code should hopefully improve with time and practice.</p><p>Overall, the first week served as a recap of the basics and helped to solidify my understanding of some fundamental concepts.</p><h3>Leap through time</h3><ul><li>Week 1 👀</li><li>Week 2: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-2-3029a6069794">Node.js, NPM, Test Driven Development, Pair Programming &amp; Closure</a></li><li>Week 3: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-3-371cb632a2ab">Recursion, Object Oriented Programming, Data Structures — Stacks &amp; Queues</a></li><li>Week 4: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-4-d24dffee842e">Review day, Asynchronous Callbacks, Internet &amp; Promises</a></li><li>Week 5: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-5-7a22de2a0ce3">HTTP, Express, Model-View-Controller (MVC) Pattern &amp; SQL</a></li><li>Week 6: <a href="https://medium.com/@rhalde/my-13-week-journey-through-a-coding-bootcamp-week-6-278b283aecfc">Node Postgres, Supertest &amp; Error Handling with Express</a></li><li>Week 7: <a href="https://medium.com/@rhalde/coding-bootcamp-week-7-backend-project-async-await-cicd-26ec33bf2507">Backend Project, Async Await &amp; CICD</a></li><li>Week 8: <a href="https://medium.com/@rhalde/coding-bootcamp-week-8-dom-react-components-state-hooks-f15d710d7a25">DOM, React- Components, State &amp; Hooks</a></li><li>Week 9: <a href="https://medium.com/@rhalde/coding-bootcamp-week-9-api-calls-react-router-context-optimistic-rendering-f5b4609900e6">API Calls, React — Router, Context &amp; Optimistic Rendering</a></li><li>Week 10: <a href="https://medium.com/@rhalde/coding-bootcamp-week-10-frontend-project-error-handling-custom-hooks-class-based-components-46f81fe0ff56">Frontend Project, Error Handling, Custom Hooks &amp; Class-Based Components</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=744fb3f53139" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>