<?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: Emilie</title>
    <description>The latest articles on DEV Community by Emilie (@emilie).</description>
    <link>https://dev.to/emilie</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%2F226650%2F02f0fabf-be82-4235-8bd4-ec202594287b.jpeg</url>
      <title>DEV Community: Emilie</title>
      <link>https://dev.to/emilie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emilie"/>
    <language>en</language>
    <item>
      <title>Creating an accessible UI for 5-star rating system</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Fri, 02 Apr 2021 01:45:28 +0000</pubDate>
      <link>https://dev.to/emilie/creating-an-accessible-ui-for-5-star-rating-system-k34</link>
      <guid>https://dev.to/emilie/creating-an-accessible-ui-for-5-star-rating-system-k34</guid>
      <description>&lt;p&gt;If you ever used online shopping malls and got a request to leave a review for an item you bought, you would often run into the 5-star rating system. It's intuitive and easy to understand, we can easily presume what each score would mean without any clarification.&lt;br&gt;
I currently have been working on creating a shopping mall using PHP, HTML, CSS and some JavaScript and I decided to challenge myself to build an accessible UI for this one. &lt;/p&gt;

&lt;p&gt;For this instance, I will use plain HTML, JavaScript and Bootstrap for CSS.&lt;br&gt;
If you are not familiar with the bootstrap, check out &lt;a href="https://getbootstrap.com/docs/5.0/getting-started/introduction/" rel="noopener noreferrer"&gt;this documentation&lt;/a&gt;!&lt;br&gt;&lt;br&gt;
If you have a good grasp of CSS, you would know what class would be the right choice for your work and it actually reduces a good amount of time as you would use the pre-configured CSS classes. &lt;/p&gt;

&lt;p&gt;OK, Shall we start?&lt;/p&gt;

&lt;p&gt;First off, I usually start with creating a HTML document.&lt;br&gt;&lt;br&gt;
You can see the example format down below with its finished work. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1617313139920%2FGKrJSIooC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1617313139920%2FGKrJSIooC.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1617313369443%2FYoK1DSJRh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1617313369443%2FYoK1DSJRh.png" alt="스크린샷 2021-04-01 22.42.39.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Easy peasy lemon squeezy!&lt;br&gt;&lt;br&gt;
As I chose Bootstrap for CSS, I added all the classes according to their uses simultaneously as well. Since we aim to create an accessible user interface, I have included the WAI-ARIA attributes such as &lt;code&gt;role&lt;/code&gt;, &lt;code&gt;aria-label&lt;/code&gt; and &lt;code&gt;aria-checked&lt;/code&gt; to provide improved semantics for the HTML document. &lt;br&gt;
I mulled over for quite a while and I decided &lt;code&gt;role="radiogroup"&lt;/code&gt; for the wrapper &lt;code&gt;div&lt;/code&gt; which contains all the icons and anchors. Since all the anchors actually work like radio buttons which should tell a user whether each of them has been checked or unchecked, I have come to the conclusion that this would be the best solution for this case.    &lt;/p&gt;

&lt;p&gt;I left the &lt;code&gt;aria-label&lt;/code&gt; value for the same &lt;code&gt;div&lt;/code&gt; just empty as that would be dynamically added by JavaScript followed by a user's choice. And I defined &lt;code&gt;role="radio"&lt;/code&gt; to each anchor. This would be helpful for users with disabilities as assistive devices would let them know what they are and users can presume what they need to do with them. Moreover, they become more semantic with those attributes as each anchor contains &lt;code&gt;aria-label&lt;/code&gt; and its value accordingly. I have already tested with VoiceOver on Mac, each time I move around the anchors, it read out the value of &lt;code&gt;aria-label&lt;/code&gt; and &lt;code&gt;role&lt;/code&gt;. Great!!! &lt;/p&gt;

&lt;p&gt;Finally we're moving onto JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function (win, doc){
    const rating = {
        init : function () {
            this.rating();
        },
        rating: function() {
            const stars = doc.querySelectorAll('.rating');
            const starArray = Array.from(stars);
            const role = doc.querySelector('div[role]');
            let totalRate = 0;

            stars.forEach((el, i) =&amp;gt; {
                el.addEventListener('keypress', (e) =&amp;gt; {
                    const { key, target } = e;
                    if (key === 'Enter') interaction(i);
                });

                el.addEventListener('click', (e) =&amp;gt; {
                    e.preventDefault();
                    interaction(i);
                });
            });

        function interaction(i) {
            starArray.forEach((el, j) =&amp;gt; {
                const star = el.firstElementChild;

                if (i === j) {
                    if (star.classList.contains('bi-star')){
                        star.classList.remove('bi-star');
                        star.classList.add('bi-star-fill');
                        star.parentElement.setAttribute('aria-checked', true);
                        totalRate++;
                    } else {
                        star.classList.remove('bi-star-fill');
                        star.classList.add('bi-star');
                        star.parentElement.setAttribute('aria-checked', false);
                        totalRate--;
                    }
                } else if (i &amp;gt; j){
                    if (star.classList.contains('bi-star')){
                        star.classList.remove('bi-star');
                        star.classList.add('bi-star-fill');
                        star.parentElement.setAttribute('aria-checked', true);
                        totalRate++;
                    }
                } else if (i &amp;lt; j){
                    if (star.classList.contains('bi-star-fill')) {
                        star.classList.remove('bi-star-fill');
                        star.classList.add('bi-star');
                        star.parentElement.setAttribute('aria-checked', false);
                        totalRate--;
                    }
                }
            });

            role.setAttribute('aria-label', `Your rating is ${totalRate}`);
        }
    }
}
    rating.init();
})(window, document);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;If you are using a module bundler, you do not need to use the encapsulation and IIFE like my example. As I didn't use a module bundler, these techniques were implemented in order to avoid any global variable pollutions with other JavaScript snippets.&lt;/em&gt;    &lt;/p&gt;

&lt;p&gt;As you can see, there are two types of event listeners, the &lt;code&gt;click&lt;/code&gt; event is for users who use a mouse/trackpad and the &lt;code&gt;keypress&lt;/code&gt; event is for users who mainly use a keyboard.    &lt;/p&gt;

