<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Guosa</title>
    <description>The latest articles on DEV Community by Guosa (@guosae).</description>
    <link>https://dev.to/guosae</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%2F407179%2F8f63955f-985f-4417-9d08-d7024ef1e78c.jpg</url>
      <title>DEV Community: Guosa</title>
      <link>https://dev.to/guosae</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guosae"/>
    <language>en</language>
    <item>
      <title>Why Software Engineering? What's the appeal?</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Fri, 12 Nov 2021 19:35:11 +0000</pubDate>
      <link>https://dev.to/guosae/why-software-engineering-whats-the-appeal-3p5o</link>
      <guid>https://dev.to/guosae/why-software-engineering-whats-the-appeal-3p5o</guid>
      <description>&lt;p&gt;In this post I am going to reflect on the different aspects of software engineering that drew me towards choosing software development as a career path. When I think back to what first drew me to the field of software development, there are probably some things that appealed to me about it that I can no longer recall, but for the most part the five things I will discuss below stand out. These are not necessarily listed in order of their importance for why they made me choose software engineering as a career, but rather they are just in the order in which I was able to recall them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Love of Problem Solving&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cnpaco9Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neu6xgsagj788l78go0c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cnpaco9Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neu6xgsagj788l78go0c.jpg" alt="Chess Board" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since middle school and high school I have had an appreciation for the challenge and thrill involved in tackling difficult problems. In high school I was in the math club, where at the end of every week we would work through problem sets with difficult math problems and attempt to solve them, and every several weeks we would participate in local and regional math competitions. I was also an avid chess player and in my last years of high school I drifted towards choosing a science subject as my major in college. In college I eventually settled on math as my major and graduated with bachelor of science in mathematics with a minor in physics. Throughout my college years I spent most of my time working on difficult problems for homework, tests, and occasionally projects or labs. Although I did not major in computer science or get very far into programming at all during college, I did take two courses for my major that that required me to learn the basics of, and use, two programming languages: C++ and Python. This was my first exposure to using programming languages to solve problems and although I did not get involved in anything relating to software at that point, I gained an appreciation for the way programming could be used to solve real problems using logic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An Affinity for Abstract Thought&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZU7HdQvT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt61j79l9iiqqjp9z736.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZU7HdQvT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt61j79l9iiqqjp9z736.jpg" alt="mc escher" width="454" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the things I love most about programming and software development is the abstract thought involved - the use of variables and methods and classes and other components of programming languages to create software that can create general solutions to problems. By focusing on abstract, or more general, ideas and concepts when designing software, software engineers are able to create really remarkable products and services that have a lot more power and adaptability than products or services that are only focused on, and only capable of dealing with, one very specific problem or scenario. As someone who was already familiar with the power of abstraction in higher mathematics, it was easy for me to appreciate this aspect of software development and it was one of the things that I found most appealing about software development.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Ability to Create Things with Your Mind&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dc_eumL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5c9e2m3czqi61mjgu0p.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dc_eumL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5c9e2m3czqi61mjgu0p.gif" alt="alchemist" width="220" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I was younger I wanted to be either an architect, a fiction writer (novelist), or a mathematician. Each of these fields appealed to me because they allow a person to basically create new and interesting ideas and concepts with just one's mind. Although I did not end up pursuing any of those careers when I grew into adulthood, I did find that same appealing aspect of being able to create something interesting and important with just one's mind in software engineering. The ability to create almost anything one can conceive of, with essentially no limits on what sort of product or service one can bring into reality, simply with thought and hard work, is one of the most appealing things to me about software engineering. In some sense, being a software engineer is like being an alchemist working with a modern day "philosopher's stone": with some starting ideas, materials, technologies, and the necessary programming languages, people can create (or transmute) seemingly inanimate and lifeless text, images, and numbers into a working, responsive, active system capable of implementing nearly anything that the creators wish it to implement, as long as the creators have sufficient skill, knowledge and hard work to make that product or service work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Stable and Rewarding Career Path&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RFMErRjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9t5kq2bim68d4i5n3yzx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RFMErRjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9t5kq2bim68d4i5n3yzx.gif" alt="mad men discussing" width="400" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the things that appealed to me about software engineering as a career is the stability and the rewarding opportunities available as a software engineer. Many jobs are available for software engineers in many different specialties (front-end, back-end, full stack, machine learning, embedded software, etc.) so there is a lot of variety, and most of these jobs pay very well, especially as one advances further in one's position. Furthermore, many new jobs are emerging or being created in software engineering over time, as technology progresses, unlike in some other industries where jobs are being gradually eliminated as technology advances and the use of automation increases. This means that software is a more stable career field than some other jobs such as certain factory jobs. Software engineering is also rewarding mentally, in addition to being financially rewarding. The ability to feel like what one applies one's thoughts and hard work towards really matters and helps people or provides a useful or enjoyable service is also mentally rewarding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An Opportunity to be at the Cutting Edge of Technology and Innovation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nRDiR686--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jkiur3vrp322r0wmbki.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nRDiR686--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jkiur3vrp322r0wmbki.jpg" alt="robotic geisha from ghost in the shell" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a software engineer also means that one is at the forefront of innovation in technology and business if one wants to be or chooses to go that route. In today's increasingly technologically sophisticated world, software is relevant for everything from robotics to e-commerce, finance, biotechnology or space exploration. Practically no field of human endeavor where important innovations are happening, or new technologies are being created or used, is without use for software engineers. This means that software engineers have a big role to play in advancing already existing fields by applying new or existing technologies to those fields and also in creating new technologies and new innovations that will create new opportunities and new areas of human activity.&lt;/p&gt;

