<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ghameerah McCullers</title>
    <description>The latest articles on Forem by Ghameerah McCullers (@ameerrah9).</description>
    <link>https://forem.com/ameerrah9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F379661%2Fbf4e9c5f-d1f6-4b92-aa7b-4eb449b67ab4.jpeg</url>
      <title>Forem: Ghameerah McCullers</title>
      <link>https://forem.com/ameerrah9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ameerrah9"/>
    <language>en</language>
    <item>
      <title>The Most Effective Tutorial on Tests You Will Ever Read</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sun, 22 Jan 2023 22:23:18 +0000</pubDate>
      <link>https://forem.com/ameerrah9/the-most-effective-tutorial-on-tests-you-will-ever-read-5f2d</link>
      <guid>https://forem.com/ameerrah9/the-most-effective-tutorial-on-tests-you-will-ever-read-5f2d</guid>
      <description>&lt;h2&gt;
  
  
  A Testing Guide For Node.js, Express.js, and Mongoose Apps with Jest and SuperTest
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pPa2lf9a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4t2p1i53btq8hri9offi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pPa2lf9a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4t2p1i53btq8hri9offi.png" alt="Photo by CDC on Unsplash" width="880" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The benefits of testing isn’t obvious at first.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Testing is responsible for verifying the correctness of our code. When writing any software, it is important to have confidence in the quality of your code. Tests can help you confirm that your code is working as expected.&lt;/p&gt;

&lt;p&gt;In this article, you’ll learn how writing tests will make your coding life easier. I’ll provide a good overview of what testing is, and show you how to write tests for your Node.js/Express.js and MongoDB/Mongoose applications with testing libraries Jest and Supertest.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s get started
&lt;/h3&gt;

&lt;p&gt;Ever wondered how you could test your API without using &lt;a href="https://www.postman.com/"&gt;Postman&lt;/a&gt; or &lt;a href="https://www.thunderclient.com/"&gt;ThunderClient&lt;/a&gt;? While these tools are helpful, if you’re like me and work in the backend a lot, working with these tools can get time-consuming and tedious. Instead of manually making calls to your API, testing the backend can be automated with unit testing. There are many other benefits to testing but here are a few:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps you keep your codebase in good shape.&lt;/li&gt;
&lt;li&gt;Improves development efficiency.&lt;/li&gt;
&lt;li&gt;Expands how you think about your code.&lt;/li&gt;
&lt;li&gt;Strengthens the reliability of your code.&lt;/li&gt;
&lt;li&gt;Quicker debugging.&lt;/li&gt;
&lt;li&gt;Helps you ensure your application is bug-free.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Testing can even make your development faster. You pay a fee upfront by investing time in creating the test case, but once their complete, you can rerun it at little to no cost. The investment can pay dividends even during the initial development.&lt;/p&gt;

&lt;p&gt;Reading tests written by another developer can help you understand their code much faster and can be a guide for how to refactor. Not only is testing useful for the codebase it also provides a benefit to team workflow. Understanding how the code will be tested informs developers on how code should best be composed and modularized.&lt;/p&gt;

&lt;p&gt;When writing any software, it is essential to have confidence in the quality of the code. Tests can help you verify that your code is working as expected. Although testing is not required to build healthy apps, it is generally a good development practice to have &lt;em&gt;unit tests&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o1cm3BCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ep1cs3i4ym1eqyn7rmr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o1cm3BCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ep1cs3i4ym1eqyn7rmr0.png" alt="Dev Dependencies" width="508" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Unit testing principles
&lt;/h3&gt;

&lt;p&gt;There are many different ways software can be tested. Unit testing is just one of many ways to classify testing.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://en.wikipedia.org/wiki/Single-responsibility_principle"&gt;single-responsibility principle&lt;/a&gt; plays a significant role in developing tests. In JavaScript, if you have a particular function that is supposed to take some arguments, process them, then fire a callback, you might write something known as &lt;em&gt;unit tests&lt;/em&gt; that target that specific function as opposed to testing the entire class. Each unit test should only be checking the completion of a single act or responsibility. Unit tests are responsible for verifying the correctness of your code in isolated chunks.&lt;/p&gt;

&lt;p&gt;A unit test is a way of testing the smallest piece of code (unit or component). A unit might be an individual function, method, procedure, module, or object. This will drive the code to be written in a way that adheres to the same principle. Unit tests are typically run as you code. When using tests to guide your development work, you can use failing test messages to determine how to move forward and make the test pass.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools for Testing
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ru5UrhtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxxwagam4sgsei4xlu2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ru5UrhtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxxwagam4sgsei4xlu2v.png" alt="Hunter Haley Photo" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript land, there are &lt;em&gt;many&lt;/em&gt; testing frameworks out there. To name a few:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mocha&lt;/li&gt;
&lt;li&gt;Jest&lt;/li&gt;
&lt;li&gt;Jasmine&lt;/li&gt;
&lt;li&gt;Protractor&lt;/li&gt;
&lt;li&gt;Karma&lt;/li&gt;
&lt;li&gt;Selenium&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, we’re only focusing on one in particular: &lt;strong&gt;Jest&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt; is a popular JavaScript testing framework whose strength is its compatibility with many project-types and its lightweight setup.&lt;/p&gt;

&lt;p&gt;Jest comes with many built-in features that are key ingredients needed for testing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An assertion library — an API of functions for validating a program’s functionality&lt;/li&gt;
&lt;li&gt;A test runner — a tool that executes tests and provides outputted test summaries&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This article will also make use of a framework known as Supertest.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  What is Supertest?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/visionmedia/supertest"&gt;Supertest&lt;/a&gt; is a library that simulates HTTP requests. I’ll be covering how to add testing to a backend Node.js/Express.js app later in this article. Very shortly, you will see how Supertest can be used alongside Jest. Supertest will be implemented to test some Express routes/controllers.&lt;/p&gt;

&lt;p&gt;Now you’re ready to start testing your app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oYV1iXP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkvrzjd45t0dgss03se4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oYV1iXP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkvrzjd45t0dgss03se4.png" alt="Start line" width="880" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Building your First Test
&lt;/h3&gt;

&lt;p&gt;I’ve already set up a demo Express.js app but this tutorial can be used for your app as well.&lt;/p&gt;

&lt;p&gt;This is an example folder hierarchy:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8oazL5cQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f27nelz1gy5z0dwavd6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8oazL5cQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f27nelz1gy5z0dwavd6g.png" alt="VS Code File Navigator" width="273" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you’ve built a backend REST API for a social network application.&lt;/p&gt;

&lt;p&gt;This app should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get all the users&lt;/li&gt;
&lt;li&gt;Get a user by id&lt;/li&gt;
&lt;li&gt;Add user(s) to the database&lt;/li&gt;
&lt;li&gt;Delete user(s) from the database&lt;/li&gt;
&lt;li&gt;Update user information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to begin adding tests to your project, you need a few things.&lt;/p&gt;

&lt;h3&gt;
  
  
  First, you need some packages installed
&lt;/h3&gt;

