<?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: Sean Oh</title>
    <description>The latest articles on DEV Community by Sean Oh (@ohsean812).</description>
    <link>https://dev.to/ohsean812</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%2F890522%2Fe2afa43f-f341-4f8b-b80b-fcfee0def3d0.jpeg</url>
      <title>DEV Community: Sean Oh</title>
      <link>https://dev.to/ohsean812</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ohsean812"/>
    <language>en</language>
    <item>
      <title>Boost your styling with Bootstrap 🚀</title>
      <dc:creator>Sean Oh</dc:creator>
      <pubDate>Tue, 04 Oct 2022 03:04:28 +0000</pubDate>
      <link>https://dev.to/ohsean812/boost-your-styling-with-bootstrap-ol8</link>
      <guid>https://dev.to/ohsean812/boost-your-styling-with-bootstrap-ol8</guid>
      <description>&lt;p&gt;Throughout several app-building projects I have finished during my software engineering bootcamp, styling has always been a hurdle which I put aside as the last part to work on.  As I've only experienced using the regular CSS (Cascading Style Sheets) in my previous projects, styling a website was nothing more than a boring, tedious job that I'd always have to modify everything manually (and which in most cases didn't work the way I wanted anyway).  Then I met Bootstrap as I was working on my final project for the bootcamp, which completely changed the way I view website styling processes.  Now I can't imagine how I would ever do styling without Bootstrap and really wish I knew of this when working on my earlier projects.  Bootstrap is very easy to use, yet very effective in what it can do to make your websites look so much more visually pleasing.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Bootstrap?
&lt;/h2&gt;

&lt;p&gt;According to &lt;a href="https://en.wikipedia.org/wiki/Main_Page"&gt;Wikipedia&lt;/a&gt;, Bootstrap is a free and open-source CSS framework directed at responsive, mobile-first front-end web development.  It contains HTML, CSS and (optionally) JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components.  In short (and in my own words), it's a tool that help you better write CSS codes more effectively and efficiently.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to actually use Bootstrap
&lt;/h2&gt;

&lt;p&gt;To use Bootstrap, you will first need to install Bootstrap which you can do in several different ways.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;CDN Installation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Go ahead and add the below code inside the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag in your &lt;code&gt;index.html&lt;/code&gt; file before all other stylesheets.  Note, this code may vary as the new version of Bootstrap is released.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;2. Installation via yarn&lt;/p&gt;

&lt;p&gt;Enter the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react-bootstrap bootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;3. Installation via npm&lt;/p&gt;

&lt;p&gt;Enter the following command in your 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 react-bootstrap bootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;IMPORTANT&lt;/em&gt; : If you are installing via &lt;code&gt;yarn&lt;/code&gt; or &lt;code&gt;npm&lt;/code&gt;, make sure you add &lt;code&gt;import 'bootstrap/dist/css/bootstrap.css';&lt;/code&gt; in your &lt;code&gt;index.js&lt;/code&gt; file.&lt;/p&gt;




&lt;p&gt;Once installing Bootstrap using one of the above methods is completed, the world is your oyster!  The real power of Bootstrap comes from it being open-source.  That is, Bootstrap offers hundreds (if not thousands) of styling elements and effects that are available online, which is how you can apply styles to your HTML without having to write codes in your &lt;code&gt;.css&lt;/code&gt; file.  You can get started &lt;a href="https://getbootstrap.com/docs/5.1/getting-started/introduction/"&gt;here&lt;/a&gt; and navigate through the options it provides and use the styles you'd like to use as a template in your HTML file.&lt;/p&gt;




&lt;p&gt;A quick example would be buttons.  For your website or app to be dynamic, it is inevitable that you need to add buttons on the website.  In regular HTML, the codes for creating buttons would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;button&amp;gt;Cancel&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which would be displayed on your browser like this:&lt;/p&gt;

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

&lt;p&gt;These plain ol' buttons don't look too bad, but they could definitely look better with some styling added.  By using Bootstrap, you can style it in the way you want without having to add some complex CSS codes.  To do so, you can simply plug the below codes (that are pre-generated by Bootstrap) into your HTML tags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button type="button" class="btn btn-outline-success"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;button type="button" class="btn btn-outline-danger"&amp;gt;Cancel&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which will then upgrade your plain ol' buttons to...&lt;/p&gt;

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

&lt;p&gt;Much better!&lt;/p&gt;




&lt;p&gt;The example I showed above is only a beginning; you can explore and find yourself many more options to add to your website.  All you would need to do is to navigate through the different components or effects you want to apply, then simply add the pre-generated templates to your codes after customizing it so it is altered to the way it is needed for your website.  Another effect I personally found especially helpful was hover effects, which allows Bootstrap make your website more responsive.&lt;/p&gt;




&lt;h2&gt;
  
  
  But what if you are using React?
&lt;/h2&gt;

&lt;p&gt;Most Bootstrap codes you'd find online are provided in an HTML format so you can directly add it to your HTML tags.  However, if you are a React lover (like me), the keywords and syntaxes needed to add the Bootstrap effects are a bit different.  For example, classification for HTML tags would be &lt;code&gt;&amp;lt;tag class="className" /&amp;gt;&lt;/code&gt;, while the same attribute for JSX in React components would be &lt;code&gt;&amp;lt;tag className="className" /&amp;gt;&lt;/code&gt;.  Hence, the code you copy directly from the Bootstrap template and paste into your React components may not work quite right.  Luckily, there is a &lt;a href="https://magic.reactjs.net/htmltojsx.htm"&gt;website&lt;/a&gt; I found which converts all the HTML codes into a JSX format for you.  Living in the future sure feels great!&lt;/p&gt;




&lt;p&gt;For me, using Bootstrap sure was a guilty pleasure because it was super easy to use and it surely made my life so much easier, yet I felt somewhat unaccomplished since it does all the magic.  Like, shouldn't I spend more time and struggle more in order to yield such a result?  What I've come to decide then was that Bootstrap exists for all developers around the world to help save time and code better.  It is there to use, so why not use it?  But I can't deny that it is still crucial that you have to have a basic understanding of how to use the classic CSS and how styling webpage and components work.  If you rely fully on Bootstrap, you will never be able to learn how CSS works under the hood.  As I (luckily?) spent a good amount of time struggling with classic CSS, though, I guess I could use some help from what Bootstrap has to offer for the time being.  That way I could not only have a more visually appealing website, but also spend more time focusing on the website's fundamental structure, functionality, and making the user experience more pleasant.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Bootstrap_(front-end_framework)"&gt;https://en.wikipedia.org/wiki/Bootstrap_(front-end_framework)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://getbootstrap.com/docs/5.1/getting-started/introduction/"&gt;https://getbootstrap.com/docs/5.1/getting-started/introduction/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://magic.reactjs.net/htmltojsx.htm"&gt;https://magic.reactjs.net/htmltojsx.htm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bootstrap</category>
      <category>styling</category>
      <category>css</category>
      <category>easy</category>
    </item>
    <item>
      <title>Your Auth Cheat Sheet</title>
      <dc:creator>Sean Oh</dc:creator>
      <pubDate>Tue, 13 Sep 2022 02:28:57 +0000</pubDate>
      <link>https://dev.to/ohsean812/your-auth-cheat-sheet-4795</link>
      <guid>https://dev.to/ohsean812/your-auth-cheat-sheet-4795</guid>
      <description>&lt;p&gt;I'm not gonna lie; it took me quite some time to understand (and I'm still taking steps to get closer to the full understanding of it) the fundamental concepts of sessions, cookies, authentication and authorization along with password protection (including the crazy processes with BCrypt) in Rails.  In this post, I'm just going to dabble in each concept mentioned above to give you an idea, then share my "cheat sheet" that will hopefully help you with writing sign-up and log-in/out features on your Rails backend.  As the frontend design for these features is all about creativity, I will leave it up to you on that part. &lt;del&gt;(of course not because I'm too lazy to come up with an example)&lt;/del&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;u&gt;Cookies and Sessions&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Even not as a developer, you might have heard of &lt;em&gt;cookies&lt;/em&gt; before.  And there is another thing called &lt;em&gt;sessions&lt;/em&gt; when you dive deeper into learning the auth concept in Rails.  So what are exactly &lt;em&gt;cookies&lt;/em&gt; and &lt;em&gt;sessions&lt;/em&gt;?  Let's say that you recently bought a new laptop, and you're so excited to use it.  You'd browse on the internet, send emails, shop online, etc.  In order for you to do these things, you have probably accessed google.com, gmail.com, amazon.com, etc.  In the websites' perspectives, since you have just unboxed your new laptop and accessed those websites "for the first time," these websites would have no idea who you are.&lt;/p&gt;

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