&lt;p&gt;I created all the variables on the top of the code block so, I can easily refer to them whenever I need them. We all know that what HTML elements need to be manipulated according to users' interaction. First, all the anchors would work like radio buttons here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stars = doc.querySelectorAll('.rating');
const starArray = Array.from(stars);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the variable stars is a nodelist(not an array), I also converted it into an Array using the method Array.from(). If you are not sure why you need to do this, let me quickly summarise it for you.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.querySelectorAll()&lt;/code&gt; is not a part of JavaScript API. It is a part of Browser(document) API which let us access to DOM elements. The thing is even if it contains list in its name, it is not an array, but, a collection of nodes. How confusing! If you want to manipulate DOM elements using Array methods, you should convert the &lt;code&gt;nodelist&lt;/code&gt; into an array beforehand. One more thing! As you can see from my code snippet, the nodelist &lt;code&gt;stars&lt;/code&gt; is iterated by forEach. Do not confound the &lt;code&gt;NodeList.forEach()&lt;/code&gt; with the &lt;code&gt;Array.forEach()&lt;/code&gt; method here! Actually, these are not JavaScript APIs, you can see them from other languages in order to interact with documents. I hope this clarifies your confusion.    &lt;/p&gt;

&lt;p&gt;The whole code snippet is basically to add an event listener for each anchor element and it runs the rest of the codes inside of the correct event type according to a user' input device. To reduce the repetition of the codes, I have wrapped the codes in the forEach method. If I didn't do it this way, I have to create the same event listener for each anchor element, that is to say, 5 times in total per event type! This way we can provide more readable codes for a team and we can work more efficiently.  &lt;/p&gt;

&lt;p&gt;To maximise the code reuse, I created a function called &lt;code&gt;interaction&lt;/code&gt;.&lt;br&gt;
Whether it is a mouse or keyboard interaction, fundamentally how they work is identical. I used the &lt;code&gt;forEach&lt;/code&gt; method in order to iterate the same work over all the  elements and the rest of the code is just to interchange the classes between &lt;code&gt;bi-star&lt;/code&gt; and &lt;code&gt;bi-star-fill&lt;/code&gt; based on the condition I wrote.&lt;/p&gt;

&lt;p&gt;As I used &lt;code&gt;ForEach&lt;/code&gt; twice, there are two index type, &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;j&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
&lt;code&gt;i&lt;/code&gt; index indicates the index of the anchor element which is clicked by a user amongst 5 of them and as &lt;code&gt;j&lt;/code&gt; index is for the nested loop, the array indicated by &lt;code&gt;j&lt;/code&gt; index will iterate every time a user clicks an anchor element. For example, the &lt;code&gt;if( i === j )&lt;/code&gt; statement is to enable the repeated interaction in case that a user &lt;code&gt;click&lt;/code&gt;s or &lt;code&gt;keypress&lt;/code&gt;es multiple times on the same element, that is to say, &lt;code&gt;aria-checked&lt;/code&gt; value can also switch between &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; interchangeably. Finally, each time a user interacts with the 5-star rating, the &lt;code&gt;aria-label&lt;/code&gt; value will also change accordingly.    &lt;/p&gt;

&lt;p&gt;Based on the Google lighthouse report, there was no error detected and everything works smoothly without any error. However, if you noticed any improvable point of my work, please, do not hesitate to leave a reply and let's discuss! ;-) I hope you find this tutorial helpful for your work and if you enjoyed this, please leave a comment and like my post as well!&lt;/p&gt;

