<?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: Jazsmith24</title>
    <description>The latest articles on DEV Community by Jazsmith24 (@jazsmith24).</description>
    <link>https://dev.to/jazsmith24</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%2F419280%2F6e9a1a74-a755-41f7-a6f3-3bd0acb1a7f5.jpeg</url>
      <title>DEV Community: Jazsmith24</title>
      <link>https://dev.to/jazsmith24</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jazsmith24"/>
    <language>en</language>
    <item>
      <title>End-to-End Encryption</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Tue, 15 Sep 2020 14:24:12 +0000</pubDate>
      <link>https://dev.to/jazsmith24/end-to-end-encryption-3bje</link>
      <guid>https://dev.to/jazsmith24/end-to-end-encryption-3bje</guid>
      <description>&lt;p&gt;In technology culture, social media has been a staple of the online world. You have the ability to interact with millions of people at the touch of your fingertips. When communicating with your worldwide buddies, you may wonder how your messages are only sending a person without everyone else online having access to these private messages. This is due to encryption. In this article, I will define what end-to-end encryption means and how to implement this encryption method. &lt;/p&gt;

&lt;p&gt;End-to-end encryption is a secure line of communication that blocks third-party users from accessing transferred data. When the data is being transferred online, only the sender and recipient can decrypt it with a key. End-to-end encryption can help protect the contents of your messages, text, and even files from being understood by anyone except their intended recipients. It can also be used to prove that a message came from a particular person and has not been altered. &lt;/p&gt;

&lt;p&gt;With end-to-end encryption, you decide what data you want to encrypt. This could include chat messages, files, photos, sensory data on IoT devices, permanent or temporary data. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How does End-to-End Encryption Work?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;End-to-end encryption scrambles messages in such a way that they can be deciphered only by the sender and the intended recipient. As the label implies, end-to-end encryption takes place on either end of a communication. A message is encrypted on a sender’s device, sent to the recipient’s device in an unreadable format, then decoded for the recipient.&lt;/p&gt;

&lt;p&gt;There are several ways to do encrypt this way, but the most popular works like this: A program on your device mathematically generates two cryptographic keys — a public key and a private key.&lt;/p&gt;

&lt;p&gt;You can share a public key with anyone who wants to encrypt a message to you. The private key, or secret key, decrypts messages sent to you and never leaves your device. You can liken this to a locked mailbox. Anyone with a public key can put something in your box and lock it, but only you have the private key to unlock it.&lt;/p&gt;

&lt;p&gt;A more common form of encryption, known as transport layer encryption, relies on a third party, like a tech company, to encrypt messages as they move across the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Implementation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this example, you might want to keep benign information related to a chat app (like timestamps) in plaintext but end-to-end encrypt the message content.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Every user has a private &amp;amp; public key which the SDK will generate on your users’ device at signup or next time they log in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The user’s public key is published to Virgil’s REST-based key management service for users to find each other’s public keys and be able to encrypt data to each other.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The user’s private key remains on the user’s device, protected by the operating system’s native key store:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;EThree&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@virgilsecurity/e3kit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Fetch Virgil JWT token from Firebase function&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetchToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{...}&lt;/span&gt;

&lt;span class="c1"&gt;// Log in Firebase user on client device&lt;/span&gt;
&lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;signInWithEmailAndPassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Once Firebase user authenticated, bootstrap e3kit to load user's private key&lt;/span&gt;
&lt;span class="nx"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;onAuthStateChanged&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// Initialize e3kit&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;eThree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;EThree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fetchToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Bootstrap user (i.e. load user's private key)&lt;/span&gt;
    &lt;span class="nx"&gt;eThree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pwd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// User private key loaded, ready to end-to-end encrypt!&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// No user signed in.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Before sending a chat message or sharing a document, the app encrypts the contents using the recipient’s public key (client-side).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;usersToEncryptTo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alice@myapp.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bob@myapp.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sofia@myapp.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Lookup destination user public keys&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chatRoomParticipants&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;eThree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lookupKeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;usersToEncryptTo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Encrypt message using target user public keys&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encryptedMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;eThree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello there!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chatRoomParticipants&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After receiving a message, the app decrypts it using the recipient user’s private key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Decrypt message from the chat room&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;decryptedMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;eThree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;encryptedMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chatRoomParticipants&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This technique ensures that only end-users can see messages. The plaintext data won’t be visible to Firebase, to developers at your company, or to clients that the message wasn't intended for. If you’re building a chat feature or app, you’ll be able to build professional-quality end-to-end encrypted chat. You can also build an end-to-end encrypted IoT product or team collaboration suite, or use end-to-end encryption for any use case to protect your users’ data.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;br&gt;