&lt;p&gt;These five aspects discussed above are the primary things (that I can recall) that drew me to software engineering as a career path. I hope it was an interesting read and hopefully someone out there who was considering software engineering as a career path will take something valuable away from my reflections on what drew me toward software engineering.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>An Application for Short Term Planning using a React/Redux frontend and a Rails API backend</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Fri, 12 Nov 2021 18:25:43 +0000</pubDate>
      <link>https://dev.to/guosae/an-application-for-short-term-planning-using-a-reactredux-frontend-and-a-rails-api-backend-3ji3</link>
      <guid>https://dev.to/guosae/an-application-for-short-term-planning-using-a-reactredux-frontend-and-a-rails-api-backend-3ji3</guid>
      <description>&lt;p&gt;I built a weekly planning app which utilized React and Redux for its frontend and a Rails API for its backend.&lt;/p&gt;

&lt;p&gt;I decided to make an application which could be used as a short term planner or scheduler where the main events or activities of the immediate upcoming week could be entered. I figured that this was more relevant than a long term calendar style application for most scheduling/planning that one needs to actually carry out.&lt;/p&gt;

&lt;p&gt;Although I do have long term plans outlined in document files or in notes on my phone, I usually need to make plans or schedule activities for more immediate upcoming events on a short term basis (a week or at most two weeks ahead) since plans are very frequently changed to adapt to changing circumstances or events that come up unexpectedly that need to be taken care of or resolved sooner.&lt;/p&gt;

&lt;p&gt;I thought it would make sense to make an application which could handle this issue in a more organized and simple manner and with a more minimalist approach than keeping dozens of random disorganized notes in a note application for short term planning.&lt;/p&gt;

&lt;p&gt;I decided that each event or activity needed to have a day it was assigned to, a location where it would occur, a name for the event, a description of the importance of the event (such as whether it was a low, medium, or high importance event), and a category for the event (such as whether it was about business, recreation, or was a creative activity for example).&lt;/p&gt;

&lt;p&gt;I set up the Rails API backend for the application by navigating to the directory where I wanted to create the application and entering into the terminal 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 planner --api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I set up the necessary migrations, models and controllers for the events and the categories that these activities belonged to.&lt;/p&gt;

&lt;p&gt;I ran the migrations, then defined the models and the necessary methods for the controllers. Then I seeded the database with some example events. After this I moved all the files and folders except the README.md file into a new backend folder.&lt;/p&gt;

&lt;p&gt;While in the uppermost folder, or root directory, of the application, I used the create-react-app generator to create a new React application in a new frontend folder:&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 frontend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the src folder in the frontend I created a components folder and then created presentation component files and container component files in that folder. Then I built out the presentation components and part of the container components for the application in JSX. &lt;/p&gt;

&lt;p&gt;I then imported these components to the App.js file, and modified the App.css file to add some CSS styling. Next I installed React Router by running the following code while in the frontend folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-router-dom@5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This installed version 5 of React Router. I then imported BrowserRouter and Route into the index.js file and set up three different routes in the index.js file.&lt;/p&gt;