&lt;p&gt;You will need to install: &lt;code&gt;jest&lt;/code&gt;, &lt;code&gt;supertest&lt;/code&gt;, and &lt;code&gt;cross-env&lt;/code&gt;. Use the code sample below to install them as your project's &lt;code&gt;devDependencies&lt;/code&gt;together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i jest supertest cross-env --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’re using &lt;code&gt;cross-env&lt;/code&gt; because it allows you to run scripts that set and use environment variables across platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next, you need to add some test scripts to &lt;code&gt;package.json&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;You will need to utilize &lt;code&gt;cross-env&lt;/code&gt; to  set environment variables, &lt;code&gt;jest&lt;/code&gt; to execute test suites, and have &lt;code&gt;testTimeout&lt;/code&gt; set to &lt;code&gt;5000&lt;/code&gt; because certain requests might take a while to finish.&lt;/p&gt;

&lt;p&gt;Open up the &lt;code&gt;package.json&lt;/code&gt; and under the &lt;code&gt;"scripts"&lt;/code&gt; key add the following test scripts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "test": "cross-env NODE_ENV=test jest --testTimeout=5000",
    "start": "node server.js",
    "dev": "nodemon server.js"
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you write your tests, you can run the tests in the terminal with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Next, you need to create a test folder
&lt;/h3&gt;

&lt;p&gt;Jest searches for the folder &lt;code&gt;tests&lt;/code&gt; at the project's root when you run &lt;code&gt;npm run test&lt;/code&gt;. Let’s create a new file with the same name as the file that you’ll be testing, but add &lt;code&gt;.test.js&lt;/code&gt; . Every test file using Jest will need to have &lt;code&gt;.test.js&lt;/code&gt; at the end of the name in order for it to be detected as a test case and you must place your test files in the &lt;code&gt;tests&lt;/code&gt; folder. Within that directory create a file called &lt;code&gt;user.test.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Below is an example file structure:&lt;/p&gt;

&lt;p&gt;├── config&lt;/p&gt;

&lt;p&gt;├── controllers&lt;/p&gt;

&lt;p&gt;│ └── user.controller.js&lt;/p&gt;

&lt;p&gt;├── models&lt;/p&gt;

&lt;p&gt;│ └── user.model.js&lt;/p&gt;

&lt;p&gt;├── node_modules&lt;/p&gt;

&lt;p&gt;├── routes&lt;/p&gt;

&lt;p&gt;│ └── user.route.js&lt;/p&gt;

&lt;p&gt;├── tests&lt;/p&gt;

&lt;p&gt;│ └── user.test.js&lt;/p&gt;

&lt;p&gt;├── utils&lt;/p&gt;

&lt;p&gt;├── package-lock.json&lt;/p&gt;

&lt;p&gt;├── package.json&lt;/p&gt;

&lt;p&gt;├── .env&lt;/p&gt;

&lt;p&gt;└── server.js&lt;/p&gt;

&lt;h3&gt;
  
  
  Next, you need to import &lt;code&gt;supertest&lt;/code&gt; and &lt;code&gt;mongoose in your&lt;/code&gt; test file.
&lt;/h3&gt;

&lt;p&gt;MongoDB/Mongoose is the database of choice for this tutorial. You’ll need it to create your unit test. In &lt;code&gt;user.test.js&lt;/code&gt; add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require("mongoose");
const request = require("supertest");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Next, you need to import &lt;code&gt;dotenv&lt;/code&gt; to load environment variables
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;user.test.js&lt;/code&gt; add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require("mongoose");
const request = require("supertest");

require("dotenv").config();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Let’s import &lt;code&gt;server.js&lt;/code&gt; because this is the location where your application starts.
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;user.test.js&lt;/code&gt; add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require("mongoose");
const request = require("supertest");
const server = require("../server");