&lt;a href="https://ssd.eff.org/en/module/deep-dive-end-end-encryption-how-do-public-key-encryption-systems-work"&gt;https://ssd.eff.org/en/module/deep-dive-end-end-encryption-how-do-public-key-encryption-systems-work&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.nytimes.com/2019/11/19/technology/end-to-end-encryption.html#:%7E:text=End%2Dto%2Dend%20encryption%20scrambles,sender%20and%20the%20intended%20recipient.&amp;amp;text=A%20message%20is%20encrypted%20on,Unlock%20more%20free%20articles"&gt;https://www.nytimes.com/2019/11/19/technology/end-to-end-encryption.html#:~:text=End%2Dto%2Dend%20encryption%20scrambles,sender%20and%20the%20intended%20recipient.&amp;amp;text=A%20message%20is%20encrypted%20on,Unlock%20more%20free%20articles&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://virgilsecurity.com/blog/simplified-firebase-sdk"&gt;https://virgilsecurity.com/blog/simplified-firebase-sdk&lt;/a&gt;&lt;/p&gt;

</description>
      <category>encrypytion</category>
    </item>
    <item>
      <title>Currying in Javascript</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Tue, 08 Sep 2020 14:10:19 +0000</pubDate>
      <link>https://dev.to/jazsmith24/currying-in-javascript-10fi</link>
      <guid>https://dev.to/jazsmith24/currying-in-javascript-10fi</guid>
      <description>&lt;p&gt;In functional programming, having the ability to pass and return functions, brought on concepts such as Higher-order functions, pure functions, and currying. In this article, we will see how currying works and how it will be useful in our work as software developers.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;What is currying?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Currying is the process where a function takes multiple arguments one at a time.  Currying translates a function from callable as f(a, b, c) into callable as f(a)(b)(c). A curried function returns a new function that expects the next argument inline. &lt;/p&gt;

&lt;p&gt;Currying lets you have light and clean looking functions. It also allows you to compose the sequence of your functions. It ensures that the particular sequence of calls is enforced and followed. The final output is only returned when all the dependencies have been passed through. The arguments are kept "alive" with closures and all are used in execution when the final function in the currying chain is returned and executed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How would you use currying in your code?
&lt;/h2&gt;

&lt;p&gt;Currying works by closures. The closure created by the nested functions retains access to each of the arguments. So inner function has access to all arguments.&lt;/p&gt;

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

&lt;p&gt;Let’s look at a simple add function. It accepts three operands as arguments and returns the sum of all three as the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can call it with too few (with odd results), or too many (excess arguments get ignored).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; 
&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;NaN&lt;/span&gt;
&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="c1"&gt;//Extra parameters will be ignored.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example 2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;hello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;morning&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Good morning&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Austin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// returns Hello Austin&lt;/span&gt;
&lt;span class="nx"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Roy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// returns Hello Roy&lt;/span&gt;
&lt;span class="nx"&gt;morning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Austin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// returns Good morning Austin&lt;/span&gt;
&lt;span class="nx"&gt;morning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Roy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//returns Good Morning Roy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The two functions created from greeting (hello and morning) each return functions that process the provided inputs to generate a greeting statement. They also take an argument which is the name of the person to be greeted.&lt;/p&gt;

&lt;p&gt;In the above case, the greeting is also used as a function factory with the two functions hello and morning generated from it.&lt;/p&gt;

&lt;p&gt;The inner function may also be called invoked after the first call as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello There&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;General Kenobi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;//returns Hello There General Kenobi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Why it’s useful?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Currying helps you to avoid passing the same variable again and again.&lt;/li&gt;
&lt;li&gt;It helps to create a higher-order function. It is extremely helpful in event handling.&lt;/li&gt;
&lt;li&gt;Little pieces can be configured and reused with ease.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://javascript.info/currying-partials"&gt;https://javascript.info/currying-partials&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339"&gt;https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/@kbrainwave/currying-in-javascript-ce6da2d324fe"&gt;https://medium.com/@kbrainwave/currying-in-javascript-ce6da2d324fe&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codeburst.io/currying-in-javascript-ba51eb9778dc"&gt;https://codeburst.io/currying-in-javascript-ba51eb9778dc&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-closures-and-currying-in-javascript#what-is-currying"&gt;https://www.digitalocean.com/community/tutorials/an-introduction-to-closures-and-currying-in-javascript#what-is-currying&lt;/a&gt;&lt;/p&gt;

</description>
      <category>currying</category>
    </item>
    <item>
      <title>Javascript Design patterns: Flyweight Pattern</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Fri, 04 Sep 2020 13:45:02 +0000</pubDate>
      <link>https://dev.to/jazsmith24/javascript-design-patterns-flyweight-pattern-1g5g</link>
      <guid>https://dev.to/jazsmith24/javascript-design-patterns-flyweight-pattern-1g5g</guid>
      <description>&lt;p&gt;The flyweight pattern is one of the structural design patterns. This pattern provides ways to decrease object count thus improving application required objects structure. It aims to minimize the use of memory in an application by sharing as much data as possible with related objects. One important feature of flyweight objects is that they are immutable. This means that they cannot be modified once they have been constructed.&lt;/p&gt;