&lt;p&gt;I then installed Redux in order to use it for state management by running the following commands in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install redux

npm install react-redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also installed Redux Thunk in order to use it for asynchronous requests in my application 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 install --save redux-thunk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From there I continued to build out and design the components of the project until it had the functionality and appearance I needed it to have for its use as a short term planner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/GuosaE/planner"&gt;A link to the repository for my project.&lt;/a&gt;  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Single Page Application for storing Recipes with a JavaScript frontend and a Rails API backend</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Fri, 12 Nov 2021 15:45:31 +0000</pubDate>
      <link>https://dev.to/guosae/a-single-page-application-for-recipes-with-a-javascript-frontend-and-a-rails-api-backend-11aa</link>
      <guid>https://dev.to/guosae/a-single-page-application-for-recipes-with-a-javascript-frontend-and-a-rails-api-backend-11aa</guid>
      <description>&lt;p&gt;I set out to build a simple &lt;a href="https://en.wikipedia.org/wiki/Single-page_application"&gt;single page application (SPA)&lt;/a&gt; which utilized a JavaScript frontend and a Rails API backend in order to store recipes.&lt;/p&gt;

&lt;p&gt;I started by setting up the Rails API backend. I navigated to the directory where I wanted to create the project, and then ran the following command in the terminal:&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 meal-maker --api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--api&lt;/code&gt; flag set up a Rails application named meal-maker, but without many of the standard features and middleware that Rails would have come with if I had run the command without adding the &lt;code&gt;--api&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;With this API-only Rails build set up I then created the models, controllers, and migrations that I would need.&lt;/p&gt;

&lt;p&gt;I decided to have two models, a cuisine model and a recipe model with has_many and belongs_to relationship between them where a cuisine has many recipes and a recipe belongs to a cuisine.&lt;/p&gt;

&lt;p&gt;To quickly create the migrations, models and controllers for the cuisines and recipes I ran the following two commands in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g resource cuisine title

rails g resource recipe title image instructions ingredients cuisine:references
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command created a cuisine migration file to create a cuisines table with a title column with a string data type, along with a cuisine model and a cuisine controller.&lt;/p&gt;

&lt;p&gt;The second command created a recipe migration file to create a recipes table with columns for title, image, instructions, and ingredients, all of the string data type, along with a cuisine_id column to indicate the particular cuisine that a recipe belongs to.&lt;/p&gt;

&lt;p&gt;In addition a recipe model was created and a recipe controller was created after running the command. My models were set up as follows:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Cuisine&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
    &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:recipes&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;Recipe&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:cuisine&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The recipe model already had &lt;code&gt;belongs_to :cuisine&lt;/code&gt; filled in after running the second command above, but for the cuisine model I had to enter &lt;code&gt;has_many :recipes&lt;/code&gt; there myself.&lt;/p&gt;

&lt;p&gt;I ran the migrations that had been created using the command &lt;code&gt;rails db:migrate&lt;/code&gt; and also filled out the two controllers with the necessary actions (controller methods) that I would need for the functionality that I wanted my application to have.&lt;/p&gt;

&lt;p&gt;I also filled out the seed file with information for four different recipes from four different types of cuisine that I would use to see how the application was working as I was building it out. Then I ran the command &lt;code&gt;rails db:seed&lt;/code&gt; to seed the database with the instances of the cuisine and recipe classes.&lt;/p&gt;

&lt;p&gt;In the cors.rb file in the config/initializers folder I made sure that the following code was uncommented out:&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="no"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert_before&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;Rack&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Cors&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;allow&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;origins&lt;/span&gt; &lt;span class="s1"&gt;'*'&lt;/span&gt;

    &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s1"&gt;'*'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;headers: :any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;methods: &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:get&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:put&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:patch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:delete&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:head&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And I made sure that the line which originally said &lt;code&gt;origins 'example'&lt;/code&gt; was now changed to &lt;code&gt;origins '*'&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In my Gemfile I also uncommented out the line which had &lt;code&gt;gem 'rack-cors'&lt;/code&gt; commented out. I then ran the command &lt;code&gt;bundle install&lt;/code&gt; in the terminal.&lt;/p&gt;