require("dotenv").config();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Next, you’ll need to connect and disconnect the database before and after each test (because you won’t need the database once testing is complete).
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;user.test.js&lt;/code&gt; add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;beforeEach(async () =&amp;gt; {
    /* Runs before each test */
    await mongoose.connect(process.env.MONGO_URL, {
        useNewUrlParser: true,
        useUnifiedTopology: true,
    });
  });

  /* Closing database connection after each test. */
  afterEach(async () =&amp;gt; {
        /* Runs after each test */
    await mongoose.connection.close();
    await server.close();
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is a simple test for the &lt;code&gt;/user&lt;/code&gt; endpoint to verify that the &lt;strong&gt;get&lt;/strong&gt; request does what’s expected. The &lt;code&gt;describe&lt;/code&gt; keyword is used to describe the unit test which you will find to be useful to identify tests in test results. The &lt;code&gt;it&lt;/code&gt; keyword is used to write the actual test code. This is where you specify what needs to be performed, in the first argument, and then in the second argument, write a callback function that contains the “arrange, act, and assert” test structure. "Arrange, Act, Assert" is a useful pattern for reading and structuring tests. In the callback function, the request is sent to the endpoint first (arrange and act), and the expected and actual responses are then compared (assertion).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("GET /api/user", () =&amp;gt; {
    it("should return all users", async () =&amp;gt; {
      const res = await request(server).get("/user");
      expect(res.statusCode).toBe(200);
      expect(res.body.length).toBeGreaterThan(0);
    });
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Give it a try, write tests for all your endpoints&lt;/p&gt;

&lt;p&gt;Below is another simple test for our &lt;code&gt;/user&lt;/code&gt; endpoint to verify that our &lt;strong&gt;post&lt;/strong&gt; request does what’s expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("POST /api/user", () =&amp;gt; {
    it("should create a user", async () =&amp;gt; {
    const res = await request(server).post("/user").send({
        userName: "pear",
        firstName: "frank",
        lastName: "sonata",
        password: "password",
        email: "franky@mail.com"
    });
    expect(res.statusCode).toBe(201);
    expect(res.body.userName).toBe("pear");
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Finally, you can run tests
&lt;/h3&gt;

&lt;p&gt;In the command line, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h3&gt;
  
  
  Other Testing Tooling
&lt;/h3&gt;

&lt;p&gt;You can install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest"&gt;Jest Extension for VS Code&lt;/a&gt; to see the tests using the Beaker icon in the editor. After installing the extension type &lt;code&gt;command-shift-p&lt;/code&gt; and select &lt;code&gt;Jest start all runners&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hTqxfMxi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ir1i30oe0j6negmojnp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hTqxfMxi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ir1i30oe0j6negmojnp8.png" alt="Vs Code Tests" width="672" height="792"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! You did it! 😄&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Y2AkkC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyfmgwzgclkkcx6vgvg8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Y2AkkC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyfmgwzgclkkcx6vgvg8.png" alt="Excitement" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you know everything you need to know to create new tests for your Express/Mongoose applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Testing your codebase is a very important stage of the Software Development Life Cycle (SDLC) because it strengthens the integrity and quality of the code. The intention of testing is to identify and find solutions for bugs and errors in the product before being shipped off.&lt;/p&gt;

&lt;h3&gt;
  
  
  Citation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.codecademy.com/learn/learn-react-testing/modules/jest/cheatsheet"&gt;Learn React Testing: Jest Cheatsheet | Codecademy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://saucelabs.com/resources/articles/test-automation-tutorial"&gt;https://saucelabs.com/resources/articles/test-automation-tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions, feel free to message me on &lt;a href="https://twitter.com/rakesh_at_tweet"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>node</category>
      <category>mongodb</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Creating a Book Class 📚</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Thu, 05 May 2022 17:32:03 +0000</pubDate>
      <link>https://forem.com/ameerrah9/creating-a-book-class-25m9</link>
      <guid>https://forem.com/ameerrah9/creating-a-book-class-25m9</guid>
      <description>&lt;p&gt;One thing that attracts me to programming is the ability to represent real-life objects in code. In this article, you'll learn how to create a Book class using Python. Let's learn about the core functionality of Python objects and classes by creating a fun Book class! 🐍🖥&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopvdg1ardz1zr74bkha5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopvdg1ardz1zr74bkha5.png" alt="Python Class"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Python exercise 1 😄
&lt;/h2&gt;

&lt;p&gt;Mission&lt;br&gt;
Fact: Libraries have a lot of books.&lt;/p&gt;

&lt;p&gt;If we want to make a program that tracks all the books in a library, we can make the process much more efficient by making a class for a book, much like a &lt;em&gt;template&lt;/em&gt;. That way we can more easily make and &lt;strong&gt;keep track&lt;/strong&gt; of all the different books.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attributes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Every book should have:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;title&lt;br&gt;
author&lt;br&gt;
description&lt;br&gt;
publication date&lt;br&gt;
isbn&lt;br&gt;
number of copies available to check-out&lt;br&gt;
list of names of people who currently have this book checked-out&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a Book? (&lt;em&gt;&lt;strong&gt;to Python&lt;/strong&gt;&lt;/em&gt;) 🧑🏾‍💻
&lt;/h2&gt;

&lt;p&gt;How do we communicate to Python to tell it what a book is?&lt;br&gt;
Think of &lt;strong&gt;attributes&lt;/strong&gt; as the &lt;em&gt;adjectives&lt;/em&gt; and nouns associated with a book?&lt;/p&gt;

&lt;p&gt;Examples of a book may include...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Title: "The Power of Now",&lt;/li&gt;
&lt;li&gt;Author: "Eckhart Tolle",&lt;/li&gt;
&lt;li&gt;Description: "The Power of Now: A Guide to Spiritual Enlightenment",&lt;/li&gt;
&lt;li&gt;ISBN: "9781682300688",&lt;/li&gt;
&lt;li&gt;Published Date: "1997",&lt;/li&gt;
&lt;li&gt;Copies Available: 8,&lt;/li&gt;
&lt;li&gt;Who currently has one checked out: "Ajh"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start by adding these simple attributes to our Book class. We'll create the &lt;em&gt;&lt;strong&gt;class Book&lt;/strong&gt;&lt;/em&gt; and create an &lt;strong&gt;__&lt;strong&gt;&lt;em&gt;init&lt;/em&gt;&lt;/strong&gt;__&lt;/strong&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  __&lt;strong&gt;&lt;em&gt;init&lt;/em&gt;&lt;/strong&gt;__ 🪄
&lt;/h2&gt;

&lt;p&gt;Quick derail because I can't stress the importance of this method we call the &lt;em&gt;constructor&lt;/em&gt;. &lt;em&gt;&lt;strong&gt;A constructor&lt;/strong&gt;&lt;/em&gt; defines what our Books will be when they are first introduced to the world, the program and Python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mu57vu5crgxmj3zx9ad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mu57vu5crgxmj3zx9ad.png" alt="Book constructor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;self&lt;/strong&gt; will refer to a specific book that we create. &lt;strong&gt;self.title&lt;/strong&gt; refers to that specific book's title. &lt;/p&gt;

&lt;p&gt;We can create a new book by calling our constructor. We call and the constructor picks up, we ask "May I create one new book using these attributes." The constructor then grants the request and creates a new Book.&lt;/p&gt;

&lt;p&gt;Notice that when we create a new book, we say it like this&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fueouycjdmvk3t39b9w4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fueouycjdmvk3t39b9w4p.png" alt="New Book created in Python class"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In this example we call &lt;strong&gt;Book(...)&lt;/strong&gt;, NOT &lt;strong&gt;__&lt;strong&gt;&lt;em&gt;init&lt;/em&gt;&lt;/strong&gt;__&lt;/strong&gt;.&lt;br&gt;
We can also add a second book to our collection by updating our code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon9xmr8kvyry155i2czy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fon9xmr8kvyry155i2czy.png" alt="Another created Book"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I Got A Instance 🍪
&lt;/h2&gt;

&lt;p&gt;So far we've created two &lt;strong&gt;instances&lt;/strong&gt; of our Book class. An instance is a single occurrence of an object. In our above examples we had two instances of a Book but their attributes are specific to each of the respective Books.&lt;/p&gt;

&lt;h2&gt;
  
  
  Methods: What A Library Book Can Do 🥳
&lt;/h2&gt;

&lt;p&gt;Functional Requirements&lt;/p&gt;

&lt;p&gt;Usually methods will be related to at least one of your attributes.&lt;/p&gt;

&lt;p&gt;For every Book, we should be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;checkout&lt;/code&gt; one book to a single person: This feature should update the number of copies available to check-out, and the list of names of people who currently have this book checked-out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;checkin&lt;/code&gt; one book from a single person: This feature should update the number of copies available to check-out, and the list of names of people who currently have this book checked-out&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;add more copies of this book: This feature should update the copies available&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;remove more copies of this book: This feature should update the copies available&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These actions might change some of the attributes we already gave our Book or necessitate that we add new attributes. Let's first update our Book class to be able to be &lt;strong&gt;checked out&lt;/strong&gt;. We'll create a &lt;code&gt;checkout&lt;/code&gt; method inside of our class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jahg637xg0x0xbsg853.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jahg637xg0x0xbsg853.png" alt="Checkout method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The self parameter refers to the &lt;strong&gt;specific book&lt;/strong&gt; we're attaching this method to. The name parameter refers to the &lt;strong&gt;specific name&lt;/strong&gt; of the person checking the book out. In this method we add the name to the &lt;code&gt;checked_out_by&lt;/code&gt; list by appending it and then we decrease the &lt;code&gt;copies_available&lt;/code&gt; by &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not too fast 🚦
&lt;/h2&gt;

&lt;p&gt;To complete this task we will be using object oriented design, though it is interchangeable with object oriented programming. &lt;br&gt;
What is OOP? Object-oriented programming is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior. Think of OOP as creating a cookie-cutter template for your created data sets. OOP allows you to create new data types in your code that otherwise wouldn't be available to you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Back to Business 😄
&lt;/h2&gt;

&lt;p&gt;Let's add the functionality of checking in a book to our class. This going to be the opposite action of our &lt;code&gt;checkout&lt;/code&gt; action, instead we'll be building the &lt;code&gt;check_in&lt;/code&gt; action.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsi58u19fmt80qvv493zy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsi58u19fmt80qvv493zy.png" alt="Check in"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice in this method we remove the name from the &lt;code&gt;checked_out_by&lt;/code&gt; list by calling &lt;code&gt;.remove()&lt;/code&gt; and passing in the &lt;code&gt;name&lt;/code&gt; and then we increase the &lt;code&gt;copies_available&lt;/code&gt; by &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, we'll need to add a method that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adds more copies to the shelf&lt;/li&gt;
&lt;li&gt;Removes copies from the shelf&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f28qcly26vrpjx45y2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f28qcly26vrpjx45y2e.png" alt="two more actions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we have &lt;code&gt;copies_available&lt;/code&gt; as a number we can easily manipulate it's value. &lt;/p&gt;

&lt;h2&gt;
  
  
  See it in Action! 🎬 Here are some examples of the actions we can now do our book:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksg9dgrxob9w800bgrki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksg9dgrxob9w800bgrki.png" alt="title"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will output "The Power of Now" in terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F958od0ji1pezm5hcgvxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F958od0ji1pezm5hcgvxf.png" alt="kyrie"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will output "Ajh" and "Kyrie" to the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fba84tougnusuu881m1lb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fba84tougnusuu881m1lb.png" alt="copies left"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will output "7" to the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7walja8i9z7c7uu50df0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7walja8i9z7c7uu50df0.png" alt="mindful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will output "10" to the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3y9bh9mxgsovjgzrknu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3y9bh9mxgsovjgzrknu.png" alt="mindful"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will output "Ajh", "Malcolm" and "Mansa Mua" to the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Our final Book Class&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1wnazlnlko7scc5ri8vb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1wnazlnlko7scc5ri8vb.png" alt="final"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What are some other actions or attributes we can add to a book? Comment below if you think of a cool related attribute. 😄&lt;/p&gt;

</description>
      <category>python</category>
      <category>objectorientedprogramming</category>
      <category>code</category>
      <category>oop</category>
    </item>
    <item>
      <title>What is TypeScript?</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Fri, 07 Jan 2022 17:29:29 +0000</pubDate>
      <link>https://forem.com/ameerrah9/what-is-typescript-1ol8</link>
      <guid>https://forem.com/ameerrah9/what-is-typescript-1ol8</guid>
      <description>&lt;h3&gt;
  
  
  An introduction to the strongly-typed language TypeScript and why you might want to learn it.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;TypeScript: A JavaScript superset&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;When it comes to programming tools, Javascript is a beast of a language with a vast array of viciously competing libraries and frameworks. If you're like me and find yourself getting frustrated reading documentation and annoyed with all the changes the API makes in a blink of an eye, then you are not alone.&lt;/p&gt;

&lt;p&gt;TypeScript was introduced as a JavaScript superset and was created released by Microsoft in 2012. TypeScript is JavaScript with syntax for types. What are types? Types give you the authority to describe your data. Types allow you to describe the shape of objects and functions in your code. Type checkers are type police built into JavaScript to enforce the type laws (for example, it's against the rules to multiply a string with an array). Type checking is the process where type checkers verify that your code follows all of the rules of the language.&lt;/p&gt;

&lt;p&gt;JavaScript is a dynamically typed language, meaning, a variable declared as a number can be turned into a string. Comparatively, TypeScipt is a statically typed language, meaning you declare beforehand what type of value the variable will hold and it doesn't change. Think of TypeScript as your code's enforcer on rules. TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor.&lt;/p&gt;

&lt;p&gt;The beauty of TypeScript is that it makes it possible to see documentation and issues directly in your editor, no more waiting until runtime to know something in your code broke. TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. As your codebase continues to grow, so does your enforcement of rules.&lt;/p&gt;

&lt;p&gt;In dynamically-typed languages like JavaScript, type checking occurs during runtime. TypeScript is so sweet that it will help developers identify errors before runtime. The browser can't actually execute typescript, so your &lt;code&gt;.ts&lt;/code&gt; file or &lt;code&gt;.tsx&lt;/code&gt; file is compiled to Javascript at runtime. TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js or Deno, and in your apps. Statically-typed languages like TypeScript check types during compile time - right in your text editor!&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Type Definitions:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let id: number = 5
let company: string = 'Ghameerah'
let isPublished: boolean = true
let x: any = 'Hello'
let ids: number[] = [1,2,4,7,8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary of Benefits of TypeScript:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Similar to static languages such as Java or C#&lt;/li&gt;
&lt;li&gt;Extra error checking&lt;/li&gt;
&lt;li&gt;Runtime errors caught early during development&lt;/li&gt;
&lt;li&gt;Avoid unwanted behavior at runtime&lt;/li&gt;
&lt;li&gt;Mitigation Strategies&lt;/li&gt;
&lt;li&gt;TypeScripts helps developers write better code&lt;/li&gt;
&lt;li&gt;Make sure type conversion doesn't happen&lt;/li&gt;
&lt;li&gt;Add static types&lt;/li&gt;
&lt;li&gt;Explicitly naming types in your code&lt;/li&gt;
&lt;li&gt;Explicitly assign types to variables&lt;/li&gt;
&lt;li&gt;Helps with predictability&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Other Resources
&lt;/h3&gt;

&lt;p&gt;React TypeScript Cheatsheet&lt;br&gt;
&lt;a href="https://react-typescript-cheatsheet.netlify.app/"&gt;https://react-typescript-cheatsheet.netlify.app/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>Getting started with create-react-app for Beginners</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sun, 14 Mar 2021 16:21:46 +0000</pubDate>
      <link>https://forem.com/ameerrah9/getting-started-with-create-react-app-for-beginners-3fli</link>
      <guid>https://forem.com/ameerrah9/getting-started-with-create-react-app-for-beginners-3fli</guid>
      <description>&lt;p&gt;Hello there, my name is Ghameerah McCullers &amp;amp; I'm Software Developer here to talk with you today about what it's like starting your first React application.&lt;/p&gt;

&lt;p&gt;For starters, you should check out the official documentation on React's website (&lt;a href="https://reactjs.org/docs/getting-started.html"&gt;https://reactjs.org/docs/getting-started.html&lt;/a&gt;). This site has a really great guide on how getting started with React works.&lt;/p&gt;

&lt;p&gt;Also, to get your feet wet, you should play around with the Tic Tac Toe tutorial providing by the official React website (&lt;a href="https://reactjs.org/tutorial/tutorial.html"&gt;https://reactjs.org/tutorial/tutorial.html&lt;/a&gt;). Building this mini-project should give you hands-on experience with the tool.&lt;/p&gt;

&lt;p&gt;I would also suggest reading the Thinking in React blog post (&lt;a href="https://reactjs.org/docs/thinking-in-react.html"&gt;https://reactjs.org/docs/thinking-in-react.html&lt;/a&gt;) in order to get more familiar with the concepts of React.&lt;/p&gt;

&lt;p&gt;In order to play around with the tool, you'll need to create your first application. This can be accomplished by simply running this command in your single-application project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app &amp;lt;cool-app-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice, you can name your application WHATEVER you like, it's your prerogative. Just be mindful about your naming, you'll want your project name to be related to the purpose of your app.&lt;/p&gt;

&lt;p&gt;As a good developer, we want to make sure we have the most up-to-date tools. Set up your development environment so that you can use the latest JavaScript features and optimize your application. You'll need to have Node &amp;gt;= 10.16 and npm &amp;gt;= 5.6 on your machine. NPM &amp;amp; Nodejs (Node) can be downloaded on your machine using the following website for reference: &lt;a href="https://www.npmjs.com/get-npm"&gt;https://www.npmjs.com/get-npm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have created your project, move into the folder to see the application run on your local machine. In your terminal type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd &amp;lt;cool-app-name&amp;gt;
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope the article was helpful for React beginners, if you have any questions reach out to me via LinkedIn or Twitter. Happy Coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>ui</category>
      <category>design</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Simple Array Sum –[HackerRank Coding Challenge]</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sun, 31 Jan 2021 23:35:57 +0000</pubDate>
      <link>https://forem.com/ameerrah9/simple-array-sum-hackerrank-coding-challenge-20ho</link>
      <guid>https://forem.com/ameerrah9/simple-array-sum-hackerrank-coding-challenge-20ho</guid>
      <description>&lt;p&gt;Warning, it is assumed that if you are reading this you understand JavaScript ES6 concepts.&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem
&lt;/h1&gt;

&lt;p&gt;Given an array of integers, find the sum of its elements.&lt;/p&gt;

&lt;p&gt;For example, if the array [1,2,3], 1 + 2 + 3 = 6 , so return 6.&lt;/p&gt;

&lt;p&gt;Function Description&lt;/p&gt;

&lt;p&gt;Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer.&lt;/p&gt;

&lt;p&gt;simpleArraySum has the following parameter(s):&lt;/p&gt;

&lt;p&gt;ar: an array of integers&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const simpleArraySum = arr =&amp;gt; arr.reduce((acc,curr) =&amp;gt; acc + curr, 0) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read more on the reduce() JavaScript ES6 array method here =&amp;gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;P.s. here's another really cool resource I like for learning more about JavaScript and reduce() =&amp;gt; &lt;a href="https://www.youtube.com/watch?v=-LFjnY1PEDA&amp;amp;t=401s&amp;amp;ab_channel=TheCodingTrain"&gt;https://www.youtube.com/watch?v=-LFjnY1PEDA&amp;amp;t=401s&amp;amp;ab_channel=TheCodingTrain&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a JavaScript frontend and Rails API backend Project for Beginners</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sat, 02 Jan 2021 05:13:07 +0000</pubDate>
      <link>https://forem.com/ameerrah9/building-a-javascript-frontend-and-rails-api-backend-project-for-beginners-2mm7</link>
      <guid>https://forem.com/ameerrah9/building-a-javascript-frontend-and-rails-api-backend-project-for-beginners-2mm7</guid>
      <description>&lt;p&gt;Fresh Find application is a web application using JavaScript to render frontend data and Rails API to manage backend data.&lt;/p&gt;

&lt;p&gt;Farmers, use the Fresh Find application to keep track of your inventory when your next Farmer's Market rolls around!&lt;br&gt;
Create a "Produce List" using your choice of name, then simply add items to your list.&lt;/p&gt;

&lt;p&gt;For Flatiron School's Software Engineering course project 4, I decided to have two separate repositories for my frontend along with my backend. This avoids issues of hosting on a deployment site such as Heroku. This also allows me to run both my backend and frontend at the same time, with the Rails server running on localhost:3000 and the front-end Javascript and HTML/CSS running on the browser. This allowed for faster error handling because of the use of the Console in the browser and being able to go into the Rails console at any moment. When I was setting up my Rails API, I had to make use of the - api Flag like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails new fresh-find-backend - api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This - api flag ensures that I create an API only application using Ruby on Rails.&lt;/p&gt;

&lt;p&gt;This project uses AJAX and JavaScript to make fetch requests to a Rails backend to access a database containing information about Farmer's Market items. I used JavaScript to make changes to the DOM. Javascript is powerful and capable of so much. This JavaScript Project requires that the app use a Javascript frontend with a Rails API backend. Client/server interaction must be handled asynchronously in JSON format. The Rails backend needs to have a resource with a has-many relationship and have at least 3 AJAX calls (at least two of Create, Read, Update, and Delete). This was by far the toughest part of the course, combining both JavaScript and Rails.&lt;/p&gt;

&lt;p&gt;My JS + Rails API project is a Farmer's Market vendor's dream. My app allows vendors to keep track of their inventory by creating lists for their items they'll be selling at their upcoming Farmer's Market visit. The object model relationship is a list has many items.&lt;/p&gt;

&lt;h1&gt;
  
  
  Three Pillars of Web Programming
&lt;/h1&gt;

&lt;p&gt;Recognizing JS events, Manipulating the DOM, and Communicate with the server. All of these pillars were difficult for me to grasp at first but with persistence, I was able to learn these pillars.&lt;br&gt;
My application has two classes, List and Item as show below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class List { 
 static listNames = []
 
 constructor(list){
 this.id = list.id
 this.name = list.attributes.name
 this.items = list.attributes.items
 List.listNames.push(this)
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Item {
 constructor(item) {
 this.id = item.id
 this.list_id = item.list_id
 this.content = item.content
 this.li = document.createElement('li')
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Making sure back end is connected to front end
&lt;/h1&gt;

&lt;p&gt;In order to connect my frontend directory to my backend directory I needed to make use of a fetch request to my Rails API backend from my JavaScript frontend. Using the &lt;a href="http://localhost:3000/lists"&gt;http://localhost:3000/lists&lt;/a&gt; as my endpoint. I connect the front end of my application to my back end using the following GET fetch request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static getLists() {
 fetch(listsURL)
 .then(resp =&amp;gt; resp.json())
 .then(lists =&amp;gt; {
 for(let list of lists) {
 let newList = new List(list.data)
 }
 this.renderLists()
 })
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is also an example of a static method in JavaScript. With the data I receive from my back end server, I am then able to handle DOM manipulation and render this data to my HTML.&lt;/p&gt;

&lt;p&gt;My classes contain functions that strictly handle DOM manipulation. Some functions handle server communication. Some functions may serve as 'helper' functions to others. This all ties into the programming mantra of "Separation of Concerns". With Object Orientation, instead of a web, we can think of our code as a collection of cells. These cells are separated from each other, can contain information, bits of data like variables, as well as behaviors, functions directly related to that data. &lt;/p&gt;

&lt;h1&gt;
  
  
  Static Methods - OOJS
&lt;/h1&gt;

&lt;p&gt;Static methods are class-level methods - they are not callable on instances of a class, only the class itself. These are often used in 'utility' classes - classes that encapsulate a set of related methods but don't need to be made into instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;StaticMethod&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;methodName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My method is static!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope you learned something about JavaScript and Rails reading this piece on the fourth software engineering project for Flatiron School. This was by far the toughest part of the course, combining both JavaScript and Rails. I learned a lot about utilizing classes in JavaScript and handling JSON formatting.&lt;/p&gt;

&lt;p&gt;Source Code &lt;a href="https://github.com/ameerrah9/Fresh-Find-Frontend"&gt;https://github.com/ameerrah9/Fresh-Find-Frontend&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>rails</category>
      <category>react</category>
      <category>api</category>
    </item>
    <item>
      <title>Getting Started with Rails as an API</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sun, 22 Nov 2020 22:32:11 +0000</pubDate>
      <link>https://forem.com/ameerrah9/getting-started-with-rails-as-an-api-17pg</link>
      <guid>https://forem.com/ameerrah9/getting-started-with-rails-as-an-api-17pg</guid>
      <description>&lt;p&gt;An API is known in the programming world as an Application Program Interface. What does this mean you ask? Well from my understand an API is used to grab data from a particular source, usually a database.&lt;/p&gt;

&lt;p&gt;You may ask, what is a database? From my understanding, a database is used to store and retrieve information, and when I get really good at communicating with these suckers, I'll become a better engineer.&lt;/p&gt;

&lt;p&gt;An API can be created by anyone, that's the really cool part. The way to get started will be explained in this blog post. Now the first thing I will tell you is, APIs enable programmers like me, to access and display on a web page.&lt;/p&gt;

&lt;p&gt;APIs can become the grit of your application because of the freedom and the ability to grab any informational database and use it as a tool. APIs are great because your program is allowed to be multi-resourced. It has range, it has freedom, go create. This tool comes with flexibility by using a powerful gem called the Fast JSON API. The Fast JSON API gem provides a quick way to generate and customize JSON serializers. &lt;/p&gt;

&lt;p&gt;Woah, slow down! What are you even saying?&lt;br&gt;
Okay, I'll break it down, you're probably asking, "what is JSON?" It stands for JavaScript Object Notation. JSON (JavaScript_Object_Notation)  is a simple data format that uses sets of the familiar &lt;em&gt;key &amp;amp; value pairs&lt;/em&gt; to store information. Back to that information storing thing again. JSON is chosen because it uses javascript to pass information around. Serializers enable us to handle the logic of arranging our JSON data the way we want it.&lt;/p&gt;

&lt;p&gt;There are many gems out there, but there is a particular gem in Rials that I truly have fallen madly in love with. It was an instant connection, didn't make much for me to realize the power of this tool. It's not just me that can confirm how brilliant it is. Using this popular option, the Fast JSON API gem creates a JSON serializer for Rails APIs. It provides a way for us to generate serializer classes for each resource object in our API that is involved in customized JSON rendering.&lt;/p&gt;

&lt;p&gt;Setting up Fast JSON API&lt;br&gt;
To add the Fast JSON API gem to your Rails program, go to your project's Gemfile and copy and paste this line there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'fast_jsonapi'&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run bundle install in your terminal.&lt;/p&gt;

&lt;p&gt;Once installed, you will gain access to a new generator, serializer.&lt;/p&gt;

&lt;p&gt;Godly Gem!&lt;/p&gt;

</description>
      <category>react</category>
      <category>ruby</category>
      <category>rails</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What is Rails?</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Wed, 21 Oct 2020 14:14:03 +0000</pubDate>
      <link>https://forem.com/ameerrah9/what-is-rails-4i14</link>
      <guid>https://forem.com/ameerrah9/what-is-rails-4i14</guid>
      <description>&lt;p&gt;Ruby on Rails is a web framework that provides developers the tools they need in order to build applications. Rails is written in the Ruby programming language and it is incredibly smart because it makes assumptions about what every developer needs. Rails is a very fun framework to work with because it is just so powerful, and you can accomplish more with less code.&lt;/p&gt;

&lt;p&gt;If you ever run into any issues when building your application, Rails has comprehensive documentation for (almost) every aspect of Rails. Refer to their documentation if you ever feel really stumped. &lt;/p&gt;

&lt;p&gt;The Rails philosophy includes two major guiding principles:&lt;/p&gt;

&lt;p&gt;I've heard these concepts come up a lot during bootcamp, the first concept is D.R.Y., which is an abbreviation for "Don't Repeat Yourself". This is a huge principle of software development which states that "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." Ruby makes your life as a developer very easy because you can achieve a lot with less code and by not writing the same information over and over again, your code is more maintainable, more extensible, and there are far fewer bugs. It astonished me what you can "DRY" up in Ruby, one line of coders are a frequent occurrence in my &lt;a href="https://github.com/ameerrah9/Travelgram"&gt;Travelgram&lt;/a&gt; application.&lt;/p&gt;

&lt;p&gt;Another really important principle is "Convention Over Configuration". Rails has opinions about the best way to do many things in a web application and defaults to a simple set of conventions.&lt;/p&gt;

&lt;p&gt;Rails is an open-source software, so it free to use! Check out this video to learn more on Rails: &lt;a href="https://youtu.be/OaDhY_y8WTo"&gt;https://youtu.be/OaDhY_y8WTo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you've heard of any of these known apps, you probably wouldn't know they were all built with Rails:&lt;br&gt;
Shopify, Airbnb, Twitch, SoundCloud, and Hulu.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a Rails Application</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Wed, 21 Oct 2020 13:48:13 +0000</pubDate>
      <link>https://forem.com/ameerrah9/building-a-rails-application-5e0f</link>
      <guid>https://forem.com/ameerrah9/building-a-rails-application-5e0f</guid>
      <description>&lt;p&gt;The Travelgram App was built using the Ruby on Rails framework and no scaffolding was used to build my project. This app was created with the intention to help travelers blog about their experiences.&lt;/p&gt;

&lt;p&gt;Rails comes with scripts called generators that are designed to make your development life easier by creating everything that’s necessary for you. The generator I used was the new application generator. The new generator will provide you with the foundation of a fresh Rails application so that you don’t have to write it yourself.&lt;/p&gt;

&lt;p&gt;To use this generator, I opened up my terminal, navigated to my project directory, and typed the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rails new Travelgram
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Building a blog with comments using Ruby on Rails is a foundational exercise I went through to learn more about the framework. Ruby and Rails allowed me to generate a fairly simple MVC pattern built on top of a CRUD approach when working with dynamic data.&lt;/p&gt;

&lt;p&gt;When building a Rails app I struggled a lot with routing. Most developers struggle with understanding routes like I did. A lot of the time it was simple syntax errors and not knowing what was being passed through to my views.&lt;/p&gt;

&lt;p&gt;Understanding the routing process made it a lot easier for me to build successfully. Another key struggle was with styling and CSS. This was a personal issue for me not so much as a technical issue. I wanted my application to look a certain way so that my user could get a certain feel when interacting with my application.&lt;/p&gt;

&lt;p&gt;Luckily the developer network is very useful in that if you need help you can find a useful resource. Rails has really great documentation (&lt;a href="https://guides.rubyonrails.org/"&gt;https://guides.rubyonrails.org/&lt;/a&gt;) for developers, so it makes the process really fun when you run into an issue.&lt;/p&gt;

&lt;p&gt;Feel free to check out my application, I have linked my repository (&lt;a href="https://github.com/ameerrah9/Travelgram"&gt;https://github.com/ameerrah9/Travelgram&lt;/a&gt;)! Happy coding!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>webdev</category>
      <category>webapp</category>
    </item>
    <item>
      <title>Creating a Basic Sinatra App</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Mon, 31 Aug 2020 22:16:12 +0000</pubDate>
      <link>https://forem.com/ameerrah9/creating-a-basic-sinatra-app-2ipk</link>
      <guid>https://forem.com/ameerrah9/creating-a-basic-sinatra-app-2ipk</guid>
      <description>&lt;p&gt;First I want to admit learning and Building with Sinatra was a journey; Sinatra was a challenge but do-able. I had a bit of difficluty just understading how the SQL database works with Sinatra but I was able to figure it out and complete my project which I am so proud of. I’ve grown as a developer during this jounrey and anyone reading this will learn from me. What exactly is Sinatra? Sinatra is a Domain Specific Language used for writing web applications written in Ruby.&lt;/p&gt;

&lt;p&gt;I’m going to take you through my process of development. I started with a sketch on plain paper, because it’s important to map out the layout of yoru design prior to writing any code. I asked myself this basic question to spark my creative spirit; What do you care about? What are you passionate about? Next, I developed 2 models. I decided to use my newly learned Sinatra web application skills to build a Business Posting site. I’ll explain my two models and their concepts below.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BizPlan&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
    &lt;span class="c1"&gt;# association macro&lt;/span&gt;
    &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt;
    &lt;span class="c1"&gt;# model validations&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;length: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;minimum: &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:mission&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:mission&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;length: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;minimum: &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:budget&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:budget&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;length: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;minimum: &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I created a correspoding table for each of my model classes so they need to inherit from ActiveRecord. With this piece of code, I use macro to establish a relationship to a user. And I use bcrypt through ActiveRecord; using has_secure_password adds methods to set and authenticate against a BCrypt password.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;
    &lt;span class="n"&gt;has_secure_password&lt;/span&gt;
    &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:biz_plans&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I establish a relationship to biz_plans and also use has_secure_password to add methods to set and authenticate against a BCrypt password. When a user creates an account it must be with a unique login attribute. The job of ensuring the login is unique is left up to the controllers. Read below on how to set up your controller for authorization checks.&lt;/p&gt;

&lt;h1&gt;
  
  
  CRUD (Create, Read, Update, Delete) actions using Active Record.
&lt;/h1&gt;

&lt;p&gt;CRUD actions in the controllers connects views and erb files to certain actions in the controller. CRUD actions come with the sinatra-activerecord gem. CRUD routes are created in the controller for four unique actions; create, read, update and delete. With the Create CRUD action we can create a table using a Rake task to create migration. In the controller I create a route get ‘/biz_plans/new’, that renders the new.erb view. With the Read CRUD actions we can read or display information from our database. In the controller I create a route, the ‘biz_plan_index’ action, which should render the ERB view index.erb, which shows a list of all of the biz_plans. With the Update CRUD action we can update information in our database using a form. In the controller I create a route get ‘/biz_plans/:id/edit’, that renders the view edit.erb. With the Delete CRUD actions we can delete information from our database using a form. In the controller I create a route delete ‘/biz_plans/:id’, that creates a button and send the information to a form that will send a request to the delete controller action, where we will identify the biz_plan to delete and delete it.&lt;/p&gt;

&lt;p&gt;When creating a Sinatra application, the file structure is very important. I used the corneal gem to set up my file structure for my project. I will break down the MVC File Structure below. When I continue my build I must understand each file in our application will have a different responsibility and we’ll keep these responsibilities split up into reasonable chunks. &lt;/p&gt;

&lt;h1&gt;
  
  
  Steps
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Create file structure using corneal gem in terminal. You can use this or manual create each folder. Corneal is just an easier way to handle this job.
Run bundle install in terminal, ensure versions are up to date. - set up gems&lt;/li&gt;
&lt;li&gt;Set up Rake tasks, config folder and environment file This is a very important file, is where you get your database connection ready, and it will connect your app folder with the rest of the files that require it as well.&lt;/li&gt;
&lt;li&gt;Setting up config.ru file&lt;/li&gt;
&lt;li&gt;Create a migration - create users table and biz_plans table with input for both&lt;/li&gt;
&lt;li&gt;Create another migration&lt;/li&gt;
&lt;li&gt;Create a User class - inherit from the ActiveRecord::Base class - set up validations&lt;/li&gt;
&lt;li&gt;Create a BizPlan class&lt;/li&gt;
&lt;li&gt;Create a users_controller - sessions and Validation&lt;/li&gt;
&lt;li&gt;Create a biz_plan controller - Update, Delete, and Protecting Resources&lt;/li&gt;
&lt;li&gt;Create Restful routes - explain Restful routes - User Signup and Password Protection&lt;/li&gt;
&lt;li&gt;Set up views - Forms - error messaging
create BizPlans and users - use rake console&lt;/li&gt;
&lt;li&gt;Run shotgun and test out as you build&lt;/li&gt;
&lt;li&gt;Commit to GitHub Repo&lt;/li&gt;
&lt;li&gt;Add styling with CSS&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Model, View, Controller (MVC) File Structure
&lt;/h1&gt;

&lt;p&gt;Keeping Code Organized is so critical to the layout and flow of an application. MVC is used to help us with the organization. What is MVC? Model, View, Controller.&lt;/p&gt;

&lt;p&gt;Controller actions are where the application configurations, routes, and controller actions are implemented. Controller actions represent the application logic. The “C” in MVC acts as the interface and flow of our application. Our “V” in MVC is out Views and holds the code that will be displayed in the browser. Models of our application represent the data and object logic of our application. Typically a Model includes a class used as a unit of measurement, it is the “M” in MVC.&lt;/p&gt;

&lt;p&gt;Keeping our code organized is crucial when developing complex applications. As a developer I have learned the importance of separation of concerns and single responsibility.&lt;/p&gt;

&lt;p&gt;├── apps&lt;br&gt;
│   ├── Controllers&lt;br&gt;
│   │   └── # Your controllers &lt;br&gt;
│   ├── models&lt;br&gt;
│   │   └── # Your models&lt;br&gt;
│   └── views&lt;br&gt;
│   │   └── # Your Views&lt;br&gt;
│   ├── layout.erb # the default html template&lt;br&gt;
│&lt;br&gt;
├── config.ru # Your Rack config&lt;br&gt;
├── db&lt;br&gt;
│   ├── development.sqlite# Sqlite3 database&lt;br&gt;
│   ├── migrate&lt;br&gt;
│   │   └── # Migrations&lt;br&gt;
│   └── schema.rb&lt;br&gt;
├── config&lt;br&gt;
│   └── environment.db&lt;br&gt;
├── Gemfile&lt;br&gt;
└── Rakefile # Your Rake tasks&lt;/p&gt;

&lt;p&gt;Separation of Concerns is again super important when building web applications. The views should never directly pull from the database. All of that should be taken care of in the controller actions, and the data should be passed to an erb file through a specific controller action.&lt;/p&gt;

&lt;p&gt;Project requirements - Build a full scale Sinatra application that uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A sqlite database&lt;/li&gt;
&lt;li&gt;ActiveRecord&lt;/li&gt;
&lt;li&gt;RESTful routes&lt;/li&gt;
&lt;li&gt;Sessions&lt;/li&gt;
&lt;li&gt;Login/Logout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what I was tasked with and it can seem like a lot but once it’s completely mapped out it because easy to understand how everything needs to work together. With the knowledge and understanding of your controllers views and routes in your app, you can truly create something amazing!&lt;/p&gt;

&lt;p&gt;What is REST?&lt;br&gt;
A RESTful route is a route that maps HTTP verbs (get, post, put, delete, patch) to controller CRUD actions (create, read, update, delete). It helps us with data manipulation and by following it we are able to create new content, edit content, and delete it.&lt;/p&gt;

&lt;p&gt;HTTP verb: GET routes to ‘/biz_plans’, action: index action, used to display all biz_plan only if you’re logged in. HTTP verb: GET routes to ‘/biz_plans/new’, action: new action, used to display create biz_plan form new biz_plan. HTTP verb: GET routes to “/biz_plans/:id/edit”, action: edit action, used to display edit form based on ID in the url. HTTP verb: GET routes to ‘/biz_plans/:id’, action: show action, used to display a biz_plan based on ID. HTTP verb: POST routes to ‘/biz_plans’, action: create action, used to create a biz_plan HTTP verb: PATCH routes to ‘/biz_plans/:id’, action: update action, used to update an existing biz_plan based on ID. HTTP verb: DELETE routes to ‘/biz_plans/:id’, action: delete action, used to delete a biz_plan based on ID.&lt;/p&gt;

&lt;h1&gt;
  
  
  What are sessions and cookies?
&lt;/h1&gt;

&lt;p&gt;Sessions and cookies work in tandem to store information about a user’s interactions with a website at a given point in time. A session gives us a way to remember a user’s identity from page to page. Cookies and session data assists a web application in knowing who interacting with it. Cookies store information locally and are visible only to the server that created them. And while the web application on the server reads the client side cookie, it associates the cookie with an existing session (if such a session exists), and decides how to move forward. Pretty cool huh?&lt;/p&gt;

&lt;h1&gt;
  
  
  Why
&lt;/h1&gt;

&lt;p&gt;The goal of this project was to build a basic Sinatra application by utilizing the Sinatra framework in conjunction with ActiveRecord and SQLite 3. This Sinatra project is my very first web application – completed with a database!&lt;/p&gt;

&lt;h1&gt;
  
  
  Look Ma, I built a website!
&lt;/h1&gt;

&lt;p&gt;Hope this post was helpful. Here I’m adding a link to my Github repository (&lt;a href="https://github.com/ameerrah9/BizUs"&gt;https://github.com/ameerrah9/BizUs&lt;/a&gt;) in case you want to check out my code and/or try out my Business planning app!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Why did you decide to study Software Engineering?</title>
      <dc:creator>Ghameerah McCullers</dc:creator>
      <pubDate>Sat, 09 May 2020 17:02:56 +0000</pubDate>
      <link>https://forem.com/ameerrah9/why-did-you-decide-to-study-software-engineering-3kog</link>
      <guid>https://forem.com/ameerrah9/why-did-you-decide-to-study-software-engineering-3kog</guid>
      <description>&lt;p&gt;The reason I have to become a software developer...&lt;/p&gt;

&lt;p&gt;“You can focus on your spiritual growth more when you’re not in survival mode living paycheck to paycheck.” &lt;br&gt;
-Ayodeji Awosika&lt;/p&gt;

&lt;p&gt;I come from a low income household and not the most educated. I was the first to graduate from college in my family. My family lived on public assistance for most of my life. I found freedom in a skill which allowed me to further my education at a lower cost than most; playing basketball. Though a scholarship funded my education, I still had to take out student loans. After I earned a degree I was not able to find work in my field, a bachelor's only gets you but so far nowadays. Before this pandemic I was making a $30k salary barely enough to pay rent, eat healthy or enjoy activities out of my home. After fighting myself and beating myself up over the position I was in in life, I discovered a way to financial freedom. &lt;/p&gt;

&lt;p&gt;"Today, every company is a Software company. The Software industry is booming and demand for qualified software engineers is expected to increase by over 23% by 2028."&lt;/p&gt;

&lt;p&gt;Technology is an essential skill of the world! If you have desires to survive and thrive, learn about technology. The technology industry is trending towards engineers; the need for engineers is very high. The chance to be a part of an organization's decision making and being in those rooms where innovative change is discussed and planned is something that drives me. I’m intrigued by the influence engineers have on a product directly and the impact we can have on a business. Software Engineering is a very collaborative task and I love to immerse myself in team environments. I am very intrigued by the field because of the real world application of the projects. When I learn Software Engineering I will get the necessary preparation and knowledge needed to make a break in this industry. &lt;/p&gt;

&lt;p&gt;I have been interested in coding for as long as I can remember, more distinctly, since high school. I have always had the desire but I’ve never been given the chance to be educated formally since then. Learning Software Engineering creates a competitive advantage for myself to gain the attention of employers. Let's be completely transparent, there's $100,000 ON THE TABLE A YEAR!!! I just need to believe in my infinite capacity to learn. I intend to learn new skills for self-enrichment and financial freedom. I intend to start a new in-field job within 60 days of graduating the Flatiron program. With no formal education in this field and no Computer Science degree, it's clear I have an insane amount of self determination to be successful.&lt;/p&gt;

&lt;p&gt;The reason I have to become a software developer...&lt;/p&gt;

&lt;p&gt;I have a strong desire to learn! Not just programming but in life, I'm a lifelong learner. Yes, adding coding skills will allow me to add value to a business in exchange for gainful employment; but it's about more than money. In fact, I’m enjoying the process of learning that I would do it for free! Engineers are respected and for good reason. Software Engineering is full of twists, turns and roadblocks that can have you thinking, "Can I actually do this?" This journey will be a test of toughness and resilience. I'm constantly reaching out and networking so I can find ambitious people so that I am surrounded by motivated, hard working people! There's an abundance of reasons why I chose to learn Software Engineering, but a key reason is to challenge myself.&lt;/p&gt;

&lt;p&gt;The reason I have to become a software developer...&lt;/p&gt;

&lt;p&gt;A career in software engineering would be life changing, I would be doing something impactful, something I love and enjoy and can feel fulfilled by and it would financially allow me to have more buying power and freedom for my family and future success. I think of programming as a craft. I was an athlete in college so I truly enjoy craftsmanship. When I put my mind to something, I try to learn as much as possible about it, in hopes of enjoying them more. I love the challenge of programming. I see it as a creative mode of expression. Upon graduating this course my goals are to continuously learn more and more skills to better my craft as an engineer, my education starts with Flatiron School but it doesn't end. My goals include being employed at a company that I feel adds value to the world and aligns with my values. My goals are to earn six figures by 2021 and be able to do more for my family. My goals have always been to contribute to the human advancement through technology. Learning Software Engineering allows me to provide a valued skill to individuals and businesses that can utilize this unique skill. Once I complete Flatiron's course I will have the confidence, the skills and the experience to make an impact on a company and further produce for their bottom line. My goals are to add value to an organization using my coding skills and problem solving ability, I also have desires to create a better life for my family and other coders who come after me.&lt;/p&gt;

&lt;p&gt;So that’s it! The plentiful reasons why I chose to embark on this crazy journey of learning Software Engineering. My friends and family think I’m crazy but I know I can do this! Let’s face it, I’m a NERD. I can’t get enough of this! Keep following my journey as I give updates on my story.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