&lt;p&gt;Each "flyweight" object is divided into two pieces: the state-dependent (extrinsic) part, and the state-independent (intrinsic) part. The intrinsic state is stored (shared) in the Flyweight object. The extrinsic state is stored or computed by client objects and passed to the Flyweight when its operations are invoked.&lt;/p&gt;

&lt;p&gt;Intrinsic information may be required by methods on our objects, which they absolutely cannot function without. Extrinsic information can be removed and stored externally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does the flyweight pattern store values?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the Flyweight pattern, we use a HashTable that stores reference to the object which has already been created, every object is associated with a key. HashTables are data structures that store data in an array-like format, using key/value pairs, where the (hashed) key corresponds to the index in the array. HashTables offer the same key/value functionality and come native in JavaScript in the form of the map() object. &lt;/p&gt;

&lt;p&gt;Now when a client wants to create an object, he simply has to pass a key associated with it. If the object has already been created we simply get the reference to that object else it creates a new object and then returns its reference to the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Flyweight uses sharing to support large numbers of objects efficiently. Modern web browsers use this technique to prevent loading the same images twice. When a browser loads a web page, it traverses through all images on that page. The browser loads all-new images from the Internet and places them on the internal cache. For already loaded images, a flyweight object is created, which has some unique data like position within the page, but everything else is referenced to the cached one.&lt;/p&gt;

&lt;p&gt;Let's take a look at an example from Addy Osmani's "Learning JavaScript Design Patterns" book which is about implementing a system to manage all of the books in a library.&lt;/p&gt;

&lt;p&gt;The vital meta-data for each book could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ID&lt;/li&gt;
&lt;li&gt;Title&lt;/li&gt;
&lt;li&gt;Author&lt;/li&gt;
&lt;li&gt;Genre&lt;/li&gt;
&lt;li&gt;Page count&lt;/li&gt;
&lt;li&gt;Publisher ID&lt;/li&gt;
&lt;li&gt;ISBN&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll have the following properties to keep track of which member has checked out a particular book, the date they've checked it out on as well as the expected date of return:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;checkoutDate&lt;/li&gt;
&lt;li&gt;checkoutMember&lt;/li&gt;
&lt;li&gt;dueReturnDate&lt;/li&gt;
&lt;li&gt;availability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before any optimization using the Flyweight pattern, each book would be represented as follows:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;prior flyweight&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;publisherID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;ISBN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;checkoutDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;checkoutMember&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;dueReturnDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;availability&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pageCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publisherID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;publisherID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ISBN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ISBN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;checkoutDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutMember&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;checkoutMember&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dueReturnDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dueReturnDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;availability&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;availability&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;getTitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;getAuthor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;getISBN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ISBN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// For brevity, other getters are not shown&lt;/span&gt;
  &lt;span class="na"&gt;updateCheckoutStatus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;bookID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;newStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;checkoutDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;checkoutMember&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;newReturnDate&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;availability&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newStatus&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;checkoutDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutMember&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;checkoutMember&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dueReturnDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newReturnDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;extendCheckoutPeriod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bookID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newReturnDate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dueReturnDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newReturnDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;isPastDue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bookID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;currentDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;currentDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dueReturnDate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Using thousands of book objects may overwhelm the available memory, but we can optimize our system using the Flyweight pattern to improve this.&lt;/p&gt;

&lt;p&gt;We can now separate our data into intrinsic and extrinsic states as follows: data relevant to the book object (title, author, etc.) is intrinsic while the checkout data (checkoutMember, dueReturnDate, etc.) is considered extrinsic.&lt;/p&gt;

&lt;p&gt;Effectively this means that only one Book object is required for each combination of book properties. It's still a considerable quantity of objects, but significantly fewer than we had previously.&lt;/p&gt;

&lt;p&gt;The following single instance of our book meta-data combinations will be shared among all of the copies of a book with a particular title.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;post flyweight&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Flyweight optimized version&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;publisherID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ISBN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genre&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pageCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pageCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publisherID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;publisherID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ISBN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ISBN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The extrinsic states have been removed. Everything to do with library check-outs will be moved to a manager, and as the object data is now segmented, a factory can be used for instantiation.&lt;/p&gt;