&lt;p&gt;Seeing you for the first time ever, the website's reaction would probably be like "Hey, I've never seen you before.  It's nice to meet you.  So that I can recognize you, please have this &lt;em&gt;name tag&lt;/em&gt; with you next time you visit here."&lt;/p&gt;

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

&lt;p&gt;In this analogy, you can think of the &lt;em&gt;name tag&lt;/em&gt; as &lt;em&gt;&lt;strong&gt;cookies&lt;/strong&gt;&lt;/em&gt;.  It is a unique distinguisher for your (new) laptop so that the website doesn't have to ask who you are (or what other information you have with you) every time you visit there.  Now that your laptop (or your browser) has &lt;em&gt;cookies&lt;/em&gt;, the website will have to remember the fact that it has assigned you those &lt;em&gt;cookies&lt;/em&gt;.  To do so, the website's server will make a list of the name tags(&lt;em&gt;cookies&lt;/em&gt;) it has assigned to various computers and browsers.  Now this "list" is called a &lt;strong&gt;&lt;em&gt;session&lt;/em&gt;&lt;/strong&gt;.  Going forward, when you visit the website (which you've previously visited) with the name tag(&lt;em&gt;cookie&lt;/em&gt;) you've been assigned with, the website will see if your name tag(&lt;em&gt;cookie&lt;/em&gt;) is in the list(&lt;em&gt;session&lt;/em&gt;) of the name tags that it has assigned before to determine whether or not you have already visited this website in the past.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;u&gt;Authentication &amp;amp; Authorization&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Authentication and authorization are two vital information security processes that administrators use to protect systems and information.  They may seem to be conceptually the same, but have slightly different aspects in what they imply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt; verifies the identity of a user or service.  That is, when you log into your Gmail account (if you have one) using your username and password, Google's server will issue your browser the above-mentioned cookie.  Then, as you navigate through several different pages on Gmail (or anywhere on google.com for that matter), your browser will show the cookie to the server, which the server then will verify the cookie and let you stay logged in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization&lt;/strong&gt; determines the user's access rights.  In addition to authentication, authorization gives certain users permission to access specific resources.  For example, everyone can go to Apple Music to listen to whatever song they like for 90 seconds as "preview."  However, only the &lt;em&gt;authenticated&lt;/em&gt; users (those who paid for the premium service and logged into Apple Music) will be able to listen to the full songs, create their own playlists, etc.&lt;/p&gt;




&lt;p&gt;Now it's time for what you've been waiting for... the cheat sheet!  I highly recommend, though, that you first have gained solid understanding of the auth process in Rails and fully understand what is going on under the hood before just referring to this cheat sheet because otherwise this cheat sheet would be a mere template that probably will not make any sense.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;/config/routes.rb&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails.application.routes.draw do
  post '/signup', to: "users#create"
  get '/me', to: "users#show"
  post '/login', to: "sessions#create"
  delete '/logout', to: "sessions#destroy"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;/app/models/user.rb&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ApplicationRecord
    has_secure_password
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;/app/controllers/users_controller.rb&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UsersController &amp;lt; ApplicationController

    before_action :authorize, only: [:show]

    def create
        # create a new user
        # save their hashed password in the database
        user = User.create(user_params)
        # save the user's ID in the session hash
        if user.valid?
            session[:user_id] = user.id
        # return the user object in the JSON response
            render json: user, status: :created
        else
            render json: { error: user.errors.full_messages }, status: :unprocessable_entity
        end
    end

    def show
        # if the user is authenticated, return the user object in the JSON response
        user = User.find_by(id: session[:user_id])
        render json: user
    end

    private

    def user_params
        params.permit(:username, :password, :password_confirmation)
    end

    def authorize
        return render json: { error: "Not authorized" }, status: :unauthorized unless session.include? :user_id
    end

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;/app/controllers/sessions_controller.rb&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SessionsController &amp;lt; ApplicationController

  def create
    user = User.find_by(username: params[:username])
    if user&amp;amp;.authenticate(params[:password])
      session[:user_id] = user.id
      render json: user, status: :created
    else
      render json: { error: "Invalid username or password" }, status: :unauthorized
    end
  end

  def destroy
    session.delete :user_id
    head :no_content
  end

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;u&gt;References&lt;/u&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://guides.rubyonrails.org/action_controller_overview.html#session"&gt;https://guides.rubyonrails.org/action_controller_overview.html#session&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://guides.rubyonrails.org/action_controller_overview.html#cookies"&gt;https://guides.rubyonrails.org/action_controller_overview.html#cookies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.onelogin.com/learn/authentication-vs-authorization#:%7E:text=Authentication%20and%20authorization%20are%20two,authorization%20determines%20their%20access%20rights"&gt;https://www.onelogin.com/learn/authentication-vs-authorization#:~:text=Authentication%20and%20authorization%20are%20two,authorization%20determines%20their%20access%20rights&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password"&gt;https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>authentication</category>
      <category>authorization</category>
      <category>rails</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Application Structure (feat. Separation of Concerns)</title>
      <dc:creator>Sean Oh</dc:creator>
      <pubDate>Mon, 22 Aug 2022 03:46:00 +0000</pubDate>
      <link>https://dev.to/ohsean812/application-structure-feat-separation-of-concerns-4c02</link>
      <guid>https://dev.to/ohsean812/application-structure-feat-separation-of-concerns-4c02</guid>
      <description>&lt;p&gt;When I first started learning Ruby and Sinatra framework, it took me quite some time to get myself familiarized with the application structure.  The idea of this whole file structure thing at first looked like this to me:&lt;/p&gt;

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

&lt;p&gt;I mean okay, separation of concern is important, but how do I know what to put, and in where?  For those who may be struggling to understand the application structure concepts, this post can guide you through what each of your folder(directory) and file should contain.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is "Separation of Concerns"?
&lt;/h2&gt;

&lt;p&gt;To understand the whole idea of creating this complex (and even intimidating) structure before working on your application, understanding &lt;em&gt;separation of concerns&lt;/em&gt; would be the key concept to get familiarized with first.  "Separation of concerns" is a design principle for separating a computer program into distinct sections.  Without following it, your application might get very messy and hard to understand for other developers.  It's like having your belongings organized in the right place.  You would want your toothbrush in the toothbrush holder in your bathroom, cups in the cabinet of your kitchen, your mouse to the right-hand side to your laptop or keyboard (given that you use your mouse set up for right-handed people.  (&lt;del&gt;TMI: I'm left-handed but use a right-handed mouse.&lt;/del&gt;), and so on.&lt;/p&gt;

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