&lt;p&gt;With those changes made to those two files I made sure that problems relating to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"&gt;Cross-Origin Resource Sharing (CORS)&lt;/a&gt; would not cause problems for the ability of the JavaScript frontend to communicate with the Rails API backend.&lt;/p&gt;

&lt;p&gt;After this I moved all the folders and files in the application except the README.md file into a new folder that I created called "backend". &lt;/p&gt;

&lt;p&gt;Then I created a new folder called "frontend" and in that new folder I created an index.html file and a style.css file. In that frontend folder I created another folder called src, and in the src folder I created an index.js file.&lt;/p&gt;

&lt;p&gt;In the index.html file I built out all the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML"&gt;HTML&lt;/a&gt; elements that my application would use, consisting mainly of a form to add new recipes as well as a container to hold already available and newly added recipes.&lt;/p&gt;

&lt;p&gt;In the style.css file I defined the visual styling/appearance of the page using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS"&gt;CSS&lt;/a&gt;, then I made sure that the style.css file was linked to the html file by making sure to include the following line in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of the index.html file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also made sure that the index.js file would be linked to the index.html file by including the following line in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of the index.html file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"src/index.js"&lt;/span&gt; &lt;span class="na"&gt;defer&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the index.js file inside of the frontend/src folder I used Object Oriented JavaScript to write out a Recipe class with the methods and behavior that I wanted to provide my application with the necessary functionality. &lt;/p&gt;

&lt;p&gt;I wrote &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static"&gt;static&lt;/a&gt; and non-static methods that used DOM manipulation or &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents"&gt;Document-Object-Model manipulation&lt;/a&gt; on the elements of the index.html file, as well as methods that made three &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started"&gt;AJAX calls&lt;/a&gt; using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch"&gt;fetch&lt;/a&gt; in order to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET"&gt;GET&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST"&gt;POST&lt;/a&gt; data from and to the Rails API backend that I had set up earlier. I was able to communicate with the Rails API backend using &lt;code&gt;fetch&lt;/code&gt; in these JavaScript methods after making sure to first navigate to the backend directory of the application and then use the &lt;code&gt;rails s&lt;/code&gt; command to start the server. &lt;/p&gt;

&lt;p&gt;One of these methods I defined for the Recipe class was able to use &lt;code&gt;fetch&lt;/code&gt; to get all of the Recipe objects, including information about what Cuisine each Recipe object belonged to, from the backend and pass on that information to another method to display these recipes on the page. Another method was able to use &lt;code&gt;fetch&lt;/code&gt; to make new Recipe objects from the information entered by the user on the form at the top of the page, and then pass on the entered information to another method which would display this newly created recipe in a table row on the page.&lt;/p&gt;

&lt;p&gt;Finally another method was able to remove existing recipes from the page of the application and use &lt;code&gt;fetch&lt;/code&gt; to delete existing recipes from the Rails API backend once the user clicked on the delete button below a recipe. All of this functionality was possible in the application without the page needing to be refreshed/reloaded, showing the power of a JavaScript frontend to deliver a fast and seamless experience for the user.&lt;/p&gt;

&lt;p&gt;I learned a great deal about JavaScript, HTML, and CSS from building out this project and I felt like I was closer to becoming a full stack software developer after it was completed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/GuosaE/meal-maker"&gt;A link to the repository for my project&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Ruby on Rails Application for Organizing News Articles</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Fri, 12 Nov 2021 12:31:08 +0000</pubDate>
      <link>https://dev.to/guosae/a-ruby-on-rails-application-for-organizing-news-articles-1422</link>
      <guid>https://dev.to/guosae/a-ruby-on-rails-application-for-organizing-news-articles-1422</guid>
      <description>&lt;p&gt;As part of my journey to becoming a software developer I learned the Ruby on Rails framework, a popular web application framework which makes use of the principle of &lt;a href="https://en.wikipedia.org/wiki/Convention_over_configuration"&gt;&lt;em&gt;convention over configuration&lt;/em&gt;&lt;/a&gt; to make it easier for developers to quickly develop useful web applications.&lt;/p&gt;

&lt;p&gt;Ruby on Rails, or Rails, utilizes the &lt;a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller"&gt;model-view-controller (MVC) architecture&lt;/a&gt; where controllers handle data flow between views (the representations of data which the user of the application sees and can interact with) and models (which manage the logic and data of the application). &lt;/p&gt;