&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@gentlestache?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Bonneval Sebastien&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/user-interface?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>javascript</category>
      <category>html</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>WordPress VS PHP Scripting</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Sat, 20 Mar 2021 20:23:04 +0000</pubDate>
      <link>https://dev.to/emilie/wordpress-vs-php-scripting-1fgk</link>
      <guid>https://dev.to/emilie/wordpress-vs-php-scripting-1fgk</guid>
      <description>&lt;p&gt;This is my comparison and contrast between WordPress(&lt;em&gt;E-reader's digest&lt;/em&gt;) and PHP Scripting(&lt;em&gt;Furniture shop&lt;/em&gt;) to build websites. If you are interested in learning one or the other, this may give you an enlightenment to make your mind up to decide which one you would start with first. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both websites have responsive navigation which automatically fits the users' screen size from a single URL. As can be seen below, they are very similar navigations in terms of how they work and are viewed by users. However, there are a few distinctions to achieve the same functionality between the two websites. &lt;/p&gt;

&lt;p&gt;The WordPress theme provides a responsive layout as default. Therefore, it doesn’t require any hand-coding unless a user wants to make any customisations for cosmetic purposes. It can be simply created by adding up the menu categories from the admin page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--20sZ67h4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616264788100/y6THkYVQW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--20sZ67h4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616264788100/y6THkYVQW.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, &lt;em&gt;Furniture Shop&lt;/em&gt; requires web programming skill to implement responsive navigation such as comprehending what a responsive design and media query are and how to create grid/flex layouts. For the &lt;em&gt;Furniture shop&lt;/em&gt;, CSS bootstrap framework is used to reduce the initial set-up time for CSS. As such, HTML formatting, pictured below, was the prime task and all CSS classes are preconfigured from bootstrap; they have been added to class attributes accordingly in order to create the user interface. Since the navigation is present throughout all pages on the website, it is modularised into &lt;code&gt;navigation.php&lt;/code&gt; in the components folder, so that it can be embedded throughout all the pages by using &lt;code&gt;&amp;lt;?php includes 'components/navigation.php' ?&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rn1FUxkT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265050291/faiaZlIht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rn1FUxkT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265050291/faiaZlIht.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KD4IcnAU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265061191/OnNpvqP0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KD4IcnAU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265061191/OnNpvqP0e.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;em&gt;E-reader’s digest&lt;/em&gt;, the data tables are preconfigured and the data is populated automatically when categories, posts and other data is created by users. The easy-to-use interface is intuitive and allows for the creation of a website even without knowing about the database. At the same time, the provision of preconfigured options in WordPress could be seen to somewhat limit creativity; WordPress might be seen more like a paint-by-numbers picture compared to the blank canvas offered by PHP Scripting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JWWt18U_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265169679/VZAj459T5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JWWt18U_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265169679/VZAj459T5.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The database for &lt;em&gt;Furniture Shop&lt;/em&gt; was created with &lt;strong&gt;phpMyAdmin&lt;/strong&gt; which supports &lt;strong&gt;MySQL&lt;/strong&gt; with its intuitive web interface. Creating, dropping and modifying tables, columns and data isn’t challenging and it actually can be comparable with the former method thanks to its web interface. But, the difference with WordPress is that the connection and closure of database and query statements should be hardcoded in a PHP file to communicate with the database. Once specific data from products table is called, the relevant data based on columns’ name would be displayed according to a unique &lt;em&gt;product_id&lt;/em&gt;. Unlike the former method, the configuration and displaying of columns is up to the developer so that the customisation pertains to the programming logic.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oD8fREcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265248773/WJ7k4GZ1e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oD8fREcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265248773/WJ7k4GZ1e.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Thumbnails&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The thumbnail of &lt;em&gt;E-reader’s digest&lt;/em&gt; was created by a plugin called &lt;em&gt;Advanced Excerpt&lt;/em&gt;. It automatically generates thumbnails of all the posts based on the user’s setting, as can be seen in the image below. While it might be desirable to allow users to have full control of the thumbnail customisation, ‘&lt;em&gt;Advanced Excerpt&lt;/em&gt;’ is arguably very helpful for non-technical users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zqI53dea--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265354474/jOD-Z_2YU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zqI53dea--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265354474/jOD-Z_2YU.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VXxYINdc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265382947/2566bPQiF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VXxYINdc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265382947/2566bPQiF.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With regards to &lt;em&gt;Furniture Shop&lt;/em&gt;, the thumbnails, which were created by hand-coded PHP, HTML and CSS, can be seen below. The benefit of this method is having full control of the thumbnail component such as styling, layout and content. Owing to the bootstrap framework, the fluid layout was easily achieved by adding a few CSS classes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P1LmXsH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265432440/l6OOKD0Xb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P1LmXsH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265432440/l6OOKD0Xb.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZrNsoWLq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265444563/PITVG5Uio.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZrNsoWLq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265444563/PITVG5Uio.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;Detail page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The detail page of WordPress was generated by creating a post using its WYSIWYG editor. This is the power of WordPress’ Content Management System (CMS) which provides several component blocks such as Heading, Paragraph, Table, Columns, etc and reusable blocks can be created by grouping them. &lt;/p&gt;

&lt;p&gt;This is arguably the best way to create a blog post as bloggers can be creative online without web programming skills and present their work in a way they want to. &lt;/p&gt;

&lt;p&gt;While this is the case, when considering an e-commerce website with a thousand products that need to be uploaded, this kind of repetitive creation for each product page could be seen to be cumbersome and inefficient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--In6cDMxX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265510409/-N6cU2R-B.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--In6cDMxX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265510409/-N6cU2R-B.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, the detail page of &lt;em&gt;Furniture Shop&lt;/em&gt; avoids the aforementioned potential disadvantage of the WordPress website. Each thumbnail of a product item is wrapped by &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag and the hyperlink contains a query parameter “&lt;em&gt;product_id&lt;/em&gt;” with a unique ID for the product. As soon as a user clicks the hyperlink, PHP scripting starts communicating with the database to request the product data which has the same ID from the products table. &lt;/p&gt;

&lt;p&gt;Once it successfully retrieves the data, the rest of the codebase runs and the display of the detail page is completed. If not retrieved, it will show an error message. By doing so, it eliminates the onerous amount of work to create each detail page per item. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gH8iaycZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616266417324/LRecSQ9gh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gH8iaycZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616266417324/LRecSQ9gh.png" alt="스크린샷 2021-03-20 18.53.08.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C3nPLP6z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616266448616/quX6_uIJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C3nPLP6z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616266448616/quX6_uIJQ.png" alt="스크린샷 2021-03-20 18.54.00.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HOzN8W2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265732651/O5v5nEmdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HOzN8W2n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1616265732651/O5v5nEmdo.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Conclusions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;WordPress&lt;/strong&gt; enables the buildings of a website without initial engineering overhead. However, the more a user wants to customise a theme and plugins, the more time would be needed to learn how to do so and then optimise it. This would be a time-consuming process to take more control over those plugins and the theme. At the same time, the loading time appears to be somewhat cumbersome and slow in terms of performance. Perhaps it may be a downside of the server-side rendering which is implemented by &lt;strong&gt;WordPress&lt;/strong&gt; using &lt;strong&gt;PHP&lt;/strong&gt; and &lt;strong&gt;MySQL&lt;/strong&gt; under the hood. Moreover, the more new code blocks such as &lt;strong&gt;CSS&lt;/strong&gt; and &lt;strong&gt;JavaScript&lt;/strong&gt; are embedded for the modification of plugins and themes, considering the performance is more important as they would affect both the &lt;em&gt;First Content Paint&lt;/em&gt; and the &lt;em&gt;First Meaningful Paint&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PHP Scripting&lt;/strong&gt; requires more time for the initial configuration and codebases should be hard coded to communicate with the database. Besides, the logic which tells a browser what to do and how to do the tasks needs to be explicit. At the same time, PHP scripting generally allows have full control over a website in areas such as layout, styling, performance optimisation, website architecture and Search Engine Optimisation, etc. &lt;/p&gt;

&lt;p&gt;It would be fair to say that both &lt;strong&gt;WordPress&lt;/strong&gt; and &lt;strong&gt;PHP Scripting&lt;/strong&gt; have their advantages and disadvantages. Programming is about problem-solving and trade-offs. The best decision would be the most viable and achievable one within the given time, resources and knowledge as a developer. &lt;/p&gt;

&lt;p&gt;Hope you find this was helpful for you and why don't you crack on it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://localwp.com/"&gt;WordPress Local&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>wordpress</category>
      <category>php</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>JavaScript: demystifying  numbers</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Tue, 12 Jan 2021 17:43:01 +0000</pubDate>
      <link>https://dev.to/emilie/javascript-demystifying-numbers-l1k</link>
      <guid>https://dev.to/emilie/javascript-demystifying-numbers-l1k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This story contains the anecdote behind how I came across the quirkiness of JS number during the development of a personal finance app. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;As the application would grow and populate more numeric data, I came to wonder how commercial finance applications deal with fraction points of currencies. This question was derived from the multiple fraction point numbers after all the money values tallied up by JavaScript. When building a commercial application, this would be a prime discussion among developers, accountants and other stakeholders. As result of my lack of time and expertise in finance, I wasn’t sure how to approach to this issue and couldn’t conduct significant research. Considering this is a premature version of a personal finance app which doesn’t set out any rules in terms of any complex financial covenants, I just decided to keep it simple for now. Furthermore, the current implementation wouldn’t have a great effect on the actual monetisation of the users’ financial flow in a direct manner.&lt;/p&gt;

&lt;p&gt;Putting aside how to define the fraction numbers, the reason why the aggregated result from JavaScript returns the unexpected fraction numbers was investigated.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This would be an example of the quirkiness of JavaScript numbers. Wouldn't you expect the result would be 58.87 if you have learn the basic arithmetic from school unless you are a CS student or a well-versed developer? &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Axhn__zB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610462468862/tzkHBwW0I.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Axhn__zB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610462468862/tzkHBwW0I.png" alt="carbon.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I understand it, all computational processes run with binary code and representational data such as images, audio, characters and numbers which are stored as binary and are encoded in different formats to deliver their means. Specifically, JavaScript encodes all the numeric values with double precision floating point numbers(64 bit) following IEEE Standard. Even though we may expect the aggregate result from the example above to simply be 58.87, it returns all the fraction points by the nature of how JavaScript processes numeric value with double-precision floating point number. As such I decided to delve into this further to provide rationale and to advocate my decision regarding rounding up/down fraction numbers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bicZwiGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610472422302/Tt1W_PhLQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bicZwiGy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610472422302/Tt1W_PhLQ.jpeg" alt="alexander-sinn-YYUM2sNvnvU-unsplash.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@swimstaralex?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Alexander Sinn&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/binary?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  IEEE754 Double-Precision binary floating-point format : Binary64
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dYqKYw5m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610464013100/j_F6Ea3MI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dYqKYw5m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610464013100/j_F6Ea3MI.png" alt="image.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;[¹]  Significand precision is implicitly 53 bits. However, 1 bit is not stored since it goes through the normalisation and it always leads with value “1”. It’s called implicit bit, hidden bit and so on.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;JavaScript has adapted Double-Precision floating point format as its standard for numbers. As we can conjecture from its naming, this format provides a wider range of numbers and higher accuracy compared to single-precision or half-precision floating-point format. &lt;/p&gt;

&lt;p&gt;Specifically speaking, JavaScripts can process numbers in the range between &lt;code&gt;Number.MAX_SAFE_INTEGER(253 - 1)&lt;/code&gt; and &lt;code&gt;Number.MIN_SAFE_INTEGER(-(253 - 1))&lt;/code&gt; based on the binary 64 format. However, ECMAScript 2020 which was published in June 2020 updated their specification and it includes a new built-in object &lt;code&gt;BigInt&lt;/code&gt; which provides a larger number representation for JavaScript. &lt;/p&gt;

&lt;p&gt;Naturally this format takes up more memory and requires a better processor to perform this computation. During this research, I also learned how to convert binary to denary and vice versa. This was a very constructive learning in order to understand the quirkiness of JavaScript Number. As such I’d like to articulate how the denary number is converted to 64bit binary number under the hood.&lt;/p&gt;

&lt;h4&gt;
  
  
  Denary 19.25
&lt;/h4&gt;

&lt;p&gt;First, Convert the whole number 19 to binary : divide the number until the remainder is 0/1.&lt;br&gt;&lt;br&gt;
The Converted binary is &lt;strong&gt;10011&lt;/strong&gt;.    &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3GDb8Z70--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610464947324/peWS7OttM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3GDb8Z70--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610464947324/peWS7OttM.png" alt="carbon (1).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Read the remainders from bottom to top for the whole number.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Secondly, Convert the fraction number 0.25 to binary : multiply the fraction numbers by 2 until the value returns to 0.&lt;br&gt;&lt;br&gt;
The Converted binary is &lt;strong&gt;0.01&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tjP-CUoB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610465394098/GAs7yxVyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tjP-CUoB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610465394098/GAs7yxVyr.png" alt="carbon (2).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Read the decimal points from top to bottom at this time&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Thirdly, Combine the two parts of the number and Normalise for significand and unbiased exponent (move the binary point to after leftmost 1 or to the right where the first “1” value exists) : Once the binary numbers are normalised, the number of times we moved the decimal point to the leftmost 1[²]will be the exponent in the base 2 notation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10011.01 = 1.001101 × 2⁴&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;[²]  &lt;em&gt;If whole number conversion to binary starts with a decimal point, for example, 0.00110011, you need to move the decimal point to the right where the first “1” value is located. In this case, the result will be 1.10011 × 2⁻³&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Fourthly, Get the biased exponent based on precision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4 + 1023 = 1027₁₀ = 10000000011   ₂&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pu_1BxFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610467952544/AMxtuMfV1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pu_1BxFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610467952544/AMxtuMfV1.png" alt="carbon (4).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Read the remainders from bottom to top just like the first step we did.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JdR_JlpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610467985393/h0SkFjYX0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JdR_JlpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610467985393/h0SkFjYX0.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Fifthly, Determine the significand removing leading 1 from step 3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.001101&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--psMgdFAf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468088574/2qjknM9xb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--psMgdFAf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468088574/2qjknM9xb.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Finally, we have successfully converted Decimal number 19.25 to Binary64 format.&lt;/p&gt;

&lt;p&gt;Now, I will convert a 64bit binary to the denary value which is a simplified demonstration to show you how the computer processes this under the hood.&lt;/p&gt;

&lt;h4&gt;
  
  
  64bit binary
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cF9DBbay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468390780/RuDT0ZBR9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cF9DBbay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468390780/RuDT0ZBR9.png" alt="carbon (5).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For an easier explanation, refer to this table.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pqBz0mVI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468433253/dSJuSN9sV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pqBz0mVI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610468433253/dSJuSN9sV.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;e&lt;/em&gt; = 2¹⁰ + 2⁰ = 1024 + 1 = 1025₁₀&lt;br&gt;&lt;br&gt;
&lt;em&gt;p&lt;/em&gt; = &lt;em&gt;e&lt;/em&gt; - 1023 = 2&lt;/p&gt;

&lt;p&gt;&lt;em&gt;p indicates precision.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jl8HXaI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469172985/76aZH4lYw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jl8HXaI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469172985/76aZH4lYw.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first column indicates the &lt;em&gt;implicit significand value 1&lt;/em&gt; which is called &lt;em&gt;implicit bit[¹]&lt;/em&gt; and the value we get from the biased exponent subtracting the unbiased exponent denotes where the bit index starts from. If the exponent values are positive, move towards the right-hand side and if negative, move towards the left-hand side from the implicit bit as you can see on the table. Now, we have the denary value, 5. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;n&lt;/em&gt; =  2² + 2⁰ = 4 + 1 = 5&lt;/p&gt;

&lt;p&gt;If the number value is just an integer like in the example above, the calculation is straightforward. However, decimal is more complicated and it sometimes requires rounding up/down depending on the last value of significand.&lt;/p&gt;

&lt;h4&gt;
  
  
  64bit binary
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yUxg032J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469519705/zTQIEEmzM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yUxg032J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469519705/zTQIEEmzM.png" alt="carbon (6).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S23np7-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469555923/gnAqS1pfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S23np7-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610469555923/gnAqS1pfz.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;e&lt;/em&gt; =  2⁹ + 2⁸  + 2⁷ + 2⁶ + 2⁵ + 2⁴ + 2³ + 2² + 2⁰&lt;br&gt;&lt;br&gt;
   = 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 1&lt;br&gt;&lt;br&gt;
   = 1021₁₀&lt;br&gt;&lt;br&gt;
&lt;em&gt;p&lt;/em&gt; = &lt;em&gt;e&lt;/em&gt; - 1021 = -2&lt;/p&gt;

&lt;p&gt;&lt;em&gt;p indicates precision.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This time exponent value is negative. So, we need to move to the left hand side two times. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6ukMsX77--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610470175734/Zq5bvwno5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6ukMsX77--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610470175734/Zq5bvwno5.png" alt="image.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;purple cells denotes its repetitions of the pattern.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;n&lt;/em&gt; = 2⁻² + 2⁻⁵ + 2⁻⁶ + 2⁻⁹ + 2⁻¹⁰ + 2⁻¹³ + 2⁻¹⁴ + 2⁻¹⁷ + 2⁻¹⁸ + 2⁻²¹ 2⁻²² + 2⁻²⁵ + 2⁻²⁶ + 2⁻²⁹ + 2⁻³⁰ + 2⁻³³ + 2⁻³⁴ + 2⁻³⁷ + 2⁻³⁸ + 2⁻⁴¹ + 2⁻⁴² + 2⁻⁴⁵ + 2⁻⁴⁶ + 2⁻⁴⁹ + 2⁻⁵⁰ + 2⁻⁵³ + 2⁻⁵⁴&lt;br&gt;
   = - 0.3&lt;/p&gt;

&lt;p&gt;By the nature of binary and the larger bit binary deals with a wider range of fraction values for higher accuracy and precision, tallying-up the value of fraction point numbers by JavaScript returns quirky(?) values unlike we would expect. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>computerscience</category>
      <category>programming</category>
    </item>
    <item>
      <title>My Hustle-bustle with the full-stack development</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Fri, 18 Dec 2020 20:50:40 +0000</pubDate>
      <link>https://dev.to/emilie/my-hustle-bustle-with-the-full-stack-development-4424</link>
      <guid>https://dev.to/emilie/my-hustle-bustle-with-the-full-stack-development-4424</guid>
      <description>&lt;p&gt;Hello Devs!    &lt;/p&gt;

&lt;p&gt;I am going to write about my first ever full-stack app development story today. There are lots of things going on with me right now and I want to be honest about my experience so far. Anyone can glorify or gloss over their failure, however, I believe knowing my weakness and making mistakes is the best way to learn as a code newbie.&lt;/p&gt;

&lt;p&gt;What can you learn from reading this?&lt;br&gt;
You may gain general ideas about the development and a better insight before you start building an application or if you were considering developing a mobile application using Expo and Auth0, this would be a straightforward answer for your decision. My bottom line is that I am carrying lots of technical debts as a result of my lack of experience and expertise throughout the mobile application development.&lt;/p&gt;

&lt;p&gt;Moreover, I am not a Java, Kotlin nor Swift developer. You may have noticed that if you have ever read my blogs before. I am a JavaScript developer who started learning JS with my enthusiasm for web development and naturally learned React Native. To develop a fully functional native application on your own, I think you are either a seasoned native developer or a 10x ninja full stack developer(or a walking tech company). But, I'm proud of my failure and happy to see myself improving. :-)&lt;/p&gt;




&lt;p&gt;I have encountered the most nail-biting and tiring issue with the authorisation in conjunction with using the framework “Expo” and Auth0 since I started coding.&lt;/p&gt;

&lt;p&gt;The main reason I chose Expo is the same reason why many developers chose frameworks over native languages; It provides many benefits such as an easy configuration, ample dependencies which can substitute the native functionalities without actually using the native language, Java/Kotlin(for Android) and the developer community which can be useful when I face any issues during the development. Since Expo has a fairly big community for React Native developers, I thought it would be the right choice.&lt;/p&gt;

&lt;p&gt;My goal was to implement the authorisation code flow with PKCE(Proof Key for Code Exchange; called Pixy) which is the standard authentication method for the modern native applications and SPA(single page application)s. I initially wanted to add the minimum security layer on the backend for the databases which would be storing users' financial data. I underestimated the implication of the Pixy due to lack of my understanding. Even though this is not a commercial application, I wanted to simulate a real personal finance application-like feeling. I naively presumed that this wouldn't be much different from Role-based access control management. However, I have encountered two considerable impediments during the implementation of authorisation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XBXWPovN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8y6ryn8lsqkhiak70o5p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XBXWPovN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8y6ryn8lsqkhiak70o5p.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Discordance of the two tech stacks, Expo and Auth0
&lt;/h3&gt;

&lt;p&gt;I spent loads of time and effort trying to make the two tech stacks work, this was the most devious and dubious path I have gone through as a developer. As I only have a limited experience with Auth0 and I have seen a React Native example from its website, I made a hasty decision without knowing the implication in the practicality of the implementation.&lt;/p&gt;

&lt;p&gt;For any newbie developers who are still reading this far, let me explain to you about the Pixy first. An OAuth authorisation request should be performed through an external user-agent(such as the web browser) for the best practice in native applications and it also enables single sign-on for a better user experience.&lt;/p&gt;

&lt;p&gt;I am not a security expert, but, simply put, would an embedded user-agent be used, the app would retain valuable data, such as users’ credentials and OAuth authorisation grant. Those can be obtained by hackers or an imitated fraudulent application and it will be detrimental for all the users of the application. The best practice for calling APIs from a native application is to implement the Pixy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unfortunately, with much self-doubt as a limited-experienced developer, I was convinced that I was doing something incorrectly, but was not sure what was missing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;managed flow&lt;/code&gt; with Expo which was initially chosen by me, hoping for a manageable development experience, provides its proxy server &lt;code&gt;exp://auth.expo.io/@user_name/app_name&lt;/code&gt; which mitigates carrying a heavy load such as, the creation of a proxy server to deal with the redirect URI in order to receive the authorisation code from Auth0’s Authorisation server. &lt;/p&gt;

&lt;p&gt;To receive the authorisation code from the server, the client app should send &lt;code&gt;code_challenge&lt;/code&gt;, &lt;code&gt;code_verifier&lt;/code&gt; and &lt;code&gt;state&lt;/code&gt; to the server. I created all of them using Expo libraries such as expo-crypto, expo-random and some JavaScript codes. Expo offers the ‘AuthSession’ API to deal with authentication and authorisation. All I needed was to retrieve the authorisation code from the authorisation server. &lt;/p&gt;

&lt;p&gt;I tried most methods, class and examples which were provided by Expo and what other online blogger suggested. But, it was just all in vain. For some reasons, I couldn’t get the code as the Auth0 and Expo documentation state. This was the loophole of my authorisation experience as a developer. &lt;/p&gt;

&lt;p&gt;During that time, I discovered that my codes worked on a web browser(on the condition that I assigned the localhost on the login callback URL in Auth0 configuration and the browser returned the authorisation code successfully). This puzzled me and I started blaming Expo as it didn’t return the code only on the emulators. I also found other developers, from online forums, who alleged that AuthSession API seemed to be broken after a few updates and those claims convinced me that AuthSession was the issue. &lt;/p&gt;

&lt;p&gt;I eventually have even spoken to the Expo developers after I tagged &lt;code&gt;@expo&lt;/code&gt; on my twit. The developer I spoke to advised me kindly even though it was a Saturday evening. As I spoke to him, I kept trying what he suggested. Unfortunately, it didn’t work again. I was so frustrated, it was beyond any description. But, it led me to the final clue why it didn’t work on the emulators. &lt;/p&gt;

&lt;p&gt;Auth0 requires the extra &lt;code&gt;Login URI&lt;/code&gt; to be specified on its configuration page only for some native applications. This wasn’t clear throughout my development. There weren't enough resources about it. Moreover, because the &lt;code&gt;Auth0 Login URI scheme&lt;/code&gt; must start with &lt;code&gt;https://&lt;/code&gt;, it convinced me that Auth0 and Expo cannot be compatible since the Expo proxy server scheme is &lt;code&gt;expo://&lt;/code&gt;. This is not all, though. &lt;/p&gt;

&lt;h3&gt;
  
  
  Auth0 doesn’t support JavaScript for the native application
&lt;/h3&gt;

&lt;p&gt;The long story, in short, Auth0 doesn’t fully support JavaScript for the native applications. I should've known this. Until I found an Auth0’s engineer’s reply from its repository after a lot of research, I wasted too much time figuring out what was causing the issue without knowing it. This apparently becomes a technical debt for my assessment. &lt;/p&gt;

&lt;p&gt;If it is a commercial project, I would advise you to contact the authentication platform you have chosen to discuss the practicality and trade-offs before you make a firm decision or if you are in a team, you may already have an authentication expert. &lt;/p&gt;

&lt;p&gt;My first challenge to develop a native application on my own has not been a great success. However, you cannot achieve true success without failures. &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>mobile</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The most basic and essential GIT commands walkthrough</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Fri, 23 Oct 2020 23:42:50 +0000</pubDate>
      <link>https://dev.to/emilie/the-most-basic-and-essential-git-commands-walkthrough-1bie</link>
      <guid>https://dev.to/emilie/the-most-basic-and-essential-git-commands-walkthrough-1bie</guid>
      <description>&lt;p&gt;Hello Dev community Developers! &lt;br&gt;
I am coming back with GIT command lines. &lt;br&gt;
When you are working on a project whether on your own or with a team, GIT is a must you should acquire as a developer. &lt;br&gt;
If you just started learning web development or software development, I hope my blog will help you to get to good grips with it. &lt;/p&gt;

&lt;p&gt;GIT is a version control system which allows us work in more versatile and flexible ways when it comes to development. &lt;br&gt;
This may sound like an abstract analogy, but, personally I think GIT is a good comparison to train terminals, particularly British ones. &lt;/p&gt;

&lt;p&gt;Personally I don't like the train terminals and platforms. They are so confusing. Do not jump to the conclusion that you are on the right train. Ask attendants before you hop on if you are a lone traveller without much experience taking trains in a foreign country. haha&lt;/p&gt;

&lt;p&gt;When I got on a train from Liverpool to get back to London a long, long time ago (it was my second time to get on a train in the UK), I actually got on the wrong one, obviously from the wrong platform. When I realised that, I was panicking so much til I got a new ticket to London from the next stop. It was the most nerve-racking time in the middle of nowhere half way around world as a traveller. You may wonder how come she is talking about her train trip in the UK while we were meant to talk about GIT. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603485695966%2FQWODlSXkw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603485695966%2FQWODlSXkw.jpeg" alt="daniel-mingook-kim-Pd-bOA-MZQs-unsplash.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My point is that you may easily get lost with GIT like my train trip with a dozen platforms lined up. But, I think it is  absolutely fine. Especially, if you work in a big team, when you see so many branches, it is quite overwhelming. No worries, working with GIT is even easier and quicker than getting a new train ticket to London and find the right train again.&lt;/p&gt;

&lt;p&gt;One of the benefits of VCS is that it enables us to see what's going as a whole and even on each branch and to roll back in case of an error or if an emergency occurs. Each branch can have a completely different setup and by virtue of it, modern microservices in one repository is also possible. So, all developers keep themselves up-to-date with the whole work flow without checking multiple repositories. &lt;/p&gt;

&lt;p&gt;Let's say you just created a project &lt;code&gt;react-app&lt;/code&gt; directory locally and also remotely. Once you create a local one, in the &lt;code&gt;react-app&lt;/code&gt; directory, create a &lt;code&gt;.gitignore&lt;/code&gt; file and includes &lt;code&gt;node-modules&lt;/code&gt;, &lt;code&gt;env&lt;/code&gt; and &lt;code&gt;.DS_Store&lt;/code&gt; as default. Open the terminal and then move to the &lt;code&gt;react-app&lt;/code&gt; directory using unix command &lt;code&gt;cd&lt;/code&gt;(change directory). &lt;br&gt;
Finally it's time to use actual GIT command lines.&lt;/p&gt;
&lt;h2&gt;
  
  
  git init
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// to create an git repository
git init       
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486077830%2F5DFYMLWGs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486077830%2F5DFYMLWGs.png" alt="스크린샷 2020-10-23 21.47.53.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good job! you've just created a local repository.&lt;/p&gt;
&lt;h2&gt;
  
  
  git add
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// to add all the files(with full stop `.`) to the index
git add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486393556%2Frox3Beuh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486393556%2Frox3Beuh7.png" alt="스크린샷 2020-10-23 21.53.10.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now all the files in the &lt;code&gt;react-app&lt;/code&gt; directory are ready to commit. Until you actually commit it, you can make multiple changes in the directory and repeat the process over and over again without any record during this stage. The full stop &lt;code&gt;.&lt;/code&gt; is like a short-cut key that enable us to add all the files which have been changed.&lt;/p&gt;

&lt;p&gt;You have made a little change on a &lt;code&gt;README.md&lt;/code&gt; file in the directory or you have been working on multiple files and before you commit, you want to see what status you are in now. &lt;/p&gt;
&lt;h2&gt;
  
  
  git status
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// to see working tree status
 git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486988706%2FYT80Bd0wr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603486988706%2FYT80Bd0wr.png" alt="스크린샷 2020-10-23 22.03.05.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You see the &lt;code&gt;modified: README.md&lt;/code&gt; line with the red text on the terminal.&lt;br&gt;
OK, now time to add it again. &lt;br&gt;
Once you add the new &lt;code&gt;README.md&lt;/code&gt;, let's commit the whole directory.&lt;/p&gt;
&lt;h2&gt;
  
  
  git commit
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// to record changes to the repository 
git commit -m "write your commit messages"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603487495226%2FmjiDnpFkrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603487495226%2FmjiDnpFkrn.png" alt="스크린샷 2020-10-23 22.11.31.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Voila! &lt;br&gt;
It's a crucial part to leave a comment regarding the work you have done when you are part of a team. So, other members would be able to see what exactly you have worked on and explain others why you decided to write codes in a certain way, etc. &lt;/p&gt;

&lt;p&gt;Now let's push the local change to the remote github repository.&lt;br&gt;
As we haven't set the tracked repository, we should tell git which repository we want to track.&lt;/p&gt;
&lt;h2&gt;
  
  
  git remote
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin &amp;lt;your remote git repository HTTP/SSH&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I always create a remote repository with the same name as the local one. So, I have used &lt;code&gt;origin&lt;/code&gt;. Type &lt;code&gt;git remote&lt;/code&gt; and then you will see that the terminal returns &lt;code&gt;origin&lt;/code&gt; as the name of the remote repository. &lt;/p&gt;
&lt;h2&gt;
  
  
  git push
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push -u origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603488381389%2FvTiLw8mxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603488381389%2FvTiLw8mxl.png" alt="스크린샷 2020-10-23 22.26.17.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh my god!&lt;br&gt;&lt;br&gt;
We made it! the remote branch &lt;code&gt;master&lt;/code&gt; is now up-to-date with our local branch. These are the very basic steps of working with GIT. &lt;/p&gt;

&lt;p&gt;Shall we move onto creating a new branch?&lt;br&gt;
I think this is the most common way you would start when you take on a task. Make sure your local repository is always up-to-date with the remote one. You can easily do that with the git command line &lt;code&gt;git fetch&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  git branch &amp;amp; checkout
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch &amp;lt;new branch name&amp;gt;
git checkout &amp;lt;new branch name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603489232380%2FudluPLy-i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603489232380%2FudluPLy-i.png" alt="스크린샷 2020-10-23 22.40.27.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, now you've just created a new branch in order to work on a new task you're given and you also have checked out from master branch to the new testing branch. &lt;br&gt;
This is a very crucial part when you work with multiple people at the same time. &lt;/p&gt;

&lt;p&gt;Oh wait! &lt;br&gt;
Have you forgotten to create a branch and you've been coding away on a wrong branch? No worries, I have done that many times. haha&lt;/p&gt;
&lt;h2&gt;
  
  
  git stash
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash
git checkout &amp;lt;a branch you need to work on&amp;gt;
git stash apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603490257240%2FXXS4lHtO2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1603490257240%2FXXS4lHtO2.png" alt="스크린샷 2020-10-23 22.57.33.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ta-Da!&lt;br&gt;&lt;br&gt;
Magic just happened. All the changes you made in a wrong branch is stashed, the master branch is in the clean state and you applied the change to the right branch. &lt;/p&gt;
&lt;h2&gt;
  
  
  --set-upstream
&lt;/h2&gt;

&lt;p&gt;Now you have added the branch to the index, committed with a new message and finally push it to the remote repository.&lt;br&gt;
As the remote repository doesn't have the same branch yet,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push --set-upstrem origin &amp;lt;current new branch name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  git merge or rebase
&lt;/h2&gt;

&lt;p&gt;Brilliant!&lt;br&gt;&lt;br&gt;
Now you've decided to merge the branch to the master&lt;br&gt;&lt;br&gt;
as you've done an excellent job!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// you are still in the working branch directory
git merge master &amp;lt;the branch name you've completed&amp;gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command line is equivalent to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout master
git merge &amp;lt;the branch name you've completed&amp;gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait a sec!&lt;br&gt;&lt;br&gt;
It's not done yet. There is another option &lt;code&gt;rebase&lt;/code&gt;. &lt;br&gt;
When you use &lt;code&gt;merge&lt;/code&gt;, you will still have kept all the commit history from the branch you merged into the &lt;code&gt;master&lt;/code&gt;. Depending on the situation, all of these unnecessary commit histories on the &lt;code&gt;master&lt;/code&gt; branch could be seen to be cumbersome for all the other developers who have never worked on the task. In this kind of case, it would be better to use &lt;code&gt;rebase&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout master
git rebase &amp;lt;the branch name you've completed&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;rebase&lt;/code&gt; creates a new commit point. &lt;br&gt;
As irrelevant and trivial commit histories are no longer in the master history, the whole team can easily track down the commit history.&lt;/p&gt;

&lt;p&gt;But, this is just an example I am referring to. What is best for you and your team is up to you.&lt;/p&gt;

&lt;p&gt;There are numerous git command lines such as &lt;code&gt;revert&lt;/code&gt;, &lt;code&gt;reset&lt;/code&gt; and  &lt;code&gt;cherry-pick&lt;/code&gt; and so on. However, once you get used to all of these basic git command lines, you will be able to wrap your head around why you would need to use others in  certain cases.  If you are not 100% comfortable with git, I would recommend you use GIT GUI together. Thank you for reading again and please like my blog if you enjoyed this!&lt;br&gt;
See you next time!&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@timmybech?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Tim Bechervaise&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/terminal-platform?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;br&gt;
&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@danielmingookkim?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Daniel Mingook Kim&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/confused?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/GOUNSHIN1?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;Follow me on Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>git</category>
    </item>
    <item>
      <title>Demystifying DB-API</title>
      <dc:creator>Emilie</dc:creator>
      <pubDate>Tue, 20 Oct 2020 10:55:05 +0000</pubDate>
      <link>https://dev.to/emilie/demystifying-db-api-4nm</link>
      <guid>https://dev.to/emilie/demystifying-db-api-4nm</guid>
      <description>&lt;p&gt;&lt;strong&gt;DB-API&lt;/strong&gt; is an acronym of DataBase Application Programming Interface and a library which lets python connect to the database server. Depending on which relational DB library you use, they have their own DB-API modules.&lt;br&gt;
Similar to the Web APIs we mostly deal with as developers, it is a computing interface specifically for databases between server-side and database and it enables us to communicate with a database using certain protocols such as TCP/IP.&lt;/p&gt;

&lt;p&gt;When we work on a client-side web application, we often pull the data from web APIs to display them to end-users and if end-users modify/upload existing/new data, we need to make sure the CRUD operation is invoked accordingly. This client-server model is applied to many modern-day systems to interact with servers. Simply put, databases are the same, interacted with using client-server interaction over a network. When an end-user makes a request, a browser will do the same to the web server and at that point, the web server becomes a client which makes a request to the database which acts as a server to fulfil the request.&lt;/p&gt;

&lt;p&gt;When we talk about the data and transferring data over the network, the two main protocols, TCP and IP are involved. They use IP address and Ports number. Since they are connection-based protocols, we always have to establish a connection from DB-API to database server over TCP/IP. In other words, we need to explicitly start a session for the connection and end the connection for a session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# DB-API for PostgreSQL 
import psycopg2 

connection = psycopg2.connect('dbname=test')
......
connection.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In each database session, there are many transactions that can occur. The session enables us to control each transaction like git. Just imagine you made your code change for your task on a new branch and add the branch before committing and pushing it to the stage. But, if a senior developer found a bug, you may end up reverting it so to speak.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transaction.add('CREATE TABLE coffee (
    id INTEGER PRIMARY KEY,
    item STRING NOT NULL') ;
)
transaction.add('''
    INSERT INTO coffee (id, item) VALUES (%(id)s, %(item)s);',
    { 'id': 1, 'item': 'Cafe Latte' }
''')

transaction.commit()
transaction.rollback()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are familiar with git command lines, as I explained above, this may help you reach enlightenment for the database transaction. It's intuitive and as the database sometimes can fail, we can roll back to a previous point before the change was made.&lt;/p&gt;

&lt;p&gt;Each transaction is an atomic unit of work to access the database and it lets us read and write data. There are 4 characteristics to make the database more maintainable and reliable: Atomicity, Consistency, Isolation and Durability. Just like git, each transaction of database operation should meet these properties in order to prevent any errors from concurrent executions, power failure and so on.&lt;/p&gt;

&lt;p&gt;I hope my explanation for DB-API helps you to understand not only the DB-API but also, the general idea of databases and APIs as well. Thank you for reading and I hope you enjoy learning web development!&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Markus Spiske&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/data?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>postgres</category>
      <category>database</category>
      <category>python</category>
    </item>
  </channel>
</rss>
