<?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: alimemonzx</title>
    <description>The latest articles on DEV Community by alimemonzx (@alimemonzx).</description>
    <link>https://dev.to/alimemonzx</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%2F565970%2F5472f9af-346d-41e3-9a46-22f8e03626f0.jpeg</url>
      <title>DEV Community: alimemonzx</title>
      <link>https://dev.to/alimemonzx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alimemonzx"/>
    <language>en</language>
    <item>
      <title>The must listen Podcast If you are a CEO </title>
      <dc:creator>alimemonzx</dc:creator>
      <pubDate>Fri, 29 Jan 2021 14:35:37 +0000</pubDate>
      <link>https://dev.to/alimemonzx/the-must-listen-podcast-if-you-are-a-ceo-5h93</link>
      <guid>https://dev.to/alimemonzx/the-must-listen-podcast-if-you-are-a-ceo-5h93</guid>
      <description>&lt;p&gt;Business wars is amazing podcast series. In which the host David Brown discusses the business strategies and competition between the biggest business in the world.&lt;/p&gt;

&lt;p&gt;The best series so far for me was Netflix vs Blockbuster. Blockbuster's was the pioneer in movie rental business. In 2000 Netflix offered Blockbuster a partnership which Blockbuster turned down and rest is the history.&lt;/p&gt;

&lt;p&gt;Do check out this 8 episode series on Spotify.&lt;br&gt;
&lt;iframe width="100%" height="232px" src="https://open.spotify.com/embed/episode/1it9SpNQQ4VmbwWipKj52o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Some amazing series from Business Wars:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Nike vs Adidas&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;eBay vs PayPal&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Marvel vs DC&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Red bull vs Monster&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Coke vs Pepsi&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;McDonalds vs Burger King&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ferrari vs Lamborghini&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Have you heard any of this series. If yes, do let me know which one is your favourite in comments section&lt;/p&gt;

</description>
      <category>podcast</category>
      <category>leadership</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Deploy your React app on heroku and go severless</title>
      <dc:creator>alimemonzx</dc:creator>
      <pubDate>Thu, 28 Jan 2021 19:22:43 +0000</pubDate>
      <link>https://dev.to/alimemonzx/deploy-your-react-app-on-heroku-and-go-severless-3pde</link>
      <guid>https://dev.to/alimemonzx/deploy-your-react-app-on-heroku-and-go-severless-3pde</guid>
      <description>&lt;p&gt;The word serverless feels like there is no server but actually &lt;strong&gt;Serverless is nothing but someone else's server.&lt;/strong&gt; So don't be confused. &lt;/p&gt;

&lt;p&gt;Herokuapp is great for deploying your projects without worrying about setting up a server. Heroku does that for you. &lt;/p&gt;

&lt;p&gt;So let's start with a react app and deploy it on heroku.&lt;/p&gt;

&lt;p&gt;🛠️ Tools we need: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A react app running on your local server.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/articles/heroku-cli"&gt;Heroku Cli&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Obviously a heroku account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1:
&lt;/h3&gt;