&lt;p&gt;An important feature of Rails is its built-in use of the &lt;a href="https://guides.rubyonrails.org/active_record_basics.html"&gt;Active Record Object Relational Mapping System&lt;/a&gt; to map database tables (which store the actual information which the program uses) to models (which in Rails are certain Ruby classes which are defined as the models of the application). &lt;/p&gt;

&lt;p&gt;Through the use of the Active Record system developers do not need to focus on putting excessive effort into configuration (since the configuration of this aspect of the application is already set up in any Rails application) and can also utilize certain standard, pre-defined conventions to quickly manipulate data for their Rails applications.&lt;/p&gt;

&lt;p&gt;Active Record has &lt;a href="https://guides.rubyonrails.org/active_record_basics.html#naming-conventions"&gt;naming conventions&lt;/a&gt; for classes and their corresponding database tables, where table names are pluralized versions of their corresponding model/class names. Active Record also comes with many standard, pre-defined methods which can be utilized on the application's models/classes and instances of those classes.&lt;/p&gt;

&lt;p&gt;In Rails, in order to set up database tables for the models of an application, a developer first has to run migrations, which create database tables for the models. In the migration files which a developer creates in order to set up their database, the structure of the database tables (their columns, the data types of these columns, and the relationships of each table to other tables in the application) are defined, and then the developer runs these migration files and the database is created.&lt;/p&gt;

&lt;p&gt;Developers can also very easily set up &lt;a href="https://guides.rubyonrails.org/routing.html#crud-verbs-and-actions"&gt;RESTful routes&lt;/a&gt; (index, new, create, show, edit, update, and destroy) in Rails by defining the necessary actions (defined as methods belonging to controller classes) in their controller files, then creating corresponding view pages, and also defining the necessary routes. By doing this, developers can provide users of their application access to view pages (accessible to users through specific URL paths) which display certain standard information about the data used in the application: a list of all existing objects, a form to create new objects and then have the newly created object persist in the database, a display of the details of one specific object, a page to edit the details of an object and then have it updated in the database, and the ability to delete an object from the application.&lt;/p&gt;




&lt;p&gt;In learning to use the Ruby on Rails framework my goal was to build a working Ruby on Rails application which allowed users to manage a collection of news articles, and make notes about news articles which other users of the application could view.&lt;/p&gt;

&lt;p&gt;The final application was a kind of Wikipedia-like application where anyone could create an account (sign up), login into their account and create, read, update, or delete news articles of interest to them, in addition to being able to create, read, update, or delete notes about the news articles (or anything else). Whereas in Wikipedia any user can create an account and add new encyclopedia articles or modify existing ones, as well as discuss the aspects (such as quality, style, tone, problems, etc.) of each online encyclopedia article on the talk pages for articles, in my application users could add news/journalism articles, modify existing ones, and create viewable notes about the news articles or other issues of interest.&lt;/p&gt;

&lt;p&gt;The project needed to meet certain requirements in terms of its functionality and design, which are listed below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The application needed to have models which had at least one &lt;code&gt;has_many&lt;/code&gt;, at least one &lt;code&gt;belongs_to&lt;/code&gt;, and at least two &lt;code&gt;has_many :through&lt;/code&gt; relationships.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It needed to include a &lt;code&gt;has_many :through&lt;/code&gt; association where the join table was a user-submittable attribute.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Models needed to have reasonable validations for simple attributes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There needed to be at least one class level ActiveRecord scope method that was chainable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application needed to be able to provide standard user authentication including signup, login, logout and passwords.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application needed to allow login from some third party service, such as GitHub or a social media account such as Facebook, Twitter, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application needed to make use of a nested resource with the appropriate RESTful URLs, which included a nested new route and either a nested index route or a nested show route.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The forms which were used to enter new information or modify existing information needed to display validation errors on the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application needed to be a DRY (Do-not-Repeat-Yourself) Rails application, where there was not excess repetition of similar or identical lines of code throughout the application.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It was also required that I not use scaffolding (Rails has certain commands a developer can enter which allow them to auto-generate a lot of the working parts of an application from the get go), in order to learn more by building out each part of the application piece by piece on my own rather than having much of it being automatically generated from the start.&lt;/p&gt;

