<?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: Taslan Graham</title>
    <description>The latest articles on DEV Community by Taslan Graham (@taslangraham).</description>
    <link>https://dev.to/taslangraham</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%2F402897%2Ff9a53059-a572-4b39-a8e2-bf28589b4d78.png</url>
      <title>DEV Community: Taslan Graham</title>
      <link>https://dev.to/taslangraham</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/taslangraham"/>
    <language>en</language>
    <item>
      <title>Scaffold Node.js APIs quickly with Todo-CLI</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Wed, 15 Dec 2021 12:21:57 +0000</pubDate>
      <link>https://dev.to/taslangraham/side-project-tode-cli-1if8</link>
      <guid>https://dev.to/taslangraham/side-project-tode-cli-1if8</guid>
      <description>&lt;p&gt;Hey, y’all! Hope you're doing great! It's been a while since I’ve posted an article. During this period I spent some time working on a node.js CLI for scaffolding APIs. In this article, I want to introduce you to the tool I created, Tode-CLI.&lt;/p&gt;

&lt;h2&gt;Why I created the tool?&lt;/h2&gt;

&lt;p&gt;First, I want to give a little insight into why I created the CLI I'm about to tell you about. I love using node.js (with express.js) to create APIs. It’s fast and simple to use.  

&lt;br&gt;&lt;br&gt;
However, I dislike having to create common things like models, controllers(routes), and service files from scratch each time I needed one. Additionally, I dislike the tedious efforts needed to set up authentication in applications that requires some level of authentication/authorization. &lt;/p&gt;

&lt;p&gt;This led me to ask the question, “what can I do to avoid this repetition?”.  So, I decided to build a simple tool that could automate some of these things for myself.&lt;/p&gt;

&lt;p&gt;After working on the tool, I decided to publish it to &lt;a href="https://www.npmjs.com/package/tode-cli" rel="noreferrer noopener"&gt;npm &lt;/a&gt;in case someone else might find it useful. Let’s take a closer look at the tool I created.&lt;/p&gt;

&lt;h2&gt;Introducing Tode-CLI&lt;/h2&gt;

&lt;p&gt;Tode-CLI is a tool for scaffolding node.js APIs. It provides commands to automate the boring stuff – creating models, services, controllers, registering routes. Thus, speeding up your development time.&lt;/p&gt;

&lt;p&gt;Tode-CLI comes with an elegant ORM, &lt;a href="https://vincit.github.io/objection.js/" rel="noreferrer noopener"&gt;objection.js&lt;/a&gt;, built on top of the famous query builder, &lt;a href="https://knexjs.org/" rel="noreferrer noopener"&gt;knex.js&lt;/a&gt;. This makes interacting with databases a breeze when working with projects created by tode-cli.&lt;/p&gt;

&lt;p&gt;The following will explore some features of the CLI.&lt;/p&gt;



&lt;h3&gt;Features&lt;/h3&gt;

&lt;p&gt;In this section, I'll take a quick look at some of the core features of the CLI and give usage examples.&lt;/p&gt;

&lt;h4&gt;Generate/scaffold a project&lt;/h4&gt;

&lt;p&gt;The tode-cli provides a command to scaffold a project that has a straightforward folder structure. You scaffold a project by running &lt;code&gt;$ npx tode-cli create-project hello-world&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This will generate a project, called &lt;code&gt;hello-world&lt;/code&gt;, with the following folder structure:&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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-5.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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-5.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;npm i&lt;/code&gt; to install the node packages, then run &lt;code&gt;npm run dev&lt;/code&gt; to serve your app locally. Your app will be served at &lt;code&gt;http://localhost:8080/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hitting &lt;code&gt;http://localhost:8080/&lt;/code&gt; via a client (web browser, postman, etc) will give the following response:&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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-2-edited.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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-2-edited.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The response above is showing all the none nested routes within the application. By default, a &lt;code&gt;example&lt;/code&gt; route comes with the application. &lt;/p&gt;



&lt;h4&gt;Adding a Controller&lt;/h4&gt;

&lt;p&gt;In node applications, it is common to use &lt;code&gt;route&lt;/code&gt; files to handle the routing in the app.
&lt;br&gt;
However, in a tode-cli generated application we call these files controllers and they are stored in the controllers folder. Future updates may see a complete separation of controllers from routes, similar to what popular tools like Laravel and adonis.js does.&lt;/p&gt;

&lt;p&gt;To add a controller to your app you simply run &lt;code&gt;$ npx tode-cli add:controller &amp;lt;controller_name&amp;gt;&lt;/code&gt;. This will scaffold a controller(route) file like the following:&lt;/p&gt;



&lt;div class="highlight js-code-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;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Router&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="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="cm"&gt;/**
   * Create a new Item
   */&lt;/span&gt;
  &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo/ - POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="cm"&gt;/**
   * Get all Items
   */&lt;/span&gt;
  &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;demo/  - GET&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="cm"&gt;/**
   * Get an Item by Id
   */&lt;/span&gt;
  &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;demo/  - GET /id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="cm"&gt;/**
   * Update an Item
   */&lt;/span&gt;
  &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;patch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;demo/  - PATCH /id&lt;/span&gt;&lt;span class="dl"&gt;"&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;router&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;Here we created a controller named &lt;code&gt;demo&lt;/code&gt;. This controller is created with handlers for some basic HTTP request methods such as &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt; on the &lt;code&gt;'/demo'&lt;/code&gt; path. &lt;/p&gt;

&lt;p&gt;We can test that our controller is working by hitting &lt;code&gt;http://localhost:8080/demo&lt;/code&gt; via a client(web browser, postman, etc). We should get the following response:&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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-3.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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-3.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we hit &lt;code&gt;http://localhost:8080&lt;/code&gt; again we will see the &lt;code&gt;demo&lt;/code&gt; route in our list of routes. As you can see here, tode-cli apps offer a level of self-documentation for the routes within the application.&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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-6.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%2Fwww.taslangraham.com%2Fwp-content%2Fuploads%2F2021%2F12%2Fimage-6.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Models&lt;/h3&gt;

&lt;p&gt;Models are classes that represent a table in your database. You use methods on the model to perform queries on the table it represents via an easy-to-use ORM, &lt;a href="https://vincit.github.io/objection.js/" rel="noreferrer noopener"&gt;Objection.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To create a model you run the command &lt;code&gt;$ npx tode-cli add:model &amp;lt;model_name&amp;gt;&lt;/code&gt;. You'll get a generated model like the following:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BaseModel&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../BaseMode&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;  &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BaseModel&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Name of table that this model maps back to&lt;/span&gt;
  &lt;span class="c1"&gt;// Table name is the only required property.&lt;/span&gt;
  &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ENTER_TABLE_NAME&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Example property&lt;/span&gt;
  &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Add other table fields (columns) as properties to access them via the model&lt;/span&gt;

  &lt;span class="c1"&gt;// Define the relations to other models.&lt;/span&gt;
  &lt;span class="c1"&gt;// READ MORE at https://vincit.github.io/objection.js/guide/relations.html&lt;/span&gt;
  &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;relationMappings&lt;/span&gt; &lt;span class="o"&gt;=&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;// specify relation with other modules&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;In the above, I generated a model called &lt;code&gt;User&lt;/code&gt;. Models on have one required property, &lt;code&gt;tableName&lt;/code&gt;, which holds the name of the database table that the model represents. You can perform a query to fetch all users in your database table using &lt;code&gt;await User.query()&lt;/code&gt;. Read more about objection.js' queries &lt;a href="https://vincit.github.io/objection.js/guide/query-examples.html" rel="noreferrer noopener"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The static method &lt;code&gt;relationMappings&lt;/code&gt; is where you define your model's relationship with other models - basically representing your database relationships. Read more about objection.js' relationships &lt;a href="https://vincit.github.io/objection.js/guide/relations.html" rel="noreferrer noopener"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: To use your models to perform queries you'll first need to set up a database connection to the database with your tables. Read more &lt;a href="https://github.com/taslangraham/tode-cli#configuring-database-connection" rel="noreferrer noopener"&gt;here&lt;/a&gt;.&lt;/p&gt;



&lt;h3&gt;Services&lt;/h3&gt;

&lt;p&gt;Service files contain your business logic. To create a service you run the command &lt;code&gt;$ npx tode add:service &amp;lt;service_name&amp;gt;&lt;/code&gt;. When you create a service, a file will be generated like the following.&lt;/p&gt;



&lt;div class="highlight js-code-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;ServiceReponse&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="s2"&gt;../../config/constants&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;_foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;foo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;foo&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;_foo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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;_foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;foobar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UserService&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;UserService&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above is the generated file for a service called &lt;code&gt;UserService&lt;/code&gt;.  You can then add methods to perform any logic inside this file. You'll then call these methods from within a controller or another service. Services are also where you utilize your Models to perform database queries where necessary.&lt;/p&gt;



&lt;h3&gt;Authentication&lt;/h3&gt;

&lt;p&gt;Authentication is an essential part of most applications these days. With Tode-Cli you can integrate basic JSON Web Token (JWT) based authentication in your application by running a single command, &lt;code&gt;$ npx tode-cli add:auth&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This command will create the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Knex Migration to create a &lt;code&gt;Users&lt;/code&gt; table in your database&lt;/li&gt;
&lt;li&gt;Login functionality which you can customise&lt;/li&gt;
&lt;li&gt;Registration functionality which you can customize&lt;/li&gt;
&lt;li&gt;Auth middleware which you can use on protected routes&lt;/li&gt;
&lt;li&gt;Login route - &lt;code&gt;/auth/login&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Registration route - &lt;code&gt;/auth/register&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All you'll need to do afterward is create the users table in your database by executing the migration file that was created. To do this, run the command  &lt;code&gt;$ npx knex migrate:latest&lt;/code&gt;. Now authentication is fully integrated.&lt;/p&gt;



&lt;h2&gt;Technologes used&lt;/h2&gt;