&lt;p&gt;Let's create an &lt;code&gt;app.js&lt;/code&gt; file on the root of you project for heroku configs so heroku will run a node server and that node server will serve the content from our react build. We will use express to create a server. Run this command in terminal inside the app root directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i express&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your &lt;code&gt;app.js&lt;/code&gt; file should look like this.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const path = require("path");
const express = require("express");
const app = express();
const publicPath = path.join(__dirname, "build");
const port = process.env.PORT || 3000;
app.use(express.static(publicPath));
app.get("*", (req, res) =&amp;gt; {
  res.sendFile(path.join(publicPath, "index.html"));
});
app.listen(port, () =&amp;gt; {
  console.log("Something cool is up and running 🚀🚀🚀!");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2:
&lt;/h3&gt;

&lt;p&gt;Make changes in your &lt;code&gt;package.json&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "scripts": {
    "start": "node app.js",
    "dev": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have replaced the start command with dev and start has new content which actually runs a production build of your app. The reason to do this because heroku will always look for start command and run it. We can not run dev server on heroku because of slow performance. You can do it if you want. But its not recommended.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3:
&lt;/h3&gt;

&lt;p&gt;Just run these commands in your terminal and there you go your app is deployed on heroku. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;heroku create&lt;/code&gt;, This creates a new project and a git repo in your heroku account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m "Initial Commit"
git push heroku master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you want to continue your local development. You will not use &lt;code&gt;npm start&lt;/code&gt; because npm start will run the local build if you have one, instead you will use &lt;code&gt;npm run dev&lt;/code&gt; to continue development on local environment. &lt;/p&gt;

&lt;p&gt;Image Credits: Dave Ceddia&lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
      <category>heroku</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Everything is 'undefined' in JavaScript</title>
      <dc:creator>alimemonzx</dc:creator>
      <pubDate>Tue, 26 Jan 2021 20:26:26 +0000</pubDate>
      <link>https://dev.to/alimemonzx/everything-is-undefined-in-javascript-4jp</link>
      <guid>https://dev.to/alimemonzx/everything-is-undefined-in-javascript-4jp</guid>
      <description>&lt;p&gt;To understand the title first we have to recap the concept of hoisting in JavaScript. &lt;/p&gt;

&lt;p&gt;You may have heard that hoisting is a concept of JavaScript, in which JavaScript moves all the variable of your code at the top level and start executing. &lt;/p&gt;

&lt;p&gt;There are statements as well like, only the variable declarations are hoisted and initialisations are not. All these explanations are explained conceptually. Things work different in reality. &lt;/p&gt;

&lt;p&gt;How about if we take a deep look how JavaScript work. Then we can have a better understanding of hoisting and the title of this blog. &lt;/p&gt;

&lt;p&gt;Everyone may know that JavaScript has a call stack and all the programs executes in a call stack. JavaScript has a global execution context. So whenever you run a piece of code it is run inside global execution context. &lt;/p&gt;

&lt;p&gt;Now the fun part is global execution context does not start executing code line by line, instead it has two process before it start the execution of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Creation Process&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2. The Execution Process&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Both process do their job very differently. Let's just discuss the creation process and reveal the secret of this blog. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Creation Process:
&lt;/h3&gt;

&lt;p&gt;When a program runs, javascript scans the whole program and registers all the variables in the global scope with the special value of &lt;strong&gt;'undefined'&lt;/strong&gt;. Yeah that's true, every variable is undefined in the creation Process. &lt;/p&gt;

&lt;p&gt;In case of functions things work differently. JavaScript registers the function with its actual body. So functions are not undefined, they have their whole body in the creation process.But, if you use arrow functions they will be undefined as well. Let's make it easier with images.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3pshlwmfp9stn6lzh8t6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3pshlwmfp9stn6lzh8t6.png" alt="alimemonzx-everything-is-undefined-in-javascript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Code starts executing in GEC.&lt;/li&gt;
&lt;li&gt;Step 2: The creation process started. It looks for all the variable and functions register them in global scope with the value of &lt;strong&gt;'undefined'&lt;/strong&gt; to variable and assigned whole function body to the function name.&lt;/li&gt;
&lt;li&gt;Step 3: The execution process started and actually assigned the value of &lt;code&gt;a&lt;/code&gt;. The value of &lt;code&gt;a&lt;/code&gt; is now replaced from &lt;code&gt;undefined&lt;/code&gt; to a string &lt;code&gt;Every variable is undefined&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's dive actually into the code. I have used the same code and tried to run it on my browser with a debug point at line no 1.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb9sh2qfz3hcba7aclday.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb9sh2qfz3hcba7aclday.png" alt="alimemonzx-everything-is-undefined-in-javascript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside the highlighted red part you can see that &lt;code&gt;var a&lt;/code&gt; is undefined. At this point creation process is already finished and JavaScript has already added the variable &lt;code&gt;a&lt;/code&gt; in global scope with a default value of &lt;code&gt;undefined&lt;/code&gt;.&lt;code&gt;aFunction&lt;/code&gt; is also added in global context with its whole body.&lt;/p&gt;

&lt;p&gt;So this is how JavaScript works. Before executing, it kind of scans the whole program and register all the variables and functions in their respective scopes. The creation process is also known as hoisting in JavaScript.&lt;/p&gt;

&lt;p&gt;You can also try and debug the code in your browser, try with ES6 arrow functions and check if it is undefined or not. The information is taken from so many videos and articles and shared it here. Share your ideas in comments below. &lt;/p&gt;

&lt;p&gt;HAPPY CODING &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>functional</category>
    </item>
    <item>
      <title>HOW TO WRITE GOOD FUNCTIONS</title>
      <dc:creator>alimemonzx</dc:creator>
      <pubDate>Sat, 23 Jan 2021 19:21:26 +0000</pubDate>
      <link>https://dev.to/alimemonzx/how-to-write-good-functions-3hk8</link>
      <guid>https://dev.to/alimemonzx/how-to-write-good-functions-3hk8</guid>
      <description>&lt;p&gt;Okay, So my first take on this blog "how to write good functions". If I tell you about my experience nobody taught me how to write good functions and classes. All I assume in the beginning of my career was I should write less amount of functions and do as much code as in one function which is totally wrong. At that time, I assume that it's a really good practice to write everything in one function which I assume that my function is very powerful doing all the stuff at once. As soon as I move to build advance project I always stuck in the mid of big functions and writing same amount of code again and again. Those functions made me realise that I am doing bad code. I was so frustrated with this practice.&lt;/p&gt;

&lt;p&gt;One day my friend suggested me to read Design Patterns to get rid of this problem. I started reading SOLID principles. All those heavy words went over my head and again it the feeling was like I can never learn this. But SOLID really helps. I will write a separate blog on SOLID principles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uncle Bob To Rescue:
&lt;/h2&gt;

&lt;p&gt;So many of you might know Uncle Bob but if not "Robert Cecil Martin" aka Uncle Bob. I was just surfing on YouTube and found a great &lt;a href="https://www.youtube.com/watch?v=TMuno5RZNeE"&gt;video&lt;/a&gt; of Uncle Bob explaining the difference between good and bad functions. Following few point I took from his talk. So without wasting your time let's discuss how to write good functions. If you keep remember these 5 points when writing functions then you will rock.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Boring Function&lt;/li&gt;
&lt;li&gt;Make It Like A Story&lt;/li&gt;
&lt;li&gt;Make Them Reusable&lt;/li&gt;
&lt;li&gt;3 Minute Strategy&lt;/li&gt;
&lt;li&gt;No More Than 2 Arguments&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Boring Functions:
&lt;/h2&gt;

&lt;p&gt;If you are reading a function and whatever you read is compiling in your mind and you feel like. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thats so boring and simple to understand whats going on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then the function is well written and that's exactly you have to write your functions. Good functions are always easy to understand. Let me explain in more detail.&lt;/p&gt;

&lt;p&gt;On the other side if you are reading a function and you have a confusing eye on the screen, Moving your eyeball from top to bottom of that function thinking that, what the hell is going on here. So it's a sign of bad function. &lt;/p&gt;

&lt;p&gt;A function should always do a one task. It should not be doing multiple tasks in its implementation. If you have multiple logics in your functions just separate them into other functions and reuse them. Doing that you will be making your functions easy to read and understand. Make sure one function is only performing one task. &lt;/p&gt;

&lt;h2&gt;
  
  
  Make it like a story:
&lt;/h2&gt;

&lt;p&gt;Ever remember when you were a kid and reading a story book and after reading each line you smile or you become curious that what will gonna happen next. While you were reading you already know what going on and sometimes you also predict what will gonna happen next. &lt;/p&gt;

&lt;p&gt;In the same manner we have to write our class like a story with the help of functions. Name your functions like if anybody reads your function, he shouldn't have to read the implementation. Just by reading the name he understands what is going on inside the function. To make your class beautiful like a story you have to write small functions so the reader (you) can understand just by reading the name of functions with a smiling face.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make them Reuseable:
&lt;/h2&gt;

&lt;p&gt;Always try to make your functions reusable, If you have written a function of 30 lines. I am 100% sure that there would be some chunks in your function which you can move it in different functions and reuse them in others. Even if you are repeating a single line again and again just put that line in another function, return it and reuse it.&lt;/p&gt;

&lt;p&gt;Try not to use global variable in your functions as it results tight coupling in your functions and you can never use them again. Use parameters instead of global variables to make them more dynamic. &lt;/p&gt;

&lt;h2&gt;
  
  
  3 minutes strategy:
&lt;/h2&gt;

&lt;p&gt;If you are taking more than 3 minutes to understand a function than there is something bad in that function. 3 minutes is a lot of time to understand. The average time to understand a function is 90 seconds (No valid stats). If you are taking more than that. Then its time to separate some chunk from your function and write them in other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not more than 2 arguments :
&lt;/h2&gt;

&lt;p&gt;According to uncle bob, Good function are always without arguments. Now in some cases we need parameters to process the output. The fine limit is 2 arguments in a function. But you can add more where it should definitely make sense. Adding 5 6 or 7 arguments in a function is a bad practice.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tip : Good functions are no longer than 20 lines.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So if you like this article do share it with your friends and let me know your feedback on this. I will be so happy if these 5 points help you to write your good functions. Cheers&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>functional</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