&lt;p&gt;Just like that, you would want your codes located in the proper file and the proper folder.  Not so related to the topic of separation of concerns, but it is also very important to name your files and folders correctly when it comes to using Active Record (a Ruby gem that will save you lots of time when writing object-relational mapping or ORM), as it is a proponent of using certain formats and grammars to ensure locating correct classes and running correct methods.  You can find more info on the Active Record's naming conventions &lt;a href="https://guides.rubyonrails.org/v4.1/active_record_basics.html#naming-conventions"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sinatra Application Structure
&lt;/h2&gt;

&lt;p&gt;Alright, let's get down to business.  Below is how you should set up your folders and files structure for your application, with each of their own responsibility:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;app/models&lt;/code&gt;: This folder contains Active Record model files with the file extension of &lt;code&gt;.rb&lt;/code&gt;.  Each model file contains code that accesses and updates data in the database using classes that inherit from &lt;code&gt;ActiveRecord::Base&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;config&lt;/code&gt; (usually contains the &lt;code&gt;environment.rb&lt;/code&gt; file): Code in this folder is responsible for environment setup, like requiring files/gems, and establishing a connection to the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;db/migrate&lt;/code&gt; (usually contains &lt;code&gt;timestamp_create_(model_name_in_plural).rb&lt;/code&gt; files): This folder contains Active Record migration files.  Each migration file contains code that is responsible for creating and altering the structure of the database (making new tables, adding columns to existing tables, etc).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;db/seeds.rb&lt;/code&gt;: This file allows us to easily add sample data to the database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Gemfile&lt;/code&gt; (a file with no extension): This file lists all the gems/dependencies the application would need to depend on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Rakefile&lt;/code&gt; (a file with no extension): This file contains code for common tasks that you can easily run from the command line, such as &lt;code&gt;rake console&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you get comfortable with the concept, it's not that complicated after all.  In fact, you will even feel more comfortable following this convention before you know it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Separation_of_concerns"&gt;https://en.wikipedia.org/wiki/Separation_of_concerns&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>filestructure</category>
      <category>separationofconcerns</category>
      <category>sinatra</category>
    </item>
    <item>
      <title>React Basics for Dummies</title>
      <dc:creator>Sean Oh</dc:creator>
      <pubDate>Mon, 01 Aug 2022 05:45:02 +0000</pubDate>
      <link>https://dev.to/ohsean812/react-basics-for-dummies-3f4g</link>
      <guid>https://dev.to/ohsean812/react-basics-for-dummies-3f4g</guid>
      <description>&lt;p&gt;By the time you have searched "react" and come across this blog post, you probably have finished some course materials on HTML, CSS, and JavaScript.  Now with some basic knowledge of how to use them to create cool websites, there is something even cooler called "React".&lt;/p&gt;