&lt;p&gt;Tode-CLI was developed with the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://oclif.io/" rel="noreferrer noopener"&gt;OCLIF &lt;/a&gt;- an open source framework for building command line interfaces (CLI) in Node.js.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We've covered some of the core features of Tode-CLI. I first created this tool for my personal use. I hope someone else finds it useful. &lt;/p&gt;

&lt;p&gt;You can have a deeper dive into the docs and configurations &lt;a href="https://github.com/taslangraham/tode-cli#readme" rel="noreferrer noopener"&gt;here&lt;/a&gt;. Feel free to try it out. Don't hesitate to report any issues you come across. I aim to improve the CLI as time goes by. &lt;/p&gt;

&lt;p&gt;Thanks for reading, and until next time! &lt;em&gt;Think, Learn, Create, Repeat!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>typescript</category>
      <category>todecli</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I've reached 20,000 views</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Sun, 08 Aug 2021 15:51:13 +0000</pubDate>
      <link>https://dev.to/taslangraham/i-ve-reached-20-000-views-3bpi</link>
      <guid>https://dev.to/taslangraham/i-ve-reached-20-000-views-3bpi</guid>
      <description>&lt;p&gt;I recently reached 20k reads on dev.to.&lt;/p&gt;

&lt;p&gt;Thank you to everyone who has taken the time out to read my articles! &lt;/p&gt;

&lt;p&gt;Glad I'm able to provide value to the community.&lt;/p&gt;

</description>
      <category>devjournal</category>
    </item>
    <item>
      <title>Node.js Event Emitter</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Thu, 05 Aug 2021 08:33:12 +0000</pubDate>
      <link>https://dev.to/taslangraham/node-js-event-emitter-fed</link>
      <guid>https://dev.to/taslangraham/node-js-event-emitter-fed</guid>
      <description>&lt;p&gt;Node's event-driven architecture allows us to execute certain actions when something happens. This is done via objects (called "emitters") which can &lt;em&gt;emit &lt;/em&gt;named events that cause functions ("listeners") to be executed. Objects that emit events are instances of node's EventEmitter class, made available via the &lt;code&gt;events&lt;/code&gt; module. In this article we'll look at node's event emitter.&lt;/p&gt;

&lt;h2&gt;Creating an Emitter&lt;/h2&gt;

&lt;p&gt;Let's create an event to explore some of basic concepts with node's EventEmitter&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Require in the events module &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;EventEmitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;events&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;carEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;EventEmitter&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;events&lt;/code&gt; module provides us with the &lt;code&gt;EventEmitter&lt;/code&gt; class. We then create an instance of &lt;code&gt;EventEmitter &lt;/code&gt;called &lt;code&gt;carEvent&lt;/code&gt;. Now let's explore some of the methods available to us.&lt;/p&gt;

&lt;h2&gt;Adding a listener&lt;/h2&gt;

&lt;p&gt;As mentioned earlier listeners are callbacks that gets executed when we emit a named event. Here's how you'd create an event listener on our &lt;code&gt;carEvent&lt;/code&gt; emmiter.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Started the car.&lt;/span&gt;&lt;span class="dl"&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;Here we are registering a listener for the event named &lt;em&gt;start&lt;/em&gt;. This will be executed when we emit an event of said name.&lt;/p&gt;

&lt;p&gt;We can also add multiple listeners to a single event. Let's add another:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Car started. Ready to go!&lt;/span&gt;&lt;span class="dl"&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;Next we'll emit events to trigger these listeners.&lt;/p&gt;

&lt;h2&gt;Emitting an Event&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;All listeners for an event will be called synchronously in the order in which they were registered.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We trigger the listener(s) for an event by calling the &lt;code&gt;emit()&lt;/code&gt; method with the name of the event as the first argument. Any  subsequent arguments will be passed on as arguments to the listeners. &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&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;Hello! &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Started the car.&lt;/span&gt;
&lt;span class="c1"&gt;// Car started. Ready to go!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above we emitted the &lt;em&gt;start&lt;/em&gt; event  which resulted in all listeners attached to the &lt;em&gt;start&lt;/em&gt; event being executed. Now lets update our second listener to make it accept an argument. &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&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;greeting&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&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;Car started. Ready to go!&lt;/span&gt;&lt;span class="dl"&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;Now we emit the &lt;em&gt;start &lt;/em&gt;event and get the following:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&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;Hello!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Started the car.&lt;/span&gt;
&lt;span class="c1"&gt;// Hello! Car started. Ready to go!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;Removing a listener from an event&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;removeListener()&lt;/code&gt; method removes a listener from an event. This takes the name of the event, and the handler function to be removed as arguments. Calls to this method only removes a single instance of a listener, so if you have a listener that was added multiple times then you'd have to call the  &lt;code&gt;removeListener()&lt;/code&gt; method multiple times to remove each listener.&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;a&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Called listener function&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Add listener to event&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;'&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="c1"&gt;// Emit event&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Called listener function&lt;/span&gt;

&lt;span class="c1"&gt;// Remove listener&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;'&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="c1"&gt;// Emit event again&lt;/span&gt;
&lt;span class="c1"&gt;// Nothing happens, event was removed&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&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 &lt;code&gt;removeListener&lt;/code&gt; method emits an event,  &lt;code&gt;removeListener&lt;/code&gt;,  after the listener has being removed. &lt;/p&gt;

&lt;h2&gt;More methods&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;on()&lt;/code&gt; and &lt;code&gt;emit() &lt;/code&gt;methods are the most commons ones used when when working with event emitters in node. However, lets take a look at some other useful methods available to us.&lt;/p&gt;

&lt;h4&gt;Once&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;once()&lt;/code&gt; method adds a listener that will be executed only, you guessed it :) , once.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Adds a listener to be executed once&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;once&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stop&lt;/span&gt;&lt;span class="dl"&gt;'&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;message&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&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 when emit the &lt;em&gt;stop &lt;/em&gt; event, node will remove the listener(from list of listeners attached to the event) then invoke it.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Executes the first time we emit the stop event&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stop&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;Stopping....&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Stopping....&lt;/span&gt;

&lt;span class="c1"&gt;// Emit the stop event a second time&lt;/span&gt;
&lt;span class="c1"&gt;// Nothing happens&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stop&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;Stopping....&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h4&gt;setMaxListeners&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;setMaxListeners()&lt;/code&gt; method allows you to set to the maximum number of listeners that can be attached to a single event. The value can be set to &lt;code&gt;Infinity&lt;/code&gt; (or &lt;code&gt;0&lt;/code&gt;) to indicate an unlimited number of listeners.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Sets a maximum of two listeners for any event on the carEvent emitter&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setMaxListeners&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we add more than two listeners to any event then we'll get a warning like the following:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add thre listeners to a single event&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eventA&lt;/span&gt;&lt;span class="dl"&gt;'&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;greeting&lt;/span&gt;&lt;span class="p"&gt;){});&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eventA&lt;/span&gt;&lt;span class="dl"&gt;'&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;greeting&lt;/span&gt;&lt;span class="p"&gt;){});&lt;/span&gt;
&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eventA&lt;/span&gt;&lt;span class="dl"&gt;'&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;greeting&lt;/span&gt;&lt;span class="p"&gt;){});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;pre&gt;(node:17787) Warning: Possible EventEmitter memory leak detected. 3 eventA listeners added. Use emitter.setMaxListeners() to increase limit&lt;/pre&gt;



&lt;h4&gt;listeners&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;listeners()&lt;/code&gt; method returns an array of the listeners registered for an event.&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;const&lt;/span&gt; &lt;span class="nx"&gt;listeners&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// [ [Function], [Function] ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h4&gt;eventNames&lt;/h4&gt;

&lt;p&gt;Returns an array listing the name of events for which the emitter has registered listeners.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;carEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eventNames&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// [ 'start', 'stop', 'eventA' ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h2&gt;Extending The EventEmitter Class&lt;/h2&gt;

&lt;p&gt;We can create our own objects that has its own set of properties and methods along with the ones provided by node's &lt;code&gt;EventEmitter&lt;/code&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;const&lt;/span&gt; &lt;span class="nx"&gt;EventEmitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;events&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;EventEmitter&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;super&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;brand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;brand&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;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;turnRadioOn&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;radio turned on&lt;/span&gt;&lt;span class="dl"&gt;'&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;Above we created a class that inherits from the &lt;code&gt;EventEmitter&lt;/code&gt; class as well as having two properties(&lt;em&gt;brand, and year&lt;/em&gt;) of its own along with a method,&lt;em&gt; turnRadioOn&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now instances of the &lt;code&gt;Car&lt;/code&gt; class will have access to both the properties and methods on the &lt;code&gt;Car &lt;/code&gt;class as well as all the ones inherited from the  &lt;code&gt;EventEmitter&lt;/code&gt; class.&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;const&lt;/span&gt; &lt;span class="nx"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BMW&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;2021&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Adds a listener&lt;/span&gt;
&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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;brand&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; started&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Emit the event&lt;/span&gt;
&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// BMW started&lt;/span&gt;

&lt;span class="c1"&gt;// Call method defined on Car class&lt;/span&gt;
&lt;span class="nx"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;turnRadioOn&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// radio turned on&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h1&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;Node's EventEmitter allows us to create objects with listeners that gets executed when we emit an event that the listener is registered to. &lt;br&gt;We covered methods including the &lt;code&gt;on()&lt;/code&gt;, &lt;code&gt;emit()&lt;/code&gt;,  &lt;code&gt;removeListener()&lt;/code&gt; methods. We also looked at how we can extend the &lt;code&gt;EventEmitter&lt;/code&gt;when creating our own classes.&lt;/p&gt;

&lt;p&gt;Did you find this useful? Let me know if the comments. Until next time, &lt;em&gt;think, learn, create, repeat!&lt;/em&gt;&lt;/p&gt;



</description>
      <category>node</category>
      <category>eventdriven</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What are the ACID properties in Database Systems?</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Wed, 28 Jul 2021 02:36:23 +0000</pubDate>
      <link>https://dev.to/taslangraham/what-are-the-acid-properties-in-database-systems-1p9o</link>
      <guid>https://dev.to/taslangraham/what-are-the-acid-properties-in-database-systems-1p9o</guid>
      <description>&lt;h2&gt;WHAT IS ACID&lt;/h2&gt;