&lt;p&gt;Here is how I met these requirements for my application:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the first requirement, I set up a &lt;code&gt;has_many&lt;/code&gt; and &lt;code&gt;belongs_to&lt;/code&gt; relationship between a region model and a country model, where a region had many countries and a country belonged to a particular region of the world. I used countries and regions for the part of the application where the user could access news articles grouped by country, view countries by region, and add countries to regions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the first requirement I also set up two &lt;code&gt;has_many :through&lt;/code&gt; relationships:&lt;/p&gt;

&lt;p&gt;A writer &lt;code&gt;has_many :sources, through: :articles&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A source &lt;code&gt;has_many :writers, through: :articles&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;An article &lt;code&gt;belongs_to :writer&lt;/code&gt;  and  &lt;code&gt;belongs_to :source&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Writer referred to the author or authors of the news article, while source referred to the media company or newspaper responsible for publishing the news article.&lt;/p&gt;

&lt;p&gt;A category &lt;code&gt;has_many :subjects, through: :notes&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A subject &lt;code&gt;has_many :categories, through: :notes&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A note &lt;code&gt;belongs_to :category&lt;/code&gt; and &lt;code&gt;belongs_to :subject&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Category referred to the type of note (i.e. what the note could be classified as - such as a critical note, a note expressing an opinion, etc.) while subject referred to what specific topic the note was actually about (such as finance, business, economics, art, politics, movies, etc.).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In my application the join table between writers and sources was the articles table. A user was able to create, read, update, and delete articles, so article was a user-submittable attribute acting as the join table between writers and sources. Similarly the notes table was the join table between subjects and categories and was also user-submittable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I included validations on the article model ensuring that each article had a title, URL address, and description and also ensuring that each URL address given for each article was unique, before articles could be saved to the database. I also included validations on the names of countries, regions, and writers, and included validations on notes to ensure that they contained information before they could be saved&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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;Article&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
    &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:writer&lt;/span&gt; 
    &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:source&lt;/span&gt; 
    &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt;
    &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:description&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;:url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;uniqueness: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I included class level ActiveRecord scope methods on the Writer model/class and on the Source model/class which enabled writers and sources to be ordered by name, respectively.
&lt;/li&gt;
&lt;/ul&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;Writer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
    &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:articles&lt;/span&gt;
    &lt;span class="n"&gt;has_many&lt;/span&gt; &lt;span class="ss"&gt;:sources&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;through: :articles&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;scope&lt;/span&gt; &lt;span class="ss"&gt;:ordered_by_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;)&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;ul&gt;
&lt;li&gt;&lt;p&gt;I set up standard user authentication allowing signup, login, logout and utilizing passwords. Initially I did this on my own, and got it working perfectly fine following the standard Rails approach to this using user and session controllers, but then later I redid this part using the devise gem instead, which also made this part a bit easier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the external third-party or social media login, I used the &lt;a href="https://github.com/heartcombo/devise"&gt;devise gem&lt;/a&gt;, the &lt;a href="https://github.com/omniauth/omniauth"&gt;omniauth gem&lt;/a&gt;, the &lt;a href="https://github.com/omniauth/omniauth-github"&gt;omniauth-github&lt;/a&gt; gem, and the &lt;a href="https://github.com/cookpad/omniauth-rails_csrf_protection"&gt;omniauth-rails_csrf_protection gem&lt;/a&gt; in my Gemfile and set up the necessary models, controllers, and routes in order to allow a user to login to the application using their GitHub account.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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;'devise'&lt;/span&gt;

&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'omniauth'&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'omniauth-github'&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'omniauth-rails_csrf_protection'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I set up a nested resource using countries and regions where there was a nested new route for making new countries by region, and a nested index route where one could see all the countries within the same region as a selected country, with the appropriate RESTful URLs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The forms for creating or editing articles, notes, countries, or regions did display validation errors on their respective view pages if the user failed to enter in the required information correctly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application made use of partials and helper methods to keep the repetition of similar or identical code throughout the application to a minimum.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also used &lt;a href="https://newsapi.org/"&gt;https://newsapi.org/&lt;/a&gt; as a source of real news articles based around a particular subject (I chose news articles about business and the economy) to seed my database with, so I could see the effect of changes to the application with the use of real data as I was building it out. I utilized the &lt;a href="https://github.com/rest-client/rest-client"&gt;rest-client gem&lt;/a&gt; to easily import news articles from the newsapi.org website into the seed file for my database, in order to create instances of articles, writers, and sources.&lt;/p&gt;