&lt;h2&gt;
  
  
  What is React?
&lt;/h2&gt;

&lt;p&gt;You can find the official definition of React &lt;a href="https://en.wikipedia.org/wiki/React_(JavaScript_library)"&gt;here&lt;/a&gt;, but for those who prefer definitions straight to the point, I would put it this way: it's like a built-in software (&lt;del&gt;officially called a "library"&lt;/del&gt;) installed inside JavaScript, so you can use that software to write your codes more easily.&lt;/p&gt;




&lt;h2&gt;
  
  
  Imperative vs. Declarative
&lt;/h2&gt;

&lt;p&gt;If I were to pick one of the many benefits of using React, I would definitely say that React is &lt;strong&gt;declarative&lt;/strong&gt; (versus &lt;strong&gt;imperative&lt;/strong&gt;).  Let me explain the difference between the two in a very simple way.  Let's say that you order your assistant (we all have a personal assistant to run your errands, don't we?) to go to Starbucks the next building to get you a cup of coffee. An imperative way of your order would look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go out the door of this building&lt;/li&gt;
&lt;li&gt;Turn left&lt;/li&gt;
&lt;li&gt;Walk 10 meters&lt;/li&gt;
&lt;li&gt;See the sign for the name of the building&lt;/li&gt;
&lt;li&gt;If the sign reads "Starbucks", go inside the building&lt;/li&gt;
&lt;li&gt;Order a grande sized iced vanilla latte&lt;/li&gt;
&lt;li&gt;Take out a wallet&lt;/li&gt;
&lt;li&gt;Pay the full amount for the order&lt;/li&gt;
&lt;li&gt;and so on...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I already got tired of writing more commands and therefore stopped here, but until you finally get your coffee, the list would go on, and on, and on.  How would a declarative way of your order look like then?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get me a grande iced vanilla latte from Starbucks next door&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;How simple is that? React allows us to give an order in a much simpler way to get the same result as you would do in the vanilla JavaScript!&lt;/p&gt;