&lt;p&gt;ACID  stands for Atomicity, Consistency, Isolation, and Durability. It is a set of database properties(rules) which transactions must obey to maintain the integrity and consistency of a database. In this article we'll take a look at each ACID property. &lt;br&gt;&lt;br&gt;But first, what is a transaction?  A transaction is a single logical unit of work which accesses and possibly modifies the contents of a database. Transactions access data using read and write operations - &lt;a rel="noreferrer noopener" href="https://www.geeksforgeeks.org/acid-properties-in-dbms/"&gt;GeeksForGeeks&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Atomicity&lt;/h3&gt;

&lt;p&gt;With the atomicity rule all operations within a transaction must be successful in order for any changes to be commit to the database. If any failure occurs during a transaction then the entire transaction fails. Lets look at an example.&lt;/p&gt;

&lt;p&gt;Imagine we have two bank accounts, account A and account B. Account A has $500, while account B has $100. We'll like to transfer $50 from account A to B. The transaction would like the following.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/04/a.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_2g4uSGQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/04/a.png%3Fw%3D344" alt="" width="344" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets imagine that a failure occurs right after we write the deductions to account A. This would leave account A with $450 but, account B was not updated. So we just magically lost $50. This would corrupt  your data. The property of atomicity prevents this - once there's a failure anywhere in the transaction then the entire transaction fails - and nothing gets committed to the database.&lt;/p&gt;



&lt;h3&gt;
&lt;span&gt;CONSISTENCY&lt;/span&gt; &lt;/h3&gt;

&lt;p&gt;Database consistency must be maintained after each transaction. This means that all changes should be accurate, and leaves the database in a valid state which also upholds data integrity. Lets look at the following example.&lt;br&gt;Imagine we have the following two tables(customers, and orders).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/05/image-3.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WlWco9PO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/05/image-3.png%3Fw%3D981" alt="" width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both tables are linked via the foreign key constraint based on the &lt;strong&gt;customer_id&lt;/strong&gt; on the. This will ensure that upon inserting a new record in the &lt;strong&gt;orders &lt;/strong&gt;table, the &lt;strong&gt;customer_id &lt;/strong&gt;used is valid (is an &lt;strong&gt;id&lt;/strong&gt; of an existing customer record in the &lt;strong&gt;customers &lt;/strong&gt;table).&lt;/p&gt;

&lt;p&gt;If a transaction inserts a new record in the &lt;strong&gt;orders &lt;/strong&gt;table using a &lt;strong&gt;customer_id&lt;/strong&gt; (e.g 90) that does not exist then the database would be in an inconsistent state as two. Thankfully our foreign key constraint would prevent this, and the entire transaction would be aborted(including any other changes that may have occurred earlier in the transaction) and consistency would be maintained.&lt;/p&gt;

&lt;h3&gt; &lt;span&gt;ISOLATION&lt;/span&gt; &lt;/h3&gt;

&lt;p&gt;A transaction being executed should not be affected by any other transactions executing simultaneously, therefore isolated. The result of concurrent transactions should be the same as it would be if the transactions were executed sequentially. Isolation also determines how/if changes in an uncommitted transaction are visible to other transactions or whether different transactions can access the same data at the same time. - this is done via &lt;a href="https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels"&gt;isolation levels&lt;/a&gt;. &lt;/p&gt;



&lt;h3&gt;Durability&lt;/h3&gt;

&lt;p&gt;Durability ensures that changes committed during a transaction persists permanently(stored in non-volatile memory), even if there happens to be a system failure or a power outage. Lets take a look at an example.&lt;br&gt;Lets says you're transferring funds from account A to account B, and right after completing the transaction the bank has a sudden power outage, the durability property would ensure that the changes made to both accounts are still stored.  &lt;/p&gt;

&lt;p&gt;The ACID properties ensure that we have a database with correct data at any given time. In this article we looked at each of the ACID properties - there impact and importance. &lt;/p&gt;

&lt;p&gt;This is my first time writing about a database topic, hope you enjoyed it and found it useful. Thank you for reading. Until next time, &lt;em&gt;think, learn, create, repeat!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is the D.R.Y Principle?</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Sat, 20 Feb 2021 17:51:55 +0000</pubDate>
      <link>https://dev.to/taslangraham/what-is-the-d-r-y-principle-52c2</link>
      <guid>https://dev.to/taslangraham/what-is-the-d-r-y-principle-52c2</guid>
      <description>&lt;p&gt;In this article we will explore one of the main software design principles - D.R.Y, its benefits, and downfall of violating this principle. I will also provide short code snippet to help demonstrate this principle.&lt;/p&gt;

&lt;h2&gt;What is the D.R.Y Principle&lt;/h2&gt;

&lt;p&gt;D.R.Y, which stands for "Do Not Repeat Yourself", is a principle of software development  aimed at reducing the of repetition code.&lt;/p&gt;

&lt;p&gt;The Authors of the book &lt;strong&gt;&lt;em&gt;The Pragmatic Programmer&lt;/em&gt;&lt;/strong&gt; described D.R.Y as "&lt;em&gt;every piece of knowledge must have a single, unambiguous, authoritative representation within a system.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Knowledge would be your business logic, and algorithms or a variable used in your application. So, in simple terms what the definition is saying is that every piece of individual logic or algorithm or info should live and be expressed in a single location(function etc.) within your code. &lt;br&gt;&lt;br&gt;The alternative to this would be to have the same thing expressed in two or more places. If you change one, then you'll have to remember to change the others - and &lt;em&gt;waste everyone's time&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;D.R.Y Violation&lt;/h3&gt;

&lt;p&gt;Let us take a look at simple piece of code that violates the D.R.Y principle. We will then we update our code to adhere to the D.R.Y principle.&lt;/p&gt;

&lt;p&gt;Let's imagine we have the following class:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Player&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;moveRight&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Right&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Moved player -- Right&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;moveLeft&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Left&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Moved player -- Left&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;moveUp&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Moved player -- Up&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;moveDown&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Down&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Moved player -- Down&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Taking a break...... Drinking some water :)&lt;/span&gt;&lt;span class="dl"&gt;"&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;Our class has methods that allows a player to move left, right, up, and down. However, each method ( &lt;em&gt;moveRight()&lt;/em&gt;, &lt;em&gt;moveLeft()&lt;/em&gt;, &lt;em&gt;moveUp()&lt;/em&gt;, &lt;em&gt;moveDown() &lt;/em&gt;) all repeats the same logic.&lt;br&gt;&lt;br&gt;If we wanted to perform some more task after moving (similar to &lt;em&gt;rest())&lt;/em&gt; then we will have to update each of our existing methods to include that new piece of code. We could update our class to the following:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Player&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;move&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;direction&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;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;logMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Moved player -- &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Taking a break...... Drinking some water :)&lt;/span&gt;&lt;span class="dl"&gt;"&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;Here we updated our class to have a single &lt;em&gt;move()&lt;/em&gt; method which will handle moving the player. We also included a&lt;em&gt; &lt;/em&gt;function, &lt;em&gt;logMessage()&lt;/em&gt;, which we'll pass our confirmation messages to. Let's imagine that this function is available for usage across our entire codebase. &lt;/p&gt;

&lt;h3&gt;Benefits of Keeping D.RY.&lt;/h3&gt;

&lt;p&gt;Adhering to the D.R.Y principle provides many benefits. Some of which are mentioned below. While reading these benefits you'll also get a picture of what life is like when you fail to follow the D.R.Y principle.&lt;/p&gt;

&lt;h3&gt;Maintainability &lt;/h3&gt;

&lt;p&gt;If you have repeated logic all over your application then it will be a nightmare to make updates. If you fix an issue or make an update in one place then you have to remember to make the changes in the other places - and we're likely to forget all the places that needs this fix. However, if we have our logic in one place then we only need to make a fix in that one place making our code easier to maintain.&lt;/p&gt;

&lt;h3&gt;Promotes code reuse&lt;/h3&gt;

&lt;p&gt;With the D.R.Y principle, logic that was expressed across two or more instances in now available at a single source. Whenever you need that piece of logic you can simply reuse the existing source (variable, function etc.).&lt;/p&gt;

&lt;h3&gt;Easier to test&lt;/h3&gt;

&lt;p&gt;If a piece of logic is duplicated across your application codebase then you'll need to write test to cover the various areas where the duplication is present. Having a single place test test makes would make testing much easier.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;In this article we took a look at the D.R.Y principle, and it's benefits. We also got an insight into how difficult life can get when we violate this principle. We should always try to refactor and remove duplication from code as much as possible. &lt;br&gt;&lt;br&gt;If you found this article helpful then leave a comment below. Also spread the knowledge with your peers by sharing this article. Until next time, &lt;em&gt;think, learn, create, repeat!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>refactorit</category>
    </item>
    <item>
      <title>Advice to Junior Software Engineers - from a Junior Engineer</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Wed, 03 Feb 2021 15:13:54 +0000</pubDate>
      <link>https://dev.to/taslangraham/advice-to-junior-software-engineers-from-a-junior-engineer-2fe7</link>
      <guid>https://dev.to/taslangraham/advice-to-junior-software-engineers-from-a-junior-engineer-2fe7</guid>
      <description>&lt;p&gt;As a Junior Engineer you're at the baby stages of your career - learning a lot, and full of passion. Recognizing that this is a time for growth you may ask yourself "what are the things that I can do during this important time in my career to help me along my journey?".&lt;/p&gt;