&lt;p&gt;I was able to build out a working Ruby on Rails application which met the technical and design requirements described above, and which provided a basic service to users (storing and managing news information/content in the form of news articles) and in the process I learned a great deal about Rails and also about web development more generally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/GuosaE/story-saver"&gt;A link to the repository for my project.&lt;/a&gt; &lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Sinatra MVC Application for Storing Quotes</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Wed, 27 Oct 2021 10:29:56 +0000</pubDate>
      <link>https://dev.to/guosae/a-sinatra-mvc-application-for-storing-quotes-89h</link>
      <guid>https://dev.to/guosae/a-sinatra-mvc-application-for-storing-quotes-89h</guid>
      <description>&lt;p&gt;My objective was to build a Sinatra application which met the following requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;had a MVC (Model-View-Controller) architecture&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;used ActiveRecord&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;utilized multiple models&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;used at least one &lt;code&gt;has_many&lt;/code&gt; relationship on a User model and one &lt;code&gt;belongs_to&lt;/code&gt; relationship on another model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;had user accounts, where users were able to sign up, sign in, and sign out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;validate the uniqueness of user login attributes, such as username or email&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;once logged in, a user had the ability to create, read, update and destroy the resource that &lt;code&gt;belongs_to&lt;/code&gt; that user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ensured that users could edit and delete only their own resources but not those created by other users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;validated user input so bad data was not able to be persisted to the database&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I was able to create a working Sinatra MVC application which met all of these requirements. I decided to make my application function as a quote management service, where users could enter memorable quotes that they had come across and save them in their pages, while also being able to view quotes that other users had saved. &lt;/p&gt;

&lt;p&gt;I learned a great deal about a number of features of Sinatra and about programming in general.&lt;/p&gt;

&lt;p&gt;Some specific things I gained more experience and knowledge of were the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;how to design views (the V in MVC) to make my application's pages convey relevant information to users based upon what links or buttons they clicked and whether they were logged in or not.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;how to make good use of helper methods. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the usefulness of &lt;em&gt;yield&lt;/em&gt; and &lt;em&gt;layout&lt;/em&gt; in reducing repetition of code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the usefulness of embedded ruby tags&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the power of controllers (the C in MVC)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the usefulness of validations on models &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sessions and how to use the &lt;a href="https://github.com/bcrypt-ruby/bcrypt-ruby"&gt;bcrypt gem&lt;/a&gt; for user authentication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;forms and how they relate to controller actions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I learned a great deal about Sinatra and working on this project was a rewarding experience overall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/GuosaE/Quotably"&gt;A link to the repository for my project.&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Ruby CLI Application Showing the Distribution of Languages Across Countries</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Thu, 21 Oct 2021 19:01:25 +0000</pubDate>
      <link>https://dev.to/guosae/a-ruby-cli-application-showing-the-distribution-of-languages-across-countries-b3d</link>
      <guid>https://dev.to/guosae/a-ruby-cli-application-showing-the-distribution-of-languages-across-countries-b3d</guid>
      <description>&lt;p&gt;My goal was to build a CLI (Command Line Interface) application that utilized external data from a webpage, prompted a user to make choices, and then provided detailed information back to the user based on the choices which the user made.&lt;/p&gt;

&lt;p&gt;I chose to build a Ruby CLI application that would allow a user to see information about all of the regions, countries, and national languages of the world. First I found an API (application programming interface), from the website restcountries.com:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://restcountries.com/v3/all"&gt;https://restcountries.com/v3/all&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This API provided a very detailed list of all the countries in the world, the major languages used in those countries, the regions of the world those countries are located in, and some other important geographical information about those countries.&lt;/p&gt;

&lt;p&gt;With this API, which contained detailed geographical information in JSON (JavaScript Object Notation) format, I was able to obtain the external data that my application could utilize to provide geographical information back to the user.&lt;/p&gt;