&lt;p&gt;Essentially Flyweight is an 'object normalization technique' in which common properties are factored out into shared flyweight objects. (Note: the idea is similar to data model normalization, a process in which the modeler attempts to minimize redundancy).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's an advantage and a disadvantage of the flyweight pattern?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantage:&lt;/strong&gt; Flyweights may introduce run-time costs associated with transferring, finding, and/or computing extrinsic state, especially if it was formerly stored as an intrinsic state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages*:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Space savings, which increase as more flyweights are shared. * Saves a lot of Megabytes.&lt;/li&gt;
&lt;li&gt;Facing memory constraints and get thousands of similar objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/flyweight-design-pattern/"&gt;https://www.geeksforgeeks.org/flyweight-design-pattern/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://anasshekhamis.com/2017/11/16/flyweight-design-pattern-in-javascript/"&gt;https://anasshekhamis.com/2017/11/16/flyweight-design-pattern-in-javascript/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.dofactory.com/javascript/design-patterns/flyweight#:%7E:text=Essentially%20Flyweight%20is%20an%20'object,out%20into%20shared%20flyweight%20objects.&amp;amp;text=An%20example%20of%20the%20Flyweight,are%20shared%20across%20the%20application"&gt;https://www.dofactory.com/javascript/design-patterns/flyweight#:~:text=Essentially%20Flyweight%20is%20an%20'object,out%20into%20shared%20flyweight%20objects.&amp;amp;text=An%20example%20of%20the%20Flyweight,are%20shared%20across%20the%20application&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>flyweightpattern</category>
    </item>
    <item>
      <title>What is a Relational Database?</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Thu, 27 Aug 2020 04:31:52 +0000</pubDate>
      <link>https://dev.to/jazsmith24/what-is-a-relational-database-3kf8</link>
      <guid>https://dev.to/jazsmith24/what-is-a-relational-database-3kf8</guid>
      <description>&lt;p&gt;A database is a very useful tool in development. It gives a developer the ability to not only have a sense of data persistence within an application but is also efficient for space in memory. There are different ways a database can be framed. One way to frame a database is non-relational, on the other hand, one would use a relational database. In this article, I will dive deeper into relational databases.&lt;/p&gt;

&lt;p&gt;In the early years of databases, every application stored data in its unique structure. When developers wanted to build apps to use the data, they had to know a lot about the particular data structure to find the data they needed. These structures were inefficient and hard to optimize for delivering good application performance. This is why the relational database model was introduced. The relational database model was designed to solve the problem of multiple arbitrary data structures.&lt;/p&gt;

&lt;p&gt;A relational database is a type of database that stores and provides access to data points that are related to one another. An example of a relational database is the use of schemas. &lt;/p&gt;

&lt;p&gt;In psychology and cognitive science, a schema describes a pattern of thought or behavior that organizes categories of information and the relationships among them.&lt;br&gt;
Similarly, in programming, a schema is the organization or structure for a database. The term seems to refer to a visualization of a structure and sometimes to a formal text-oriented description.&lt;/p&gt;

&lt;p&gt;In the early years of databases, every application stored data in its unique structure. When developers wanted to build applications to use that data, they had to know a lot about the particular data structure to find the data they needed. These data structures were inefficient, hard to maintain, and hard to optimize for delivering good application performance. The relational database model was designed to solve the problem of multiple arbitrary data structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schema Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A relational database presents data sets as a collection of tables and provides relational operators to manipulate the data in tabular form. Each row in the table is a record with a unique ID called the key. The columns of the table hold attributes of the data, and each record usually has a value for each attribute, making it easy to establish the relationships among data points.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Schema Example&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy63cjc46k946a0e25zlt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy63cjc46k946a0e25zlt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the benefits of a relational database?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The main advantage of relational databases is that they enable users to easily categorize and store data that can later be queried and filtered to extract specific information for reports. Relational databases are also easy to extend and aren't reliant on a physical organization.&lt;br&gt;
A relational database can be considered for any information need in which data points relate to each other and must be managed in a secure, rules-based, consistent way.&lt;/p&gt;

&lt;p&gt;Relational databases give a developer the ability to do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Removes redundant data through normalization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Standard mature tools to be used for development, design, performance measurement, and management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to deal with larger datasets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to identify and utilize relationships inherent in the datasets, and more readily share data with other relational databases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main advantage of a relational database is its formally described, tabular structure, from which data can be easily stored, categorized, queried, and filtered without needing to reorganize database tables. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.oracle.com/in/database/what-is-a-relational-database/" rel="noopener noreferrer"&gt;https://www.oracle.com/in/database/what-is-a-relational-database/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.omnisci.com/technical-glossary/relational-database" rel="noopener noreferrer"&gt;https://www.omnisci.com/technical-glossary/relational-database&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>relationaldatabase</category>
    </item>
    <item>
      <title>What is a Hybrid App?</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Mon, 27 Jul 2020 13:54:10 +0000</pubDate>
      <link>https://dev.to/jazsmith24/what-is-a-hybrid-app-27mh</link>
      <guid>https://dev.to/jazsmith24/what-is-a-hybrid-app-27mh</guid>
      <description>&lt;p&gt;A hybrid mobile application development looks appealing to an organization. Why hire a developer for each platform when you can hire one developer and target all of them through HTML, CSS, and JavaScript?  In this article, I will give an introduction to &lt;em&gt;hybrid web apps&lt;/em&gt; along with some examples of a Hybrid application.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is a Hybrid Application?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Hybrid mobile apps are applications that are installed on a device, just like any other app. Hybrid apps are built with a combination of HTML, CSS, and Javascript. Hybrid apps are part native app, part web app. Like native apps, they live in an app store and can take advantage of some device features available. Like web apps, they rely on HTML being rendered in a browser, with the caveat that the browser is embedded within the app.&lt;/p&gt;