&lt;p&gt;Here are eight (8) pieces of advice to Junior Engineers from me, a fellow Junior Engineer. The following has played a huge role in my journey thus far.&lt;br&gt;&lt;br&gt;This list is a non-exhaustive, many more things can and should be done (for example, focusing on developing technical skills, learning different techniques and best practices. So, without further ado lets dive in.&lt;/p&gt;

&lt;h2&gt;1. Take notes from senior Engineers&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-rfstudio-3059747.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e9xgqyur--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-rfstudio-3059747.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's a lot you can learn from experienced Engineers if you observe them or ask questions. Things like how to deal with clients and project managers, tips on how to improve as an Engineer,  advice on how to progress forward in your career, problem solving, insight into different technologies and so much more.&lt;br&gt;&lt;br&gt;Most seniors are happy to share what they know with you. You can also follow senior Engineers on social media as well. One Engineer who I follow on YouTube is &lt;a rel="noreferrer noopener" href="https://www.youtube.com/c/HusseinNasser-software-engineering/about"&gt;Hussein Nasser&lt;/a&gt;, he discusses a wide range of engineering topics.&lt;/p&gt;

&lt;h2&gt;2. You Don't Need To Know Everything&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-pixabay-356079.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h3DHEZjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-pixabay-356079.jpg%3Fw%3D1024" alt="" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's a lot out there to learn in the world of technology. Some persons may feel &lt;a rel="noreferrer noopener" href="https://taslangraham.com/2020/05/17/keep-at-it/"&gt;doubtful&lt;/a&gt; of their skills, unready or inadequate if they don't know a particular thing or can't answer a particular question about something. &lt;br&gt;&lt;br&gt;The truth is, you don't need to know everything. You simply need to know the things that are relevant to what you're doing. &lt;br&gt;&lt;br&gt;Something to keep in mind is that you can learn just about anything tech related through proper research and usage of free resources like YouTube. &lt;/p&gt;

&lt;h2&gt;3. There's No Such Thing As Perfect Code&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/work-731198_1920.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7krmEa2w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/work-731198_1920.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used to spend a considerable amount of time overthinking and trying to perfect my code. Ironically this lead to code that was prematurely "optimized", over complicated and difficult to read, understand and debug.&lt;br&gt;&lt;br&gt;Trying to write perfect code will slow you down. It's best to write working code in its simplest form then refactor to improve readability and performance. &lt;/p&gt;

&lt;h2&gt;4. Learn How To Read Code&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-photo-3768894.jpeg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0QVb9c4i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-photo-3768894.jpeg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I read something somewhere that said something along the lines of &lt;em&gt;&lt;strong&gt;"you'll read more code than you write"&lt;/strong&gt;&lt;/em&gt;. This is quite true. You'll spend a considerable amount of time reading existing code ( written by yourself or others).&lt;br&gt;&lt;br&gt;Adding a new feature to an application? You'll first need to read the existing code to understand what's going on.&lt;br&gt;Refactoring code? You'll need to read it first. &lt;br&gt;&lt;br&gt;Searching for help online? You'll need to read and understand the code snippets given to avoid just copying and pasting.&lt;br&gt;&lt;br&gt;Even when you're using a framework, you'll need to be able to read through the coding samples given in their documentation.&lt;/p&gt;

&lt;p&gt;Seeing that you will spend a lot of time reading code, it makes sense to improve on this skill. Reading code written by others will help you to see the thought process of other engineers.&lt;/p&gt;

&lt;p&gt;You can read open source code (at the time of writing, I don't read a lot of open source code but, I intend to change that) or code written by project team members. Reviewing PRs (pull requests) are also a great way to learn to read code.&lt;/p&gt;

&lt;h2&gt;5. Work On Your Soft Skills&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-fauxels-3184291.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jgIAgrNo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-fauxels-3184291.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's well known that technical competence is needed to have a great career as an Engineer but, at the end of the day we are still social beings and we will work with others .&lt;/p&gt;

&lt;p&gt;Even with work from home being the status quo, your people skills are still on display in the gazillion weekly meetings that you have.&lt;br&gt;&lt;br&gt;How you interact with others(clients, teammates etc.) can open doors for you even in the early stages of your career.&lt;br&gt;You don't need to be chatty or extremely out going either. You simply need to develop &lt;a rel="noreferrer noopener" href="https://taslangraham.com/2019/12/14/5-soft-skills-every-developer-should-have/"&gt;certain soft-skills&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;6. Learn The Tools You Are Using&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/tools-864983_1920.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gh4oAKL6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/tools-864983_1920.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An efficient craftsman knows his tools inside out - their capabilities, limitations and use cases. As an engineer you have to learn the tools you use on a regular basis. This includes your IDE, source control, project management tool and any other tool you use on a daily basis to carry out your work.&lt;br&gt;&lt;br&gt;Learning and mastering these tools will make you much more efficient and can save time. For example, learning the shortcuts within your IDE will allow you to navigate your code and work faster.&lt;/p&gt;

&lt;p&gt;This is a continuous process for me as I'm always coming across things I did not know about the tools I'm using.&lt;/p&gt;

&lt;h2&gt;7. Take Opportunities To Lead&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-vlada-karpovich-6114991-1.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ylsy6sf6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-vlada-karpovich-6114991-1.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A great way to get noticed within your organization and to be viewed as more than just another developer is to make the most of opportunities to lead. &lt;br&gt;&lt;br&gt;This does not necessarily mean leading projects (in most cases, more experienced engineers lead the projects). Leadership can mean taking opportunities to lead project demos, review sessions, providing help to others, volunteering to be a part of discussions surrounding the project or product, contribute to in-house projects/groups, and doing your absolute best with everything you're tasked with. &lt;br&gt;&lt;br&gt;These things shows that you take initiatives and that you care about what you are doing.&lt;/p&gt;



&lt;h2&gt;8. Keep Learning&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/pexels-burst-545062.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DrENRJ-D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2021/01/pexels-burst-545062.jpg%3Fw%3D1024" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Continuous learning is key in the world of Software Engineering. What's new today might become obsolete tomorrow, and at times we may be working on legacy systems using legacy technologies.&lt;br&gt;&lt;br&gt;Therefore, we need to set aside some time to learn things we are interested in, and to level up on our skills (both technical and non technical). This can be done through reading, taking online courses and watching tutorials. This personal investment will payoff in the future. Also, find a way to share what you learn!&lt;/p&gt;

&lt;p&gt;There you have it, eight (8) tips for Junior Software Engineers - from a fellow Junior Engineer.&lt;/p&gt;

&lt;p&gt;I hope you found these tips helpful. Let me know you're favorite one as well any additional advice in the comment section. Until next time, &lt;em&gt;&lt;strong&gt;think, learn, create, repeat!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devjournal</category>
    </item>
    <item>
      <title>Caching in NodeJS with Redis</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Tue, 12 Jan 2021 14:33:10 +0000</pubDate>
      <link>https://dev.to/taslangraham/caching-in-nodejs-with-redis-4p24</link>
      <guid>https://dev.to/taslangraham/caching-in-nodejs-with-redis-4p24</guid>
      <description>&lt;p&gt;Full post available &lt;a href="https://taslangraham.com/2021/01/12/caching-in-nodejs-with-redis/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Speed performance is critical in modern-day applications. Most of the time your application may have to make requests to an endpoint/server to get some data. Or your application may frequently request a specific dataset. &lt;br&gt;&lt;br&gt;Depending on the size of your dataset along with other things like query database and network speed, the speed at which your application can fetch certain data to display to users may get slower over time (as data increases).&lt;br&gt;&lt;br&gt;This is where caching comes in handy and can dramatically improve your application's speed. In this tutorial we will look at how to implement redis caching in a node application  (API) to improve the speed at which we are able to serve data to client apps. Let's dive in!&lt;/p&gt;

&lt;h2&gt;What is Caching&lt;/h2&gt;

&lt;p&gt;Before we dive into creating our own Redis cache, we have to first answer the question of &lt;em&gt;what is caching&lt;/em&gt;?  &lt;br&gt;&lt;em&gt;&lt;strong&gt;In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient(existing for a short  period of time) in nature, so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to efficiently reuse previously retrieved or computed data&lt;/strong&gt;&lt;/em&gt; -  &lt;a href="https://aws.amazon.com/caching/" rel="noopener noreferrer"&gt;https://aws.amazon.com/caching/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a scenario to help you think about how caching works. Imagine you're watching your favorite sport (Soccer/Football for me ) or the news or a movie.&lt;br&gt; &lt;br&gt;You're also a big fan of Potato chips, so you decide that every 15 minutes you'll go to the kitchen to get a little potato chips to eat.&lt;br&gt; &lt;br&gt;You then noticed that going to the kitchen every 15 minutes is time consuming, not to mention the fact that you miss out a minute or two of what you're watching.&lt;br&gt; &lt;br&gt;So instead of repeatedly making trips to the kitchen you decide fill a large bowl with chips and have it right next to you while watching the TV. &lt;/p&gt;

&lt;p&gt;Now you can get your chips much faster and you don't need to go back to the kitchen unless your bowl is empty or you want a different kind or chips/snack . That bowl of chips is your cache. &lt;/p&gt;

&lt;p&gt;In the world of IT, caching is similar. Data is stored somewhere (the bowl) where it can be accessed fast without having to go to the original source (the kitchen) unless the data needed is not inside the bowl.&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;What is Redis&lt;/h2&gt;

&lt;p&gt;Seeing that we will be using Redis to implement caching inside our node application it makes sense to first discuss what is Redis. Redis is an in memory key value pair database. Yes, you read that right, Redis stores data in memory (RAM). &lt;br&gt;Reading and writing to RAM is magnitudes faster than reading from a disk drive. This makes Redis perfect for caching.&lt;/p&gt;

&lt;h2&gt;Benefits of caching&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Redis cache uses RAM as its storage (more on this further down) which is faster than disk storage, reading from cache is extremely fast. Being able to  read data at higher rates will significantly improve application performance.
&lt;/li&gt;
&lt;li&gt;Caching  frequently requested data will result in a reduction in the number of database queries needed retrieved particular data.
&lt;/li&gt;
&lt;li&gt;Following up on the previous benefit, if we are making less database queries or even less network request to fetch external resources then our application will have lower latency.
&lt;/li&gt;
&lt;li&gt;Your application can scale better since you can cache that is requested more frequently as more person uses your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Node App&lt;/h2&gt;

&lt;p&gt;Now that we understand what caching is and got an introduction to Redis  we will create a node application that utilizes caching through Redis.&lt;br&gt;Our application will be a simple e-commerce API server that allows users to fetch a list products. Let's start coding!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder name node-redis-cache (or whatever you like )&lt;/li&gt;
&lt;li&gt;open the folder inside your text editor(I use VScode)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll be using a few npm packages in our app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;express - handle routing in our app&lt;/li&gt;
&lt;li&gt;redis - use redis commands in node&lt;/li&gt;
&lt;li&gt;axios - to make API calls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open your terminal inside the project folder (&lt;em&gt;node-redis-cache&lt;/em&gt;) and run the following command to install the needed packages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;npm install express redis axios&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The command above installs the express, redis, and axios packages&lt;/p&gt;

&lt;h4&gt;Create Server&lt;/h4&gt;

&lt;p&gt;Now lets finally write some code. We'll first create our express server. Create a file name &lt;em&gt;index.js&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Add the  following imports to &lt;em&gt;index.js&lt;/em&gt;&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;const express = require('express'); 
const app = express();
const axios = require('axios');
const PORT = 9000;

const redis = require("redis");
const cacheClient= redis.createClient(); // redis client used to interact with redis database

app.listen(PORT, () =&amp;gt; console.log(`listening on port ${PORT}`));&lt;/pre&gt;



&lt;p&gt;We've created our server and set it to listen on port 9000. We've also required in the redis and axios packages which we'll use later on.&lt;/p&gt;



&lt;h3&gt;
&lt;br&gt;Route&lt;/h3&gt;



&lt;p&gt;Now we'll add a route that returns a list of products to the user. Add the following to &lt;em&gt;index.js&lt;/em&gt;&lt;/p&gt;



&lt;pre class="wp-block-syntaxhighlighter-code"&gt;app.get('/products', async (req, res) =&amp;gt; {
  const { data } = await axios.get('https://fakestoreapi.com/products'); // This is a real API ;)
  return res.send(data);
});&lt;/pre&gt;



&lt;p&gt;Here we've created a route handler for &lt;strong&gt;&lt;em&gt;/products&lt;/em&gt;&lt;/strong&gt; that will return a list of products. We are making a request to an external API to get these products.&lt;br&gt;&lt;br&gt;Lets assume that this external API also makes a database request get this list of products. As you can see, when a user requests the list of available products it may take a while for them to get a response. &lt;/p&gt;



&lt;h3&gt;API Speed (without cache)&lt;/h3&gt;



&lt;p&gt;Let's test our endpoint using &lt;a rel="noreferrer noopener" href="https://www.postman.com/"&gt;postman&lt;/a&gt; (or your favorite API testing tool).  This will show us the speed performance of our application without caching.&lt;/p&gt;



&lt;a href="https://taslangraham.files.wordpress.com/2021/01/request-1.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2021%2F01%2Frequest-1.jpg%3Fw%3D1024" alt=""&gt;&lt;/a&gt;



&lt;p&gt;Without caching implemented our API request takes &lt;strong&gt;1540 milliseconds&lt;/strong&gt; (or 1.54 seconds) to be processed. Now let's add caching to our route handler.&lt;/p&gt;



&lt;h3&gt;Adding caching&lt;/h3&gt;



&lt;p&gt;Update the &lt;em&gt;&lt;strong&gt;/products&lt;/strong&gt;&lt;/em&gt; route handler to the following. &lt;/p&gt;



&lt;pre class="wp-block-syntaxhighlighter-code"&gt;app.get('/products', async (req, res) =&amp;gt; {
    const TIME_TO_LIVE = 1800; // 30 minutes as seconds

    cacheClient.get("products", async (err, cachedProducts) =&amp;gt; {
        if (cachedProducts) {
            res.send(JSON.parse(cachedProducts));
        } else {
            const { data } = await axios.get('https://fakestoreapi.com/products');
            cacheClient.setex("products", TIME_TO_LIVE, JSON.stringify(data))
            return res.send(data);
        }
    });
});
&lt;/pre&gt;

&lt;p&gt;Here, we are changing how our &lt;strong&gt;&lt;em&gt;/products&lt;/em&gt;&lt;/strong&gt; route handler operates. When we get a request to fetch for products, we first check to see if we already have that data available in cache.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;If the cached data is available then we return that to the user. If there's no cached data available, we first make a call to the external API for the data.  Then we cache the newly fetched data. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;sete&lt;/em&gt;x()&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;method allows us to set the Time To Live (TTL) for the cached data. This means that after the specified amount of time (in seconds) the cached data will be deleted. Finally we return the data to the user.&lt;/p&gt;

&lt;h3&gt;API Speed (with cache)&lt;/h3&gt;

&lt;p&gt;This will show us the speed performance of our application with caching implemented. Lets make a call to the API endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/request-3-1.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2021%2F01%2Frequest-3-1.jpg%3Fw%3D1024" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whoa, wait, that's not much faster! Why is that so? On the first request, there's no data in the cache, so we'd have to the make a call to the external API which will take some time. The fetched data is then cached and is available on subsequent requests. So, let's make another request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taslangraham.files.wordpress.com/2021/01/request-4.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2021%2F01%2Frequest-4.jpg%3Fw%3D1024" alt=""&gt;&lt;/a&gt;Now look at that! Our request took only &lt;strong&gt;2 milliseconds&lt;/strong&gt; (or 0.002 seconds). That's fast, very fast compared to when we don't have cache implemented.&lt;br&gt;&lt;br&gt;As you can see, caching can significantly improve your application's performance. There's a lot more to redis caching and caching in general. If you're interested in learning more about caching and redis, see the following links:&lt;/p&gt;

&lt;p&gt;https://aws.amazon.com/caching/&lt;/p&gt;

&lt;p&gt;https://www.cloudflare.com/learning/cdn/what-is-caching/&lt;/p&gt;

&lt;p&gt;https://wp-rocket.me/blog/different-types-of-caching/&lt;/p&gt;

&lt;p&gt;https://redis.io/documentation&lt;/p&gt;

&lt;p&gt;https://www.npmjs.com/package/redis&lt;br&gt;&lt;br&gt;If you found this helpful leave a comment below and share with devs who will find it useful. Until next time &lt;em&gt;think, learn, create, repeat&lt;/em&gt;.&lt;/p&gt;

</description>
      <category>node</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript call, bind, and apply methods</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Sat, 28 Nov 2020 18:48:38 +0000</pubDate>
      <link>https://dev.to/taslangraham/js-call-bind-and-apply-methods-301m</link>
      <guid>https://dev.to/taslangraham/js-call-bind-and-apply-methods-301m</guid>
      <description>&lt;p&gt;Full post available &lt;a href="https://taslangraham.com/2020/11/28/js-call-bind-and-apply-methods/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Each JavaScript function has access to the &lt;em&gt;this &lt;/em&gt;keyword. The &lt;em&gt;this &lt;/em&gt;keyword references the object to which the function belongs (remember, everything in JS is an Object). &lt;/p&gt;

&lt;p&gt;This sounds straightforward enough but, things can quickly get tricky when working with &lt;em&gt;this.&lt;/em&gt; Why? The value of &lt;em&gt;this&lt;/em&gt; is determined by how/where the function was executed:&lt;/p&gt;

&lt;ul id="block-b8cac825-336b-46ce-bbc7-5430c6799d15"&gt;
&lt;li&gt;In a method, &lt;em&gt;this&lt;/em&gt; refers to the &lt;strong&gt;owner object&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Alone, &lt;em&gt;this&lt;/em&gt; refers to the &lt;strong&gt;global object&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In a function, &lt;em&gt;this&lt;/em&gt; refers to the &lt;strong&gt;global object&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In a function, in strict mode, &lt;em&gt;this &lt;/em&gt;is &lt;em&gt;undefined&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;In an event,&lt;em&gt; this &lt;/em&gt;refers to the &lt;strong&gt;element&lt;/strong&gt; that received the event.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that if we are not careful we can lose the scope of &lt;em&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Luckily, all JavaScript function object has access to some very special methods which we can use to explicitly state what &lt;em&gt;&lt;strong&gt;this &lt;/strong&gt;&lt;/em&gt;should reference. These methods are &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;, &lt;strong&gt;call()&lt;/strong&gt;,  &amp;amp; &lt;strong&gt;apply()&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;



&lt;h2&gt;
&lt;br&gt;Bind&lt;/h2&gt;





&lt;p&gt;&lt;br&gt;The &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt; method creates a new function that, when called, has its &lt;strong&gt;&lt;em&gt;this&lt;/em&gt; &lt;/strong&gt;keyword reference the provided value.&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;greeting&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&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;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; says hi!`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;john&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;johnGreeting&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="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;john&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;br&gt;Above, we created the function &lt;em&gt;greeting&lt;/em&gt;, then on line &lt;em&gt;11&lt;/em&gt;, we used the &lt;strong&gt;&lt;em&gt;bind &lt;/em&gt; &lt;/strong&gt;method to tell the function that the &lt;em&gt;&lt;strong&gt;this &lt;/strong&gt;&lt;/em&gt;keyword should point to the object &lt;em&gt;&lt;strong&gt;john&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;





&lt;p&gt;This then returns a new function which we store inside &lt;em&gt;&lt;strong&gt;johnGreeting&lt;/strong&gt;&lt;/em&gt;. We can then execute &lt;em&gt;&lt;strong&gt;johnGreeting&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;johnGreeting&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// John says hi!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;










&lt;p&gt;The &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt; &lt;/em&gt;method can also accept arguments. These will come after the &lt;strong&gt;&lt;em&gt;this&lt;/em&gt; &lt;/strong&gt;argument. Here's an example:&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;greeting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;country&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&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;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; says hi! from &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;country&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;john&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;














&lt;p&gt;Here our greeting function now accepts an argument, &lt;em&gt;country&lt;/em&gt;. We can now pass an additional parameter to the &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt; method.&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;const&lt;/span&gt; &lt;span class="nx"&gt;johnGreeting&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="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;john&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Jamaica&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;johnGreeting&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// John says hi! from Jamaica&lt;/span&gt;

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

&lt;/div&gt;




&lt;h2&gt;
&lt;br&gt;Call&lt;/h2&gt;





&lt;p&gt;&lt;br&gt;The &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt;&lt;/em&gt; method calls a function with a given &lt;em&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/em&gt;. The difference between the &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt;&lt;strong&gt; &lt;/strong&gt;and the &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt;&lt;/em&gt; is that the &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt;&lt;/em&gt; method does not create a new function, instead it immediately executes the function. Here's an example:&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;printName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&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;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;lastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Taslan&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Graham&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;printName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="c1"&gt;// Taslan Graham&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;










&lt;p&gt;Here we created a function, &lt;em&gt;&lt;strong&gt;printName&lt;/strong&gt;&lt;/em&gt;, and an object &lt;em&gt;&lt;strong&gt;student&lt;/strong&gt;&lt;/em&gt;. We then, on line 10, executed the &lt;strong&gt;&lt;em&gt;printName&lt;/em&gt; &lt;/strong&gt;function by calling the &lt;strong&gt;call() &lt;/strong&gt;method on it and passing student object as the &lt;strong&gt;&lt;em&gt;this&lt;/em&gt; &lt;/strong&gt;that &lt;em&gt;&lt;strong&gt;printName &lt;/strong&gt;&lt;/em&gt;should use.&lt;/p&gt;





&lt;p&gt;Similarly to the &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt; method, the &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt; &lt;/em&gt;method can accept arguments.&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;printName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Name: &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;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;lastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Age:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Taslan&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Graham&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;printName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Name: Taslan Graham, Age:24&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Here our greeting function now accepts an argument, &lt;em&gt;age&lt;/em&gt;. We can now pass an additional parameter to the &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt;&lt;/em&gt; method.&lt;/p&gt;





&lt;h2&gt;
&lt;br&gt;Apply&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;br&gt;Like the the methods above,  the &lt;em&gt;&lt;strong&gt;apply()&lt;/strong&gt;&lt;/em&gt; method calls a function with a given &lt;em&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/em&gt;. It is very similar to the &lt;em&gt;&lt;strong&gt;call()&lt;/strong&gt;&lt;/em&gt;  method, the difference being that the &lt;em&gt;&lt;strong&gt;apply()&lt;/strong&gt; &lt;/em&gt;method accepts arguments as an array.&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;const&lt;/span&gt; &lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;details&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&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="s2"&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;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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="kd"&gt;class&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;graham&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Graham&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Intro to Computer Science&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;details&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;graham&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Graham, Intro to Computer Science&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;Here we have an object, &lt;em&gt;&lt;strong&gt;student&lt;/strong&gt;&lt;/em&gt;, which has a method called &lt;em&gt;&lt;strong&gt;details&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We also have another object, &lt;em&gt;&lt;strong&gt;graham&lt;/strong&gt;&lt;/em&gt;, this object does not have the &lt;strong&gt;&lt;em&gt;details&lt;/em&gt; &lt;/strong&gt;method, but we used the &lt;em&gt;&lt;strong&gt;apply()&lt;/strong&gt; &lt;/em&gt; method to tell the the &lt;em&gt;&lt;strong&gt;details()&lt;/strong&gt; &lt;/em&gt;method of &lt;strong&gt;&lt;em&gt;student&lt;/em&gt; &lt;/strong&gt;that its &lt;em&gt;&lt;strong&gt;this &lt;/strong&gt;&lt;/em&gt;value should point to the the &lt;strong&gt;&lt;em&gt;graham&lt;/em&gt; &lt;/strong&gt;object.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;span&gt;Note: bind() &amp;amp; call() can be used in the way apply() is used aboved. &lt;/span&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;&lt;strong&gt;apply()&lt;/strong&gt;&lt;/em&gt; method can also accept additional arguments. These are passed as an array. &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;printName&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Name: &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;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;lastName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Age:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt; Country: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;args&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="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;student&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Taslan&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Graham&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;country&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Jamaica&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;printName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;student&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;country&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// Name: Taslan Graham, Age:24 Country: Jamaica&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;Above, we passed an array holding &lt;em&gt;age &lt;/em&gt;and &lt;em&gt;country &lt;/em&gt;to our &lt;em&gt;&lt;strong&gt;printName &lt;/strong&gt;&lt;/em&gt;function. We use the &lt;a rel="noreferrer noopener" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters"&gt;rest parameters&lt;/a&gt; to capture this array, then we print the values from their respective indexes. &lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;As you can see, the &lt;em&gt;&lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt;, &lt;strong&gt;&lt;em&gt;call()&lt;/em&gt;,&lt;/strong&gt;&lt;em&gt;  &lt;strong&gt;bind()&lt;/strong&gt;&lt;/em&gt; are very powerful when we want want to determine what  the &lt;strong&gt;&lt;em&gt;this &lt;/em&gt;&lt;/strong&gt;value inside of a function should be. They all work similarly but with there own unique differences. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;bind()&lt;/em&gt;&lt;/strong&gt; method creates a new function with the &lt;strong&gt;this&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;value provided to it. While the &lt;strong&gt;&lt;em&gt;call()&lt;/em&gt;&lt;/strong&gt; method immediately executes a function with the given &lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt; value. Similarly to  the &lt;strong&gt;&lt;em&gt;call()&lt;/em&gt;&lt;/strong&gt; method, &lt;strong&gt;&lt;em&gt;apply()&lt;/em&gt;&lt;/strong&gt; immediately executes the function with the given &lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt; value but, it accepts its arguments as an array.&lt;br&gt;&lt;br&gt;Hope you found this helpful. Be sure to leave comments below on the interesting ways you've used &lt;em&gt;call(), bind(), and apply()&lt;/em&gt;.&lt;br&gt;&lt;br&gt;Until next time, &lt;em&gt;think, learn, create, repeat!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
    </item>
    <item>
      <title>Creating JS objects that has no prototype</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Tue, 17 Nov 2020 05:14:20 +0000</pubDate>
      <link>https://dev.to/taslangraham/creating-js-objects-that-has-no-prototype-5d1l</link>
      <guid>https://dev.to/taslangraham/creating-js-objects-that-has-no-prototype-5d1l</guid>
      <description>&lt;p&gt;We know that All JavaScript objects inherit properties and methods from a prototype.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;strong&gt;Date&lt;/strong&gt; objects inherit from Date.prototype&lt;br&gt;
&lt;strong&gt;Array&lt;/strong&gt; objects inherit from Array.prototype&lt;/p&gt;

&lt;p&gt;What if you want to create an Object that does not have a prototype?&lt;br&gt;
Here's a neat little way to do it:&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;const&lt;/span&gt; &lt;span class="nx"&gt;blankObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When creating objects using Object.create(), we can pass an object which will be used as the prototype for the newly created object. Alternatively, we can pass &lt;em&gt;&lt;strong&gt;null&lt;/strong&gt;&lt;/em&gt; which will result in an object being created without a prototype.&lt;/p&gt;

&lt;p&gt;I only came across this recently. I think it's pretty cool and I may find some use for it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Things tech students should consider doing</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Thu, 22 Oct 2020 03:49:00 +0000</pubDate>
      <link>https://dev.to/taslangraham/things-tech-students-should-consider-doing-4jd5</link>
      <guid>https://dev.to/taslangraham/things-tech-students-should-consider-doing-4jd5</guid>
      <description>&lt;p&gt;Full article can be found &lt;a&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hey all! Welcome back. I hope you're all doing well. In this article, I want to talk about a few things that I believe university tech students should consider doing. &lt;br&gt;
I've decided to write about this for two primary reasons, 1) as I start to approach the end of my time in university, I've started to reflect on what the past four years were like. &lt;br&gt;
Things I did as a Student and things I didn't do.  
Secondly, a friend recently asked me  "why should I do an internship?" and that got me thinking about what are the things that students should consider doing. &lt;/p&gt;

&lt;p&gt;The following are some things that I've either done myself or witnessed other Students do, with great success during my time at university. &lt;/p&gt;

&lt;h2&gt;Attend Tech Conferences&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1505373877841-8d25f7d46678%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D700%26q%3D80" 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%2Fimages.unsplash.com%2Fphoto-1505373877841-8d25f7d46678%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D700%26q%3D80" alt=""&gt;&lt;/a&gt;Tech conference&lt;/p&gt;

&lt;p&gt;Attending tech conferences is something that I love doing. Conferences provide a great opportunity for you to learn about current trends from industry experts, network with said experts and others. &lt;br&gt;
An exciting thing about some tech conferences is that they highlight information technology's role in propelling other industries forward. &lt;br&gt;
This has helped me to fully appreciate the level of impact that information technology can have when combined with other industries.
So, if you want to learn about current trends, meet experts, and see technology's impact across multiple industries then you should definitely attend conferences. &lt;/p&gt;

&lt;p&gt;Some conferences are expensive, so you should consider volunteering at a conference, or going to the ones that are free or within your budget.&lt;/p&gt;

&lt;h2&gt;Join tech groups/communities&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nappy.co%2Fwp-content%2Fuploads%2F2019%2F12%2F20191208-7Z8A1154-scaled.jpg" 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%2Fwww.nappy.co%2Fwp-content%2Fuploads%2F2019%2F12%2F20191208-7Z8A1154-scaled.jpg" alt=""&gt;&lt;/a&gt;Tech group&lt;br&gt;&lt;/p&gt;

&lt;p&gt;This is something I've started doing in the last twelve (12) months. I've join joined Google Developers Group(Kingston, Jamaica) and Facebook Developer Circles (Kingston, Jamaica) in my area.&lt;br&gt;
Joining a tech group allows you to meet like-minded individuals, have insightful conversations, hear about different technologies, and learn from professionals and hear them talk about their experiences.&lt;br&gt;
This may create a job opportunity for you. Tech groups may also create an opportunity for individuals to collaborate.&lt;br&gt;
Recently, at Google Developers' Group meetup, a friend of mine spoke about an application he was working on, and someone immediately expressed interest in collaborating with him!&lt;/p&gt;

&lt;h2&gt;Participate in hackathons&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2Fhackathon.jpg%3Fw%3D1024" 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%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2Fhackathon.jpg%3Fw%3D1024" alt=""&gt;&lt;/a&gt;Me(red shirt) at last year's Coder of the Caribbean Hackathon.&lt;/p&gt;

&lt;p&gt;Hackathons are fun and provide an opportunity to solve real world problems.&lt;br&gt;
Hackathons teaches you how to create under pressure,  work in teams, and compete. All while having fun. I talk more about hackathons in a recent article, &lt;a href="https://taslangraham.com/2020/01/20/why-tech-students-should-participate-in-hackathons/" rel="noopener noreferrer"&gt;Why tech students should participate in hackathons&lt;/a&gt;. Give it a read to learn more about the hackathon experience.&lt;/p&gt;

&lt;h2&gt;Seek Internships&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.pexels.com%2Fphotos%2F3339712%2Fpexels-photo-3339712.jpeg%3Fauto%3Dcompress%26cs%3Dtinysrgb%26dpr%3D2%26h%3D650%26w%3D940" 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%2Fimages.pexels.com%2Fphotos%2F3339712%2Fpexels-photo-3339712.jpeg%3Fauto%3Dcompress%26cs%3Dtinysrgb%26dpr%3D2%26h%3D650%26w%3D940" alt=""&gt;&lt;/a&gt;Intern using computer&lt;/p&gt;

&lt;p&gt;Internships have provided the most value to me over the past year. Internships can be very important to your success in the professional world after university.&lt;br&gt;
A quality internship allows you to apply the concepts learnt in the classroom in a real world environment while achieving personal growth,  and learning new tools, technologies and concepts.&lt;br&gt;
You'll also meet great co-workers and make new friends within the tech industry. &lt;/p&gt;

&lt;p&gt;For most internships, you'll be working on a product which will be delivered throughout or at the end of the internship period.&lt;br&gt;
An important thing to note is that internships can create an opportunity for employment after graduation. &lt;/p&gt;

&lt;p&gt;I've written about my personal internship experience here, &lt;a href="https://taslangraham.com/2020/01/27/reflections-on-my-first-internship/" rel="noopener noreferrer"&gt;reflections on my first internship&lt;/a&gt;. &lt;br&gt;
If you'd like to know how to land internships, then read &lt;a href="https://techbyteswithdrew.wordpress.com/2020/01/12/how-to-be-creative-in-finding-tech-internships/" rel="noopener noreferrer"&gt;Deandrew's article on finding interships&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Pursue interests outside of tech&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2Fm50_7799.jpg%3Fw%3D1024" 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%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2Fm50_7799.jpg%3Fw%3D1024" alt=""&gt;&lt;/a&gt;Taslan holding camera&lt;/p&gt;

&lt;p&gt;Yes, you read that right. It is important to pursue your interests outside of tech. Love volunteering? Do it.&lt;br&gt;
Love taking pictures, debating, teaching others, playing a sport? Whatever it is, pursue those interests outside of tech.&lt;br&gt;
This will create new experiences for you, you'll meet people with similar interests. You may even be able to merge one of your interests with technology. &lt;/p&gt;

&lt;p&gt;For me, my main interests outside of technology at the moment are photography and videography.&lt;br&gt;
Recently I've also joined an organization name Youth Can Do I.T, which aims to  use technology and strengths based initiatives to develop and empower the youth. &lt;br&gt;
This has allowed me to pursue a long lasting interest of mine, improving digital literacy. &lt;/p&gt;

&lt;h2&gt;Bonus - Make use of opportunities that allows you to travel&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2F20181025_141313.jpg%3Fw%3D768" 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%2Ftaslangraham.files.wordpress.com%2F2020%2F03%2F20181025_141313.jpg%3Fw%3D768" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the start of my third year in university I started to realise that there are a lot of opportunities available to university students to travel (international &amp;amp; domestic) while pursuing their interests.&lt;br&gt;
Take the opportunity to travel, while in university, at least once.  I know persons who got to travel on numerous occasions by taking advantage of opportunities available to university students.&lt;br&gt;
I've also had the opportunity to travel halfway around the world,  and visit the headquarters of a fortune 500 company,  free of cost!&lt;/p&gt;

&lt;p&gt;That's it, the things I believe tech students should considering doing while in university. Attending tech conferences, joining tech groups/communities, participate in hackathons, seeking internships, pursuing your interests outside of tech, and taking advantages of travelling opportunities all have potential to enhance your university experience. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is localStorage?</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Sat, 26 Sep 2020 18:08:32 +0000</pubDate>
      <link>https://dev.to/taslangraham/localstorage-23ec</link>
      <guid>https://dev.to/taslangraham/localstorage-23ec</guid>
      <description>&lt;p&gt;Full article can be found &lt;a href="https://taslangraham.com/2020/09/26/mastering-localstorage/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;LocalStorage is a web storage which allows you to store and access data as key:value pairs inside a Web Browser using JavaScript.  Data stored with localStorage is permanent and stays forever unless deleted manually or programmatically .&lt;/p&gt;

&lt;p&gt;In this article we will look at the five (5) methods available when using local storage, the benefits of localStorage and things to consider when using it.&lt;/p&gt;

&lt;h3&gt;Methods&lt;/h3&gt;

&lt;p&gt;As mentioned above, you have five (5) methods available when working with localStorage. These are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;setItem()&lt;/strong&gt;&lt;/em&gt; - saves a key:value pair to localStorage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;getItem()&lt;/em&gt;&lt;/strong&gt; - retrieve an item in localStorage via a key&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;removeItem() &lt;/strong&gt;&lt;/em&gt;- deletes the item for the given key&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;clear()&lt;/em&gt;&lt;/strong&gt; - deletes all items&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;key()&lt;/strong&gt;&lt;/em&gt; - returns the key at the given index&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before we look at each method, it is important to understand that the localStorage operated on will be the current domain from which the methods are executed.&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;setItem(&lt;em&gt;key, value&lt;/em&gt;)&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;You use  the &lt;strong&gt;setItem&lt;/strong&gt; method to store new data inside localStorage. It accepts a &lt;em&gt;key &lt;/em&gt;and a &lt;em&gt;value. &lt;/em&gt;&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;localStorage.setItem('school', 'University of Technology, Jamaica');&lt;/pre&gt;



&lt;p&gt;The above code will create a key named &lt;strong&gt;&lt;em&gt;school&lt;/em&gt; &lt;/strong&gt;and store it with the value &lt;strong&gt;&lt;em&gt;university of Technology, Jamaica&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h5&gt;Storing Objects in localStorage&lt;/h5&gt;

&lt;p&gt;It's important to note that localStorage can only store string values. If we want to store an object, we have to first convert it to a string value. We do so using the JSON.stringify() method.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;// Create user object

let user = {
  name: 'Taslan Graham',
  nationality: 'Jamaican'
};

localStorage.setItem('user', JSON.stringify(user)); // Stores user as JSON string
&lt;/pre&gt;



&lt;p&gt;The above will convert the &lt;code&gt; user&lt;/code&gt; object to &lt;code&gt;"{"name":"Taslan Graham","nationality":"Jamaican"}"&lt;/code&gt; and store it.&lt;/p&gt;



&lt;h4&gt;&lt;strong&gt;getItem(&lt;em&gt;key&lt;/em&gt;)&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;The getItem() method accepts a key and returns its value.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;localStorage.getItem('school');&lt;/pre&gt;



&lt;p&gt;This will return &lt;code&gt;'University of Technology, Jamaica'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can also retrieve the &lt;strong&gt;user&lt;/strong&gt; item stored earlier.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;let user = localStorage.getItem('user');&lt;/pre&gt;













&lt;p&gt;This returns &lt;code&gt;"{"name":"Taslan Graham","nationality":"Jamaican"}"&lt;/code&gt;. We can convert this JSON string value back into a JavaScript object.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;JSON.parse(user); // {name: "Taslan Graham", nationality: "Jamaican"}
&lt;/pre&gt;





&lt;h4&gt;&lt;strong&gt;removeItem(&lt;em&gt;key&lt;/em&gt;)&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;removeItem &lt;/strong&gt;method accepts a key and deletes it from localStorage, if it exists.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;localStorage.removeItem('school');&lt;/pre&gt;

&lt;h4&gt;&lt;strong&gt;clear()&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;clear&lt;/strong&gt; method will delete all data inside localStorage for the domain.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;localStorage.clear();&lt;/pre&gt;



&lt;h4&gt;&lt;strong&gt;key()&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;key&lt;/strong&gt; method accepts a number(&lt;em&gt;n) &lt;/em&gt;and returns the &lt;em&gt;nth&lt;/em&gt; key inside in the localStorage object;  &lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;localStorage.key(0)&lt;/pre&gt;



&lt;p&gt;The above code would return the first key inside localStorage.&lt;/p&gt;



&lt;p&gt;The &lt;strong&gt;key&lt;/strong&gt; method can be useful when we want to access each key inside localStorage without knowing their names.&lt;/p&gt;



&lt;pre class="wp-block-syntaxhighlighter-code"&gt;for(const i = 0; i &amp;lt; localStorage.length; i++){
  const key = localStorage.key(i);
  console.log(localStorage.getItem(key);
}&lt;/pre&gt;



&lt;p&gt;In the above code, we start looping at zero and for each iteration we use the value of  &lt;strong&gt;i &lt;/strong&gt;to retrieve the key at that position inside localStorage; we store the key inside the &lt;strong&gt;key&lt;/strong&gt; variable. We then log the value of the current key to the console.&lt;/p&gt;













&lt;h3&gt;Benefits of localStorage&lt;/h3&gt;

&lt;p&gt;localStorage provides some very interesting benefits. These includes:&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;1. localStorage is supported by the major modern browsers. &lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;This means you can use it within your app without worries.&lt;/p&gt;

&lt;p&gt; But, if you want to ensure that the user's browser supports localStorage, you can do the following.&lt;/p&gt;

&lt;pre class="wp-block-syntaxhighlighter-code"&gt;if (typeof(Storage) !== "undefined") {
    // Write code for localStorage here
    } else {
     // No localStorage support
    // Do something else
}&lt;/pre&gt;

&lt;h4&gt;&lt;strong&gt;2. Can be used for simple caching&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;Most browsers provides up to 10MB for web storage. This means you could use localStorage for caching data which rarely changes and is accessed often throughout your application.&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;3. The data can be accessed easily and quickly&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;You can retrieve data without making a network call.&lt;/p&gt;



&lt;h3&gt;Things to consider&lt;/h3&gt;

&lt;p&gt;When using localStorage there a couple of things to take into consider. Well, they are more like thing &lt;strong&gt;not to do&lt;/strong&gt; when using localStorage.&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;1. Don't store sensitive data in localStorage&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;There's no security associated with localStorage. Anyone can view the data. Therefore , it is not suitable for storing sensitive information such as user passwords.&lt;/p&gt;



&lt;h4&gt;&lt;strong&gt;2. You may still need an actual database&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;The data stored is localized to the user's browser and is only accessible there. Therefore localStorage is not a substitute for a database. &lt;/p&gt;

&lt;p&gt;In this article we covered localStorage, and the methods available when working with it. Additionally, we looked at some benefits of localStorage as well as some things to take into consideration when using localStorage.&lt;/p&gt;

&lt;p&gt;If you enjoy this article, leave a comment about what was most valuable to you. Also share with friends who might find it useful.&lt;/p&gt;

&lt;p&gt;Until next time, &lt;em&gt;Think, Learn, Create, Repeat!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Keep at it</title>
      <dc:creator>Taslan Graham</dc:creator>
      <pubDate>Wed, 23 Sep 2020 06:44:20 +0000</pubDate>
      <link>https://dev.to/taslangraham/keep-at-it-273d</link>
      <guid>https://dev.to/taslangraham/keep-at-it-273d</guid>
      <description>&lt;p&gt;Full article can be found &lt;a href="https://taslangraham.com/2020/05/17/keep-at-it/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Dealing with doubt and change as a techie.&lt;/h2&gt;

&lt;p&gt;With a pat on my shoulder, the teacher looked at me and said "keep at it!". What? I asked myself. Am I coming to university to hear such nonsense from a teacher? &lt;/p&gt;

&lt;p&gt;At that time I had no idea how impactful this simple phrase could be. As I progressed through university, learnt new skills, and grasp abstract concepts in courses, I noticed the increasing frequency at which I had to tell myself "keep at it". Maybe my teacher was on to something!&lt;/p&gt;

&lt;p&gt;Hey all, welcome back! I hope you and your family are all safe during this pandemic. Recently,  I've been thinking a lot about the the battles young tech students, and  professionals face. Therefore, I'm writing this article to discuss some of those battles and how you can overcome them.&lt;/p&gt;

&lt;p&gt;There are two specific challenges that I want to discuss, namely self-doubt and dealing with changes.&lt;/p&gt;

&lt;h1&gt;Self-doubt&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XoUE_t-a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/question-mark-1872634_1920.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XoUE_t-a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/question-mark-1872634_1920.jpg%3Fw%3D1024" alt="" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In simple terms, self-doubt can be defined as a feeling of uncertainty regarding certain aspects of yourself, such as your skills or talents.&lt;/p&gt;

&lt;p&gt;Self doubt can be crippling to anyone's progress throughout life. &lt;/p&gt;

&lt;p&gt;With the nature of the tech industry, letting self doubt run free will most certainly result in you losing out on opportunities, relationships, and much more. Understanding your  doubts, and learning to deal with them can be empowering. &lt;/p&gt;

&lt;p&gt;Self doubt may appear in different forms. You may find yourself saying things like "am I good enough or ready to do this?", "will I be able to complete task?", "are my skills enough to apply for this internship".&lt;/p&gt; 

&lt;p&gt;You may even notice some levels of anxiety, procrastination, and difficulty making decisions when you're experiencing self doubt. For me, I tend to ask myself "can I do this?".&lt;/p&gt;

&lt;p&gt;That's how I know that some form of self doubt is creeping in. So, how does one cope with self doubt?&lt;/p&gt;

&lt;p&gt;These are some simple techniques that I've found to be helpful:&lt;/p&gt;

&lt;h2&gt;Change the way you view self doubt&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HrvjT12T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/elena-taranenko-hcua4xtxvta-unsplash.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HrvjT12T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/elena-taranenko-hcua4xtxvta-unsplash.jpg" alt="Change the way you view self doubt" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to understand that some level of self doubt is normal when you are faced with new or challenging situations.&lt;/p&gt;

&lt;p&gt;Use self doubt as an indication to self assess and identify the areas/skills  that you may need to improve on in order to accomplish the initial goal that triggered the doubt. &lt;/p&gt;

&lt;h2&gt;Use past success to push yourself&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NBFKFp4B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/macro-photography-of-green-butterfly-on-yellow-cocoon-1464733.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NBFKFp4B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/macro-photography-of-green-butterfly-on-yellow-cocoon-1464733.jpg" alt="past experience" width="800" height="1252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look back, you'll definitely find a past experiences where you had some level of doubt, but still propelled above it. Use these experiences as a source of strength to overcome your current situation.&lt;/p&gt;

&lt;h2&gt;Take action&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gNzIbeBF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/man-doing-a-dunk-2820906.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gNzIbeBF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/man-doing-a-dunk-2820906.jpg" alt="take action" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Doubt can only be removed by action.”&lt;/p&gt;
&lt;cite&gt;&lt;strong&gt;Johann Wolfgang von Goethe&lt;/strong&gt;&lt;/cite&gt;
&lt;/blockquote&gt;

&lt;p&gt;After you start to work on something you'll start to notice that your doubts gradually dissipates. Personally, this is something I keep in the back of mind, "&lt;em&gt;doubt can only be removed by action&lt;/em&gt;". &lt;/p&gt;

&lt;p&gt;So I do my best to take action regardless of my doubts, knowing that eventually, at some point, the doubt will fade away. Then, surprisingly at the end of it you realise that it really wasn't as bad as you thought.&lt;/p&gt;

&lt;p&gt;For example, in 2018 I worked as a software developer for the first time. I was tasked with implementing an image cropper as a feature within a web application.&lt;/p&gt;

&lt;p&gt;At first I was uncertain about my ability to complete this task, but I worked on it regardless. Eventually,  the doubt faded, and soon thereafter the feature was implemented. &lt;/p&gt;
 

&lt;p&gt;Ironically, at the time of writing this, a friend reached out to me asking for assistance in implementing an image cropper with the same framework &amp;amp; library I used in 2018. &lt;/p&gt;
 


&lt;h1&gt;Dealing with changes&lt;/h1&gt;



&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bASM5wjc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/change-4056014_1920-1.jpg%3Fw%3D1024" alt="" width="800" height="516"&gt;





&lt;p&gt;Changes are inevitable, and it seems to happen every hour in the tech industry. It can be a daunting task for tech students, and professionals to keep up with or adjust to the changes happening. However, it is important be able to do so.  So, how do you manage changes?&lt;/p&gt;

&lt;p&gt;Here's some tips that may work:&lt;/p&gt;

&lt;h2&gt;Be open to change&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XY3qaDR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/illuminated-1853924_1920-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XY3qaDR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/illuminated-1853924_1920-1.png" alt="Be open to change" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Never make the mistake of becoming overly attached to a particular technology, language, framework, or process. This will make you a bit resistant to using an alternative. &lt;/p&gt;

&lt;p&gt;Thus, making it harder for you to adjust accordingly in the event that what you're using has suddenly becomes obsolete (which could happen before you finish reading this), or there are truly better alternatives which you should consider.&lt;/p&gt;

&lt;p&gt;Without having to go into details, I can confidently say that the current pandemic has taught us all to be open to change.&lt;/p&gt;

&lt;h2&gt;Fall in love with learning&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Av8WGRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/guy-2557251_1920.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Av8WGRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/guy-2557251_1920.jpg" alt="Fall inlove with learning" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a part of the tech industry means that you will be continuously learning something new in order to get things done.&lt;/p&gt;

&lt;p&gt;Learning is an everyday aspect of this industry, and changes usually means you have to learn something new. A new language,  framework, way of doing things, way of thinking, or something new about the things you already know. You simply have to love learning so that you can stay atop of things. &lt;/p&gt;

&lt;p&gt;This doesn't mean we should try to learn everything there is. I was once like that. Learning something takes time and effort, so you should ensure that the decision to learn something is an informed one or one that simply had to be made. &lt;/p&gt;

&lt;h2&gt;Follow experts on social media&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S0posSI_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/hexagon-1743514_1920-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S0posSI_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/05/hexagon-1743514_1920-1.png" alt="Follow experts" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow industry experts on social media to get insights into what's happening or is about to happen. Experts are usually on top of the different shifts happening in the industry. &lt;/p&gt;

&lt;p&gt;For example, I follow JavaScript experts on twitter see their views on things related to the language. When they discuss certain techniques I think about how I can change the way I'm doing certain things to incorporate these techniques.&lt;/p&gt;

&lt;p&gt;Doubts, and changes can prove difficult to handle. I have shared some things that I do to deal with both doubt and changes. Regardless of the challenges you may face in dealing with both doubt and change, it is important to stay on course, never give up. Simply, &lt;strong&gt;keep at it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this helpful. Until next time, think, learn, create, repeat.&lt;/p&gt;

&lt;p&gt;Found this article useful?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/taslan"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8q5Q43-_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://taslangraham.files.wordpress.com/2020/09/default-orange.png%3Fw%3D434" alt="" width="434" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a rel="noreferrer noopener" href="https://www.buymeacoffee.com/taslan"&gt;&lt;/a&gt;&lt;/p&gt;

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