&lt;p&gt;I could spend the whole hour talking about the other good benefits of using React, but since I don't want this blog post to be so bombarding (honestly I feel like I have written so much already), let me introduce what React is actually composed of.&lt;/p&gt;




&lt;h2&gt;
  
  
  Components, Props, JSX... what?
&lt;/h2&gt;

&lt;p&gt;React is composed of various "components". Components are the &lt;strong&gt;building blocks&lt;/strong&gt; of React code. It is a JavaScript function, always starting with a capital letter to differentiate from the regular functions from vanilla JavaScript. A React component would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function IAmAComponent () {
   return &amp;lt;h1&amp;gt;Hello, I am a component!&amp;lt;/h1&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A component always returns what's called JSX. JSX, JavaScript XML, allows us to use HTML in JavaScript. (See that &lt;code&gt;h1&lt;/code&gt; tag that looks familiar?)&lt;/p&gt;

&lt;p&gt;You may have seen the definition of component as "a function that takes in props and returns JSX."  Okay, we now know component, and we also know JSX, but what are props?&lt;/p&gt;

&lt;p&gt;Before I explain what props are, I would have to point out that I have said above "components are the &lt;strong&gt;building blocks&lt;/strong&gt; of React code."  What does that mean? You will create each component as a block to build, and place them in the top level component.  From that top level component, you have access to each of the building block components.  For example, an &lt;code&gt;App&lt;/code&gt; component as a "parent" component, could have a "child" component called &lt;code&gt;About&lt;/code&gt;.  As the naming suggests, a "parent" component will pass down "props" to its "child" component(s).  When the parent component calls child components, it will assign "props" by giving the prop's name and what that prop points to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Parent Component (App)

const movie = {
  title: "Inception",
  genre: "Action/Sci-fi",
  released: 2010
},

function App() {
  return (
      &amp;lt;About
         title={movie.title}
         genre={movie.genre}
         year={movie.released} /&amp;gt;
  );
}
&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;//Child Component (About)

function About({ title, genre, year }) {
  return &amp;lt;h2&amp;gt;{title} is a {genre} movie released in {year}.&amp;lt;/h2&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the example above, the &lt;code&gt;App&lt;/code&gt; component is assigning props when it calls the &lt;code&gt;About&lt;/code&gt; component. It's giving "instructions" on what each prop means.  For example, &lt;code&gt;title={movie.title}&lt;/code&gt; means the prop's name(or label) is &lt;code&gt;title&lt;/code&gt;, and it refers to the value of the &lt;code&gt;movie&lt;/code&gt; object(which was assigned as a variable on top)'s &lt;code&gt;title&lt;/code&gt; key.  You could name your prop any way you want (see the prop &lt;code&gt;year&lt;/code&gt; above was named &lt;code&gt;year&lt;/code&gt;, not necessarily &lt;code&gt;released&lt;/code&gt;?), but by convention it is always best to come up with names that are relevant.  It's like your mom (parent) telling you as a kid (child) "Hey, I'm going to give you this prop. (handing a prop) This prop's name is &lt;code&gt;title&lt;/code&gt;.  It means &lt;code&gt;{movie.title}&lt;/code&gt; (the title of the movie).  Whenever you play in your world, you say &lt;code&gt;title&lt;/code&gt; to refer to &lt;code&gt;{movie.title}&lt;/code&gt;.  OK?"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L4lxMGDy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ue4dmdgm4gfjzzynw57.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L4lxMGDy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ue4dmdgm4gfjzzynw57.jpeg" alt="Image description" width="880" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, when the child component writes its own JSX in itself, it can use the prop name &lt;code&gt;title&lt;/code&gt; to refer to the &lt;code&gt;{movie.title}&lt;/code&gt; which was originated from the parent component.&lt;/p&gt;




&lt;p&gt;This really is just the very basics of the general concept of React, and there will be a whole lot more when you actually dive into it. But having this basic concept well drawn in your head may help you understand the awesome features of React moving forward!&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/React_(JavaScript_library)"&gt;https://en.wikipedia.org/wiki/React_(JavaScript_library)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>components</category>
      <category>props</category>
    </item>
    <item>
      <title>Love and Hate Relationship with ARRAYS</title>
      <dc:creator>Sean Oh</dc:creator>
      <pubDate>Mon, 11 Jul 2022 22:47:48 +0000</pubDate>
      <link>https://dev.to/ohsean812/love-and-hate-relationship-with-arrays-129d</link>
      <guid>https://dev.to/ohsean812/love-and-hate-relationship-with-arrays-129d</guid>
      <description>&lt;p&gt;During my prework era (my coding bootcamp required completion of about 3 weeks' worth of learning materials before the cohort started which was called prework), I first came across the concept of &lt;code&gt;array&lt;/code&gt;.  It was when the lesson material briefly explained what the &lt;code&gt;array&lt;/code&gt; is, what it looks like, and what it's used for.  Very concise and straightforward.  "I like this," I thought--only to find two weeks later thinking of arrays makes me want to throw up.  Why are there so many methods, why is it such a difficult and complicated process to access one single value, and to make things even worse, how do I link them to my assigned function, etc.?  WHY ISN'T ANYTHING I DO WORKING?!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0i3EQs-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r3mzslelw9pgmktwjeh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0i3EQs-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r3mzslelw9pgmktwjeh.gif" alt="Image description" width="640" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started hating almost everything about &lt;code&gt;array&lt;/code&gt;s, and almost lost interests in knowing more about it.  Then I gave it a second thought, "maybe we can work this out."  Just like any other love and hate relationships, I decided to look more closely into this and become better friends with it.  Then I was mesmerized by how their methods can make things so convenient and make your life so much easier.  Among various methods available for &lt;code&gt;array&lt;/code&gt;s to use in JavaScript, I would like to share some of my favorite iterator methods: &lt;code&gt;.filter()&lt;/code&gt;, &lt;code&gt;.map()&lt;/code&gt;, and &lt;code&gt;.forEach()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;* These are all built-in methods&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;code&gt;.filter()&lt;/code&gt; "Hey, create a new array with elements I want only!"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.filter()&lt;/code&gt; searches through an array, passes each element to a provided callback function.  Then it returns a brand new array including elements only that passed the callback function.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[5, 6, 7, 8, 9].filter(function (num) {
  return num &amp;lt; 8;
});

// =&amp;gt; [5, 6, 7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;&lt;code&gt;.map()&lt;/code&gt; "Hey, create a new array with each element transformed!"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.map()&lt;/code&gt; transforms every element in an array to another value.  Like &lt;code&gt;.filter()&lt;/code&gt;, it accepts a callback function and passes each element in turn to the callback.  The difference, though, is that &lt;code&gt;.map()&lt;/code&gt; will return an array of same number of elements in transformed version, while &lt;code&gt;.filter()&lt;/code&gt; will give an array with elements that passed the callback function only.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1, 3, 5].map(function (num) {
  return num ** 2;
});