&lt;p&gt;Hybrid apps are deployed in a native container that uses a mobile WebView object. When the app is used, this object displays web content thanks to the use of web technologies (CSS, JavaScript, HTML, HTML5).&lt;/p&gt;

&lt;p&gt;It is in fact displaying web pages from a desktop website that are adapted to a WebView display. The web content can either be displayed as soon as the app is opened or for certain parts of the app only i.e. for the purchase funnel.&lt;/p&gt;

&lt;p&gt;In order to access a device's hardware features (accelerometer, camera, contacts…) for which the native apps are installed, it is possible to include native elements of each platform’s user interfaces (iOS, Android): native code will be used to access the specific features in order to create a seamless user experience. Hybrid apps can also rely on platforms that offer JavaScript APIs if those functionalities are called within a WebView.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Hybrid Application Examples&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fexvl11rp2xq3iidm52d3.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fexvl11rp2xq3iidm52d3.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to check app type&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We can write our hybrid apps using HTML, CSS, and JS and wrap it in a wrapper (android/ios), sometimes using Phonegap. Writing a &lt;a href="https://build.phonegap.com/" rel="noopener noreferrer"&gt;Phonegap&lt;/a&gt; app with HTML and JavaScript gives you the ability to deploy it to any mobile device without losing features of a native app.&lt;/p&gt;

&lt;p&gt;Adobe PhoneGap is a standards-based, open-source development framework for building cross-platform mobile apps with HTML, CSS and JavaScript for iOS, Android™ and Windows® Phone 8.&lt;/p&gt;

&lt;p&gt;Is there a way to identify through jQuery or plain javascript, whether the loaded thing is a Hybrid App or a Mobile app? &lt;br&gt;
When you make a hybrid app, the HTML files loaded into a web view has a file:/// protocol and for a hosted application it is http or https. So you can check whether the app is by the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;web&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hybrid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isApp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// PhoneGap application&lt;/span&gt;
      &lt;span class="c1"&gt;//alert("U're using cordova");&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;//alert("U're using browser");&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Hybrid Application Benefits&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Often, companies build hybrid apps as wrappers for an existing web page; in that way, they hope to get a presence in the app store, without spending significant effort for developing a different app. Hybrid apps are also popular because they allow cross-platform development and thus significantly reduce development costs: that is, the same HTML code components can be reused on different mobile operating systems.&lt;/p&gt;

&lt;p&gt;Hybrid apps offer a certain number of advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Combining user experience with an agile development cycle and controlled costs&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reusing the code of the web app part:&lt;/strong&gt; the code is written once and deployed across all mobile platforms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reducing development time and costs:&lt;/strong&gt; the code is written once, which substantially reduces development time and costs compared to native apps which require development for iOS and development for Android.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoid the limitations of the Apple App Store&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Finding resources&lt;/strong&gt;: most applications have an iOS version and an Android version. They are thus developed using the corresponding programming language: Objective-C or Swift for iOS, Java for Android. Hybrid apps allow for the use of programming languages used frequently by web developers (HTML, JavaScript, and CSS) who can thus reuse their knowledge. This makes finding resources to build a hybrid app easier.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.telerik.com/blogs/what-is-a-hybrid-mobile-app-" rel="noopener noreferrer"&gt;https://www.telerik.com/blogs/what-is-a-hybrid-mobile-app-&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.app-press.com/blog/web-app-vs-native-app" rel="noopener noreferrer"&gt;https://www.app-press.com/blog/web-app-vs-native-app&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www2.stardust-testing.com/en/blog-en/hybrid-apps#:%7E:text=Hybrid%20mobile%20apps%20are%20applications,just%20like%20any%20other%20app.&amp;amp;text=Hybrid%20apps%20are%20deployed%20in,JavaScript%2C%20HTML%2C%20HTML5" rel="noopener noreferrer"&gt;https://www2.stardust-testing.com/en/blog-en/hybrid-apps#:~:text=Hybrid%20mobile%20apps%20are%20applications,just%20like%20any%20other%20app.&amp;amp;text=Hybrid%20apps%20are%20deployed%20in,JavaScript%2C%20HTML%2C%20HTML5&lt;/a&gt;).&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/12067372/differentiate-hybrid-app-or-web-app" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/12067372/differentiate-hybrid-app-or-web-app&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Intro to Progressive Web Apps </title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Thu, 23 Jul 2020 06:12:55 +0000</pubDate>
      <link>https://dev.to/jazsmith24/intro-to-progressive-web-apps-4oil</link>
      <guid>https://dev.to/jazsmith24/intro-to-progressive-web-apps-4oil</guid>
      <description>&lt;p&gt;With progressive web apps (PWAs), developers have another opportunity to optimize the quality of their user experience. In this article, we will define PWA, and I will expound on how PWA's are a little more user friendly than native apps. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is a PWA?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A PWA employs service workers to manage requests, catching shell data in a cache. &lt;strong&gt;Service workers&lt;/strong&gt; are scripts a browser will run in a separate browser thread. The service worker intercepts network requests, responsible for caching or retrieving resources from the cache, and delivering push notifications. &lt;/p&gt;

