<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nikhil Goel on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Goel on Medium]]></description>
        <link>https://medium.com/@nikhil-goel-3180?source=rss-40f7084db2fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*a_ol4tWEDS615hhl</url>
            <title>Stories by Nikhil Goel on Medium</title>
            <link>https://medium.com/@nikhil-goel-3180?source=rss-40f7084db2fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 27 May 2026 00:56:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikhil-goel-3180/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[NgRx Store]]></title>
            <link>https://nikhil-goel-3180.medium.com/ngrx-store-d3de9783a1e3?source=rss-40f7084db2fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3de9783a1e3</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[store]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[ngrx-store]]></category>
            <dc:creator><![CDATA[Nikhil Goel]]></dc:creator>
            <pubDate>Sun, 23 May 2021 14:47:34 GMT</pubDate>
            <atom:updated>2021-05-23T14:50:38.047Z</atom:updated>
            <content:encoded><![CDATA[<p>NgRx store is the state management solution for Angular applications. It acts as a backbone for Angular application and must be decided at the architecture level whether to use store or not. It is often good idea to use store when the application is dealing with medium to large amount of data. It also helps in the debugging or testing the application properly</p><p>NgRx store is basically helps to improve the performance of the application. It acts as a local storage for the data due to which server side rendering is not required every time when fetching the similar data between different tabs or components. Consider NgRx store as a local database in which when the application starts it fills up the database now each time when application needs that data it will first check the store if the data is present before making the API call to fetch data. In this way if data is already present in the store, it will prevent from making the API call and the performance of the application will improve drastically.</p><p>To install NgRx store in your application use the following command:</p><p><em>ngrx i @ngrx/store</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*6Z92J3bGnzwnL44SsaUpoA.png" /></figure><p>The above flow chart describes the working of store in details.</p><p>To implement store in our application we basically use Actions and Reducers.</p><p><strong>Actions:</strong> It basically defines all the unique events we are going to use in our applications.</p><p>It basically consists of two things:</p><ol><li>type in the form of string.</li><li>optional payload of data.</li></ol><p><strong>Reducers: </strong>A reducer is what takes the incoming actions and decides what to do with it. It takes the previous state and returns a new state based on the given action.</p><p>Now let’s understand the working of the store.</p><p>The concept of NgRx store is based on the observables. We use observables as we can define property as an observable because that’s what returned from NgRx store when we try to access the data.</p><p>The component dispatch an event to the action, it will decide the appropriate action for that request and send that action to the reducer. Reducer is where we have certain logic written that will perform based on the action received. It will take the previous state and action and will return the new state to the component which will then renders the data received from the store. Since it is implemented as observable, so whenever there is change in data, the components that are subscribe to that store will be informed and the component will take appropriate action.</p><p>Please find below the simple working example of NgRx store:</p><p><a href="https://github.com/Nikhil3180/angular-ngrx-store">Nikhil3180/angular-ngrx-store</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3de9783a1e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Value type and reference type in Javascript]]></title>
            <link>https://nikhil-goel-3180.medium.com/value-type-and-reference-type-in-javascript-605c6f964410?source=rss-40f7084db2fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/605c6f964410</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nikhil Goel]]></dc:creator>
            <pubDate>Tue, 24 Nov 2020 14:03:13 GMT</pubDate>
            <atom:updated>2020-11-24T14:03:13.297Z</atom:updated>
            <content:encoded><![CDATA[<p>Value type sometimes called Pass by value and reference type sometimes called pass by reference is an important topic that confuses most of the people while writing a program.</p><p>These are some of the few topics that are backbone of a programming language and without knowing it sometimes it is difficult to understand how the program behaves. So, let’s study in details and hopefully it will clear out all your doubts.</p><p>In Javascript, we have two types i.e. <strong>Primitive type and Object type.</strong></p><p>The primitive types in Javascript are string, numbers, boolean, undefined, null. These primitive types are value types i.e. these are copied by value.</p><p>If we assigned a value of a variable to another variable, the value is copied to the another value.</p><p>Therefore, changing the value of one variable doesn’t effect the value of another variable.</p><p>Let’s understand it with the help of an example</p><p>Javascript</p><pre>var a = 10;<br>var b = a;<br>a = 20;<br>Console.log(a);<br>Console.log(b)</pre><p><strong>The output of above code would be 20 and 10 respectively.</strong></p><p>Let’s understand why we get such output. This is because when we assign the value of a to b at that time the value of a is 10 which gets copied to b resulting the value of b to be 10 and after that we changed the value of a to 20 which results the value of a to be 20.</p><p>So, this is the concept of value type and it’s basically valid over primitive types in Javascript.</p><p><strong>Note: </strong>The value type are stored in <strong>stack memory</strong>.</p><p>Now, let’s understand the concept of reference type. It’s bit tricky to understand but once you understand, you will find it’s not that difficult to understand it. So, let’s begin.</p><p>Before proceeding further, let’s find out the output of following code.</p><p>Javascript</p><pre>var s = { name : &quot;Nikhil&quot;,<br>			Age : 25}<br>var d = s;<br>s.name = &quot;Suraj&quot;;<br>Console.log(s);<br>Console.log(d);</pre><p><strong>The output will be {name: “Suraj”, Age: 25} and {name: “Suraj”, Age: 25}.</strong></p><p>Now, you will wonder we have only change name for the s only. So why it also changes the value of name in d. So, this is the concept of reference type. Don’t get confuse, let’s find out why it happens.</p><p>The objects in Javascript are reference type and these are stored in <strong>heap memory</strong>.</p><p>So, in reference type, a new pointer is created while we assign the value of object to another variable which gets stored in stack and that pointers points to the same location in the heap memory. So whenever we change the value of any object it gets changed within the heap memory and all the pointers pointing to that object now gets the updated value. So, in this the actual value of the object is not copied instead it remains at the same location in the heap memory but we get the new pointer stored in stack pointing to that same location in the heap.</p><p>So, this is why when we change the name property in s , it actually gets updated in the heap memory and the d pointing to that location also receives the updated value. So, this is actually how a reference type behaves within the Javascript.</p><p>Hence, value type variables and reference type variables behaves totally different and we have to take care of it while writing any program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=605c6f964410" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In this growing world, everyday a new concept or new algorithm is introduced in Computer Science…]]></title>
            <link>https://nikhil-goel-3180.medium.com/in-this-growing-world-everyday-a-new-concept-or-new-algorithm-is-introduced-in-computer-science-228ed2b4ed97?source=rss-40f7084db2fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/228ed2b4ed97</guid>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Nikhil Goel]]></dc:creator>
            <pubDate>Fri, 30 Oct 2020 06:38:47 GMT</pubDate>
            <atom:updated>2020-10-30T06:38:47.211Z</atom:updated>
            <content:encoded><![CDATA[<h3>Functional Programming : The need for the hour</h3><p>In this growing world, everyday a new concept or new algorithm is introduced in Computer Science and that’s the beauty of this which makes this field interesting and exploring.</p><p>Each one of us have heard different types of programming like OOPs (Object Oriented Programming), Procedural Programming and Scripting Programming. There are many programming languages which supports these types of programming like C,C++,Java,C#,Ruby,Python,JS etc.</p><p>Today, I am going to discuss about a new type of programming i.e. <strong>Functional Programming</strong>.</p><p>This type of programming is now a days a very common practice. The basic idea behind this type of programming is mathematics. Although we all know the basic behind computer science is mathematics.</p><p>This type of programming takes the mathematics to a new level.</p><p>Just like mathematical functions, we just look at input and produce the output, there is no change in value i.e. no side effects. This is the general idea behind this type of programming. Let’s explore more about it.</p><p>First let’s try to understand with the help of mathematical example what it tries to implies.</p><p><strong>Suppose I have a set of some characters,</strong></p><p><strong>let’s suppose it x.</strong></p><p><strong>x = [‘a’,’b’,’c’]</strong></p><p><strong>Now I have another function y that uses the values of x.</strong></p><p><strong>y = a(x).</strong></p><p><strong>Now, after executing the y. does the value of x changes??</strong></p><p><strong>The answer would be No. because the y is using the values of x not manipulating the x.</strong></p><p>So, this is the idea of functional programming, we are providing some inputs and gets output using the inputs but not changing the inputs.</p><p>Now, the question arises how we can implement such concept in our programming language.</p><p>Don’t worry it’s quite simple to do so. Now, let’s talk about it in detail.</p><p>Each one of us knows about data structures, these are the building block of a programming language as well as an application. So, first approach to the implementation of functional programming is making the data structure immutable. Now, these can’t be changed. Now, if anybody wants to change any value, he/she has to make a copy of this data structure and use them. In this way the input remains same even after performing different operations by the users.</p><p>Now, we wonder if we have to copy the whole data structures each time, this leads to the problem of memory wastage. So, to solve this type of problem we have something called <strong>persistent data structures</strong>.</p><p>Persistent data structures are immutable which are implemented like a tree structure to store values, so you don’t have to copy whole array each time, just copy that node of data which you required to manipulate. Generally, people use the concept of 32 wide nodes. In this each node has 32 another nodes which can store millions of data.</p><p>So, now list out some advantages of this type of programming.</p><p><strong>1. Easy to think</strong>: Since the input remains same and you don’t have to worry about what’s the input is. It’s quite easy to think how to solve various programming problem.</p><p><strong>2. Easy to understand</strong>: Now, the function we are implementing has no side effects, so it can be easily understood by anyone.</p><p>Each type of programming has advantages as well as disadvantages same goes with functional programming as well.</p><p>Now, let’s explore some of the problems and how we can solve them.</p><p>Our customers really don’t care about how we implemented a solution to fix a problem they care about the side effects the functions are producing like updating the value in database, creating a file etc.</p><p>As we know functional programming doesn’t have any side effects, so it’s lead to a problem for our customer.</p><p>Don’t worry we also have a solution for this problem as well. To solve this problem we are going to use bridge pattern i.e. <strong>we need a bridge between functional programming and object oriented programming.</strong></p><p>We can achieve this with the help of closure state. It has something called <strong>atoms</strong> which has a container for mutable state.Through the function at atom, we evaluates the value of the function and it becomes the value of the atom and this is the bridge between the two.</p><p>Suppose, if two functions hits the atom to update the value at the same time, both functions will have the same initial value, but one function might be faster than other which will change the value of atom, now when second function tries to change the value of atom, it detects the change in value and again return the function but this time with the new value and this is how the collision is handled same as done in the database transaction.</p><p>So, In functional programming we don’t have any side effects except the updating the atom and we are controlling the value of atom as it is the bridge between our lovely functional programming world and outside messy world that has side effects. In this type of programming instead of changing the value of data directly ww throw a function to do so. We have a queue to maintain the record of side effects we are going to do like deleting a file record, write a file etc.</p><p>Surely, this type of programming is going to become very popular in the future time as it is easy to understand and with no side effects it will completely change the way of thinking and implementing the ideas to solve the real world problem</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=228ed2b4ed97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>