&lt;p&gt;In order to parse the JSON formatted data and import it into my application, I used the following lines of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;URL = "https://restcountries.com/v3/all"

    def get_country_data
        uri = URI.parse(URL)
        response = Net::HTTP.get_response(uri)
        response.body
    end

    def countries
        countries = JSON.parse(self.get_country_data)
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the relevant geographical data for each country now accessible to my program in the form of nested hashes, I was able to use that data to create Ruby objects that my application could manipulate in various ways. &lt;/p&gt;

&lt;p&gt;I chose to focus on data about the names of countries, regions, and languages out of the data that had been made available to my application from the restcountries website. &lt;/p&gt;

&lt;p&gt;Consequently, in my 'lib' folder, I created Country, Region, and Language classes, as well as another class to import the raw data, and crafted methods for each class that would allow me to display the geographical data in specific ways back to the user.&lt;/p&gt;

&lt;p&gt;I also created a CLI class, where I stated the various options available to the user to obtain different kinds of information about countries and languages, and provided prompts for specific information to the user about what information they were looking for. In my CLI class I also defined additional methods to provide responses to information that the user might enter.&lt;/p&gt;

&lt;p&gt;Finally, I created an executable file in the bin directory of the application to run the completed program, as well as an environment.rb file in the 'config' folder and a Gemfile and README file.&lt;/p&gt;

&lt;p&gt;With this, my application was complete and I had a working Ruby CLI application that utilized external data.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Regular Expressions in JavaScript</title>
      <dc:creator>Guosa</dc:creator>
      <pubDate>Tue, 28 Jul 2020 00:15:34 +0000</pubDate>
      <link>https://dev.to/guosae/regular-expressions-in-javascript-fp6</link>
      <guid>https://dev.to/guosae/regular-expressions-in-javascript-fp6</guid>
      <description>&lt;p&gt;In JavaScript there are two ways to create regular expressions. &lt;/p&gt;

&lt;p&gt;In the first way, one can write a pattern of letters, numbers or symbols enclosed in forward slash(/) characters, like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex1 = /xyz123/;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When using this first method of constructing regular expressions, certain special characters, like a question mark(?), asterisk/star(*), dollar sign($), vertical pipe symbol (|), period/dot (.), opening or closing parenthesis, and certain other special characters, need to have a back slash ( \ ) before their character in order be included in the pattern that the regular expression is searching for, as in the following cases:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex1question = /xyz123\?/;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex1pipe = /xyz123\|/;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex1money = /xyz123\$/;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the second method of constructing regular expressions, one can use the &lt;em&gt;RegExp constructor&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;new RegExp()&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;With the RegExp constructor, one encloses the pattern of letters, numbers or symbols in quotation marks, like a string, within parentheses:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex2 = new RegExp("xyz123");&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let regex2money = new RegExp("xyz123$")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A regular expression object in JavaScript has methods that can be used on it. For example, the method &lt;em&gt;test&lt;/em&gt; returns a Boolean which indicates whether the string passed as an argument in the test method matches the pattern of the regular expression. For example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(/123xyz/.test("123xyz456"));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;will return &lt;em&gt;true&lt;/em&gt; since the pattern "123xyz" is contained in the string "123xyz456". &lt;/p&gt;

&lt;p&gt;On the other hand the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(/123xyz/.test("123zzz456"));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;will return &lt;em&gt;false&lt;/em&gt;, since the pattern "123xyz" is not contained in the string "123zzz456". &lt;/p&gt;

&lt;p&gt;However, if we want to test whether or not a string contains any of the characters in a pattern, we can put the characters in regular expression between square brackets, as in the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(/[123xyz]/.test("zzz"));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will return &lt;em&gt;true&lt;/em&gt;, since the string "zzz" does contain the character "z" from the pattern "123xyz".&lt;/p&gt;

&lt;p&gt;We can also use certain shortcuts to indicate if we are searching for a certain type of character. For example, &lt;/p&gt;

&lt;p&gt;&lt;code&gt;\d&lt;/code&gt; indicates any character that is a digit between 0 and 9 (inclusive).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\w&lt;/code&gt; indicates any alphanumeric character&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\W&lt;/code&gt; indicates any non-alphanumeric character&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\D&lt;/code&gt; indicates any number that is not a digit&lt;/p&gt;

&lt;p&gt;Further reading:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp&lt;/a&gt;&lt;/p&gt;

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