&lt;p&gt;Because workers run separately from the main thread, service workers are independent of the application they are associated with. This has several consequences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Because the service worker is not blocking (it's designed to be fully asynchronous) synchronous XHR and localStorage cannot be used in a service worker.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The service worker can receive push messages from a server when the app is not active. This lets your app show push notifications to the user, even when it is not open in the browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PWA is an ultra optimized website for mobile. It's able to use features of the users' devices, such as the camera. Users can access a progressive web app from their browser - chrome, firefox, etc - and download its' content as you're browsing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.creativebloq.com/how-to/build-a-progressive-web-app"&gt;How to create a Progressive Web App&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Progressive Web app Examples&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;For example, Tinder found that implementing its PWA halved the loading time when compared to the native app and decreased its' storage size. It also saw improved session times with PWA and increased engagement for both swipes and messages. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8SvuF6u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ssuyu1qcqkognhxw8icu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z8SvuF6u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ssuyu1qcqkognhxw8icu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Similarly, Pinterest users spend 40% more time on the company’s PWA than on their mobile website, with a core engagement increase of 60%.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Progressive Web App Benefits&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

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

&lt;p&gt;A &lt;em&gt;progressive web app&lt;/em&gt; serves webpages in a users' browser, this way the user can access a mobile app with ease. Using a PWA has a few benefits that native apps do not.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Speed
&lt;/h3&gt;

&lt;p&gt;It saves time and money since it is only developed once, while a native app requires two separate developments, one for IOS and one for Android.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. User experience
&lt;/h3&gt;

&lt;p&gt;It gives you the ability to access content much faster directly via the URL which uses less storage. It requires no download, so the PWA only uses a small portion of the phones' memory.   &lt;/p&gt;

&lt;h3&gt;
  
  
  3. Online visibility
&lt;/h3&gt;

&lt;p&gt;PWAs still have greater visibility due to the nature of their build. Because PWAs are made up of app-imitating web pages, users can find your app online — not just in the app store. This allows you to utilize SEO in order to reach valuable users in a cost-effective manner. It also means users can share the URL of any app page with ease, increasing the opportunities for organic growth and engagement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Progressive Web App Disadvantages&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Internet Connection requirement
&lt;/h3&gt;

&lt;p&gt;You must have an internet connection in all of your exhibition spaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Support Problems
&lt;/h3&gt;

&lt;p&gt;They're not perfectly supported by all browsers.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. No Access to native apps
&lt;/h3&gt;

&lt;p&gt;The biggest downfall to PWAs is that they don’t have access to all of your system resources, meaning that a native app may still be required. This is only something that you need to consider, though, if you actually need to make use of the native device features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;sources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://hackernoon.com/what-is-the-difference-between-web-apps-native-apps-hybrid-apps-and-progressive-web-apps-py19n2gdi"&gt;https://hackernoon.com/what-is-the-difference-between-web-apps-native-apps-hybrid-apps-and-progressive-web-apps-py19n2gdi&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/inside-smartapps/native-application-vs-progressive-web-app-which-one-should-you-choose-5eeaaf6ee92d"&gt;https://medium.com/inside-smartapps/native-application-vs-progressive-web-app-which-one-should-you-choose-5eeaaf6ee92d&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.adjust.com/blog/native-app-vs-progressive-web-app/"&gt;https://www.adjust.com/blog/native-app-vs-progressive-web-app/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.creativebloq.com/how-to/build-a-progressive-web-app"&gt;https://www.creativebloq.com/how-to/build-a-progressive-web-app&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>progressivewebapps</category>
    </item>
    <item>
      <title>Node Package Manager (NPM)</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Mon, 13 Jul 2020 13:46:17 +0000</pubDate>
      <link>https://dev.to/jazsmith24/node-package-manager-npm-163c</link>
      <guid>https://dev.to/jazsmith24/node-package-manager-npm-163c</guid>
      <description>&lt;p&gt;In this article, I will be discussing the node package manager (NPM). We'll go over what exactly is NPM, what are its' components, how to install, and its' use cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is NPM?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NPM is a package manager for the javascript programming language. As the world's largest software registry, it is the default package manager for the javascript runtime environment, Node.js. Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. NPM is a tool that allows you to install javascript packages.&lt;/p&gt;

&lt;p&gt;The name npm (Node Package Manager) stems from when npm first was created as a package manager for Node.js. All npm packages are defined in files called package.json. The content of package.json must be written in JSON. At least two fields must be present in the definition file which is the name and version of a package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NPM has three components. These components consist of the npm &lt;em&gt;website&lt;/em&gt;, the &lt;em&gt;Command Line Interface (CLI)&lt;/em&gt;, and an online database of public and private packages called the &lt;em&gt;npm registry&lt;/em&gt;. Each of these components possesses its role in the world of NPM. What are these roles? To discover packages, set up profiles, and to manage other aspects of your npm experience, you would use the website. The command-line interface runs from the terminal and this is how most developers interact with NPM. The registry is a large public database of javascript software and metadata surrounding it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NPM is installed with Node.js. This means that you have to install Node.js to get npm installed on your computer. When installing a new package, you're creating a new package.json file.&lt;/p&gt;

&lt;p&gt;To set up a new or existing npm package you must use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm init &amp;lt;initializer&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Initializer in this case is an npm package named create-, which will be installed by npx, and then have its main bin executed – presumably creating or updating package.json and running any other initialization-related operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a new React-based project using create-react-app:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ npm init react-app ./my-react-app&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Create a new esm-compatible package using create-esm:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ mkdir my-esm-lib &amp;amp;&amp;amp; cd my-esm-lib&lt;br&gt;
$ npm init esm --yes&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Generate a plain old package.json using legacy init:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ mkdir my-npm-pkg &amp;amp;&amp;amp; cd my-npm-pkg&lt;br&gt;
$ git init&lt;br&gt;
$ npm init&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Generate it without having it ask any questions:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ npm init -y&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The init command is transformed to a corresponding npx operation as follows:&lt;/p&gt;

&lt;p&gt;npm init foo -&amp;gt; npx create-foo&lt;br&gt;
npm init @usr/foo -&amp;gt; npx @usr/create-foo&lt;br&gt;
npm init @usr -&amp;gt; npx @usr/create&lt;/p&gt;

&lt;p&gt;Any additional options will be passed directly to the command, so npm init foo --hello will map to npx create-foo --hello.&lt;/p&gt;

&lt;p&gt;If the initializer is omitted (by just calling npm init), init will fall back to legacy init behavior. It will ask you a bunch of questions, and then write a package.json for you. It will attempt to make reasonable guesses based on existing fields, dependencies, and options selected. It is strictly additive, so it will keep any fields and values that were already set. You can also use -y/--yes to skip the questionnaire altogether. If you pass --scope, it will create a scoped package.&lt;/p&gt;

&lt;p&gt;To install a new package you'll use the following command:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Windows Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C:\&amp;gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Mac OS Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Package.json example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following example represents what your package.son file looks like after installation.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
"name" : "foo",&lt;br&gt;
"version" : "1.2.3",&lt;br&gt;
"description" : "A package for fooing things",&lt;br&gt;
"main" : "foo.js",&lt;br&gt;
"keywords" : ["foo", "fool", "foolish"],&lt;br&gt;
"author": "John Doe",&lt;br&gt;
"licence" : "ISC"&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use NPM?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NPM provides plenty of different useful things for developers to use. Because npm has packages of reusable code that won't have to be repeatedly written every time you start a new project. NPM is most commonly used to publish, discover, install, and develop node programs. To make use of the tools (or packages) in node.js, we need to be able to manage them in a useful way. This is where npm comes into play. Npm installs the packages you want to use and provides a user interface to work with them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.npmjs.com/about-npm/"&gt;https://docs.npmjs.com/about-npm/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/whatis/whatis_npm.asp"&gt;https://www.w3schools.com/whatis/whatis_npm.asp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.npmjs.com/cli/init"&gt;https://docs.npmjs.com/cli/init&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>npm</category>
    </item>
    <item>
      <title>Version Control Manager</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Mon, 06 Jul 2020 13:54:45 +0000</pubDate>
      <link>https://dev.to/jazsmith24/version-control-manager-3d86</link>
      <guid>https://dev.to/jazsmith24/version-control-manager-3d86</guid>
      <description>&lt;p&gt;In this article, I will be reviewing version control. We will talk about what exactly is version control, how do you use it, different VCM's, and what the benefits of use are. &lt;/p&gt;

&lt;p&gt;Before we go over version control, let's identify a few moving parts involved with version control. A &lt;em&gt;repository&lt;/em&gt; (commonly referred to as repo) is a collection of source code. A repository has &lt;em&gt;commits&lt;/em&gt; to the project which is a set of references to the commits. A &lt;em&gt;commit&lt;/em&gt; logs a change or series of changes that you have made to a file in the repository.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;What is version control?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Version control is an invaluable tool for any kind of software development. It is a management system that allows you to record and track changes in your source code and files so that you can recall certain versions later. Creating a log of all the changes made to code allows programmers to make sure that multiple developers working on the same project do not step on each other's toes. Even if you're not working on a team, it helps keep track of all your changes just in case you break code and have to revert to the working code or previous commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to use version control?&lt;/strong&gt;
&lt;/h2&gt;

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

&lt;p&gt;In software development, a team needs an efficient way to manage changes and version code in their codebase. Developers often refer to their codebase as a working tree. Like a tree, our codebase extends to different branches that contain different versions of code. To utilize version control, we run commands in the terminal of the workspace. &lt;/p&gt;

&lt;p&gt;Above we have a visualization of a working tree. This working tree represents our codebase. There is a team of coders working on this same code base. Each author can make their edits without affecting the main branch. This prevents loss of working or optimized code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Popular version control systems&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Github&lt;/li&gt;
&lt;li&gt;GitLab&lt;/li&gt;
&lt;li&gt;Beanstalk&lt;/li&gt;
&lt;li&gt;PerForce&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below are some remote commands you would use what working with someone else on your tree. Use the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This command allows you to see what authors are added to your tree:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git remote -v&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;This command allows you to add an author to your working tree:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git remote add  &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;This command allows you to remove an author from your working tree:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git remote rm &lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Useful Situations?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tracking&lt;/strong&gt;: Say you are working on a web application, and one day, you find that your code changes have broken parts of the website. Instead of going through the trouble of finding the bug, you can revert your changes and see what lines of code are causing the problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Teamwork&lt;/strong&gt;: Without a version control system, it’s challenging to work on the same source code at once. By using something like Git, you can more easily merge changes, which makes it significantly easier to collaborate on projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Branches&lt;/strong&gt;: Say you are working on the footer and header of your website without using a version control system. You’ve finished the header, but not the footer, which means that the project isn’t ready to be public. With a version control system, you can create branches for different aspects of the project you are working on and merge them into​ the main source code when you are done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Version Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Due to how useful version control is, it’s almost always a requirement for any developer or engineering job. As you become more accustomed to using a version control system, you will realize how powerful and easy it is to use. It helps to commit and merge code without conflicts. Also, while using it on a team, you can even make edits to shared code, without unknowingly overwriting each other’s work.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sources&lt;/em&gt;&lt;br&gt;
&lt;a href="https://www.educative.io/edpresso/what-is-version-control"&gt;https://www.educative.io/edpresso/what-is-version-control&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gource.io/"&gt;https://gource.io/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.educative.io/edpresso/what-is-git"&gt;https://www.educative.io/edpresso/what-is-git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>versionctrl</category>
    </item>
    <item>
      <title>Instantiation in Javascript: Pseudoclassical Style</title>
      <dc:creator>Jazsmith24</dc:creator>
      <pubDate>Mon, 29 Jun 2020 13:58:40 +0000</pubDate>
      <link>https://dev.to/jazsmith24/instantiation-in-javascript-pseudoclassical-style-38bk</link>
      <guid>https://dev.to/jazsmith24/instantiation-in-javascript-pseudoclassical-style-38bk</guid>
      <description>&lt;p&gt;Instantiation patterns refer to the way instances of objects are created. There are different instantiation patterns and these patterns have different opinions of how a class creates a new instance of an object. This article will cover &lt;strong&gt;pseudoclassical instantiation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;All instantiation patterns have the same following functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Creates a new object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creates properties which are methods for the newly created object.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To create a new &lt;strong&gt;instance&lt;/strong&gt; in pseudoclassical style, we must start with a &lt;strong&gt;class&lt;/strong&gt; function. The class is the constructor function that creates instances of new objects that inherits properties from the class prototype. We can metaphorically think of this class as a carpentry school. This school has all the knowledge that students need to build things.&lt;/p&gt;

&lt;p&gt;For example, here we have a class called BuildDiningSet. This function has a prototype property which contains methods for building furniture and other methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;BuildDiningSet&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chair&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chair&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chairCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tableCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As a result of an affiliation with the school, the students that go to that school will have inherited the knowledge of building different things upon graduation. Thus, as a result of invoking our class, we create new instances that will inherit the prototypes of our class.&lt;/p&gt;

&lt;p&gt;The properties and methods are defined on the prototype property on the objects' class, not the object instances themselves. Each new instance refers back to the prototypal chain to access the prototype property of its' class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;BuildDiningSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;makeChair&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;chairType&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chairCount&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chair&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;chairType&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;chairType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;

&lt;span class="nx"&gt;BuildDiningSet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;makeTable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tableType&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tableCount&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tableType&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tableType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that our class has methods on its' prototype, we are ready to create new instances. To create a new instance with must use the "new" keyword. Our graduating students now know how to build tables and chairs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;carpenter1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;BuildDiningSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tallChairs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;roundTable&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;carpenter1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;makeChair&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;carpenter1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;makeTable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we have a graduating student called carpenter1 that knows how to build tables and chairs. When the graduate goes to work he refers back to what he learned in school to perform the function. &lt;/p&gt;

&lt;p&gt;When using the new keyword, it binds the keyword this to the new object being created and thus gives the new object all the properties specified in the class.&lt;/p&gt;

&lt;p&gt;Pseudo classical instantiation is the most advanced method of object creation. With the use of syntactical sugar, it makes it so you don't have to do as much code writing as you would when using other instantiation styles.&lt;/p&gt;

</description>
      <category>instantiationpattern</category>
    </item>
  </channel>
</rss>