// =&amp;gt; [1, 9, 25]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;&lt;code&gt;.forEach()&lt;/code&gt; "Hey, perform this action for each element in my array!"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.forEach()&lt;/code&gt; loops through an array and passes a callback function on each element.  This does NOT create a new array (like &lt;code&gt;.filter()&lt;/code&gt; or &lt;code&gt;.map()&lt;/code&gt;), and therefore is useful when you want to iterate through an array to log values.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;weather = [
  "sunny",
  "cloudy",
  "rainy",
  "windy"
];

weather.forEach(function(status) {
  console.log(`Tomorrow's weather could be ${status}.`);
});

// =&amp;gt;
Tomorrow's weather could be sunny.
Tomorrow's weather could be cloudy.
Tomorrow's weather could be rainy.
Tomorrow's weather could be windy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;While I like the nature of &lt;code&gt;array&lt;/code&gt;s and how it can do so much, I'm frankly still far from fully grasping each and every method.  But hey, practice makes permanent, and getting to know more about something(or someone) always helps to understand better.  That's how all relationship works anyway.  I hope my relationship with &lt;code&gt;array&lt;/code&gt;s soon will lean more towards the 'love' side and move away from the 'hate' side. &lt;del&gt;(It will take some time)&lt;/del&gt;&lt;/p&gt;




&lt;p&gt;Reference Sources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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