<?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: Saima Rahman</title>
    <description>The latest articles on DEV Community by Saima Rahman (@saimaar).</description>
    <link>https://dev.to/saimaar</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%2F434878%2Fc3862a99-b1b7-4d8a-97cf-7c5279f1a35e.jpeg</url>
      <title>DEV Community: Saima Rahman</title>
      <link>https://dev.to/saimaar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saimaar"/>
    <language>en</language>
    <item>
      <title>Handling Exceptions in Ruby</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Thu, 27 Aug 2020 23:13:51 +0000</pubDate>
      <link>https://dev.to/saimaar/handling-exceptions-in-ruby-45b3</link>
      <guid>https://dev.to/saimaar/handling-exceptions-in-ruby-45b3</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lXYdyb7J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w0r0fma1faklwnv7dle0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lXYdyb7J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w0r0fma1faklwnv7dle0.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I started working on my first CLI project, I encountered many errors and spent most of my time debugging, which is good because I have read somewhere that “Only half of programming is coding. The other 90% is debugging.” After digging through ruby docs, I found out about these useful keywords, &lt;strong&gt;begin and rescue&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are “keywords” in ruby?&lt;/strong&gt;&lt;br&gt;
Let me give you a refresher! Keywords or reserved words are used by a language for internal processes and therefore cannot be used as a variable.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#'if' and 'end' are keywords to check the condition of a given code.
#Here 'if' is checking some condition
if 2 &amp;gt; 1
  puts "I love Ruby"
end # "I love Ruby"
#"if' cannot be used as a variable
#'if' has been already reserved by the ruby language
if = 2 # : syntax error, unexpected '=')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Although there are a bunch of keywords in ruby, I will be focusing on begin and rescue. They are also known as exception handlers. In ruby whenever an exception occurs, it terminates the execution of our program, this is where the exception handlers come into play. The code in your project, that may raise an error or exception can be enclosed within the begin…end block, followed by a code that is written in the rescue block to handle this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def some_condition
 puts 3/0
end
#=&amp;gt; divided by 0 (ZeroDivisionError)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above code is giving us a ZeroDivisonError. Let's handle this error together!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def some_condition
 begin
    puts 10/0
 rescue
  puts 10/2
 end
end
some_condition #=&amp;gt; 5 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As expected, this method returned 5! We know, in ruby, a number cannot be divided by zero, and so it will raise an exception. So we wrote the “problematic” code inside the begin block. The code got executed but did not break our program. Instead, it ran the code under the rescue block and returned us with a nice answer! Phew, without an error! Keep in mind that if the code inside the begin block does not raise any possible errors, the code will be executed just fine. The rescue will only be executed when there is an error!&lt;/p&gt;

&lt;p&gt;There will be a number of scenarios, where you will also want to see the error messages even after the program is being rescued. Let’s see how it works but this time with a different exception:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def some_condition
 puts "hello".even?
end
some_condition #=&amp;gt; in `some_condition': undefined method `even?' for "hello":String (NoMethodError)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let’s not break the program and still print the error message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def some_condition
  begin
    puts "hello".even?
rescue Exception =&amp;gt; e #Exception object is being saved to a variable
    puts "hello".length
    puts e.message #prints the error message
  end
end
some_condition
#=&amp;gt; 5
#=&amp;gt; undefined method `even?' for "hello":String
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Nice! We have handled our error successfully! We were able to rescue our program as well as print the error message. So what exactly are we doing here? We saved the Exception class to a variable “e”, and now the error message can be printed in the rescue block. Since we already know the type of error, we can rewrite our code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def some_condition
  begin
    puts "hello".even?
rescue NoMethodError =&amp;gt; e 
    puts "hello".length
    puts e.message #prints the error message
  end
end
#returns the same result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Please copy-paste these codes and play around with the errors for better understanding! Happy error handling!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>womenintech</category>
      <category>codenewbie</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Looping Through JavaScript Objects</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Thu, 20 Aug 2020 02:59:31 +0000</pubDate>
      <link>https://dev.to/saimaar/looping-through-javascript-objects-44e</link>
      <guid>https://dev.to/saimaar/looping-through-javascript-objects-44e</guid>
      <description>&lt;p&gt;Before understanding how looping works, let us talk about JavaScript Objects. Remember, when we declare a variable using let, const, or var keywords? We set the identifier or variable name equals to a value. JavaScript variable can contain only one value, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruit = "apple";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Where the fruit is the identifier or name of the variable and apple is the value. Let’s say, we bought some fresh fruits from the farmer’s market. How can we save all the fruits and fruit count into one variable? Yes, you guessed it right! We can use objects because they can contain many values. Specifically, key-value pairs contained inside curly braces. Key being the property and value is whatever we set it equals to. It could be a string, number, array, object or function definition. Before we begin looping, let refresh our memory on how to gain access to the key-value pairs of an object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Accessing an object’s key-value pairs&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruit = {
            name: ["apple", "orange", "grape"],
            fruitCount: 30
            }
console.log(fruit.name) // [ 'apple', 'orange', 'grape' ]
console.log(fruit["name"]) // [ 'apple', 'orange', 'grape' ]
console.log(Object.values(fruit)) // [ [ 'apple', 'orange', 'grape' ], 30 ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here, we are using bracket notation, (.) dot notation and Object.values method (object) for accessing the object’s value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;for…in loop&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruitCount = { 
   apple : 2, 
   orange: 3, 
   grape: 6 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above example, we have names of the fruits as our key and count of each fruit as the value. So what if we want to count the total number of fruits?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let totalCount = 0
for(let key in fruitCount){
      totalCount += fruitCount[key]
  }
console.log(totalCount); // 11
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we are iterating through each object property using a for..in loop. By using this method, we have now access to the values using the bracket notation on the object itself.&lt;br&gt;
We usually use for..in loop to iterate over the properties of an object. Check if a value exists for a key, display the key-value pairs using console.log. This is actually a great debugging tool. A key thing to remember is, for..in is not recommended to use with arrays because the index order is important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;for…loop&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is another way of doing this, using Object.keys method that takes in an object as an argument and returns an array of keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruitCount = { apple : 2,
                   orange: 3,
                   grape: 6 
}
let fruitArray = Object.keys(fruitCount)
  let totalCount = 0
 for (let i = 0; i &amp;lt; fruitArray.length; i++) {
     let fruitName = fruitArray[i];
     totalCount += fruitCount[fruitName]
}
console.log(totalCount); // 11
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, we are getting back an array of keys, which we have saved it to a variable named fruitArray. Using a for…loop, we iterate through each fruitName (keys) in the array. Since we know that we can key into an object to get the value using bracket notation, we use this trick to get the fruit count and add it to the total count.&lt;br&gt;
Happy Coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>JavaScript .splice() method</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Wed, 12 Aug 2020 16:51:07 +0000</pubDate>
      <link>https://dev.to/saimaar/javascript-splice-method-170n</link>
      <guid>https://dev.to/saimaar/javascript-splice-method-170n</guid>
      <description>&lt;p&gt;There are many array methods in Javascript but the one with which I struggle the most is, .splice() method.&lt;/p&gt;

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

&lt;p&gt;So the other day, I came across a &lt;a href="https://leetcode.com/problems/move-zeroes/"&gt;leet code&lt;/a&gt; problem, which asked me to manipulate an array without making a copy of it! I searched for methods and I remembered, that .splice() can be useful for this problem. So without wasting any time lets dive into the basics of .splice() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              Deleting A Number from an Array 
let array = [2,3,4,5,6]                                                  //At index 0, let's delete the first number which is 2 in this case!
array.splice(0, 1) 
==&amp;gt; return value:[2] // returns the removed element
==&amp;gt; console.log(array)// [3,4,5,6]
//At index 0, Let's delete, first two numbers which is 2 and 3 
array.splice(0, 2)
==&amp;gt;  return value:[2,3]
==&amp;gt;  console.log(array) // [4,5,6]

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



&lt;p&gt;In the above example .splice() is taking two parameters:&lt;br&gt;
The index number(the point at which we want to start deleting elements)&lt;br&gt;
The second parameter is the number of elements we want to remove from an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Delete elements and add things
let array = [2,3,4,5,6]
//starting from index one, I want to remove two elements and add chicken
array.splice(1,2, "chicken")
==&amp;gt; return value: [ 3, 4 ]
==&amp;gt; console.log(array) // [ 2, 'chicken', 5, 6 ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we are giving .splice(), three parameters, the third parameter is optional. Recap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;First parameter:&lt;/strong&gt; Starting index, the point at which you want to delete things&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Second parameter:&lt;/strong&gt; Number of elements, you want to remove from an array&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third parameter:&lt;/strong&gt; Optional, elements you want to add at a specified position
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Delete none, Add things 
let array = [2,3,4,5,6]
//At index one, delete nothing (hence 0 as the second parameter), and add few more elements
array.splice(1,0,"grandma", "loves", "chicken")
==&amp;gt; return value: []
==&amp;gt; console.log(array) // [ 2, 'grandma', 'loves', 'chicken', 3, 4, 5, 6 ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you don’t want to delete anything, just add “0”, to the second parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Replace elements with other things
let array = [2,3,4,5,6]
//At index 4, replace number 6 with other elements
array.splice(4, 1,"grandma", "loves", "eric")
==&amp;gt; return value: [ 6 ]
==&amp;gt; console.log(array)// [ 2, 3, 4, 5, 'grandma', 'loves', 'eric' ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I hope this blog was helpful! Now go ahead and play around with .splice() until it is clear and also challenge yourself with a leet code problem: &lt;a href="https://leetcode.com/problems/move-zeroes/"&gt;Move Zeros&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Reference: &lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice"&gt;Javascript Splice&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>womenintech</category>
      <category>codenewbie</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Complexity &amp; Big0 notation</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Tue, 04 Aug 2020 04:04:26 +0000</pubDate>
      <link>https://dev.to/saimaar/complexity-big0-notation-46j9</link>
      <guid>https://dev.to/saimaar/complexity-big0-notation-46j9</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mfHRLJ4b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fl3fwz1j1304nzlfk0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mfHRLJ4b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9fl3fwz1j1304nzlfk0d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we talk about complexity and evaluate algorithm problems, we usually talk about two things: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;Deals with how efficient or fast an algorithm is. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Space Complexity&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;Deals with how much space or memory it will require. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Complexity is always related to the input, more importantly, the size of the input. &lt;/p&gt;

&lt;p&gt;for example: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(n)&lt;/strong&gt;: Linear
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input= [1,2,3,4,5,6,7,8,9,10]

function countNum(){
let counter = 0
  for (let i = 0; i &amp;lt; input.length; i++){
    console.log(counter++)
  }

}

countNum(input)
//output:
0
1
2
3
4
5
6
7
8
9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, when we talk about time complexity, we are actually talking about the number of operations. Since the number of input is 10, the number of operations will also be 10. If you increase the number of elements in the array, the number of operations will also increase. It is therefore 1:1 relation. We call this Big O(n), where n is the number of elements in the given array, and since it is 1:1 relation we call this linear.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(n^2)&lt;/strong&gt;: Quadratic
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input= [1,2,3,4,5,6,7,8,9,10]

function countNum(){
let counter = 0
  for (let i = 0; i &amp;lt; input.length; i++){
    for(let j = 0; j &amp;lt; input.length; j++){
      console.log(counter++)
    }
  }

}

countNum(input)//
Check the console.log, you will see 
the operation has increased by 10folds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, the number of operations is growing faster than the input. We have a nested loop, each loop has a time complexity of O(n), so we multiply the time like so: O(n) * O(n) = O(n^2). Note: We don't really focus on the coefficients, all we care about is the power. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(logn)&lt;/strong&gt; Logarithmic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is the opposite of exponential growth. For example in binary search the input is sorted and split into two, where one half is discarded depending on the condition and another half is being checked. This saves time complexity and considered the fastest of solving an algorithm problem after O(1).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(1)&lt;/strong&gt; Constant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Accessing the array index and not looking up the value. Just accessing the index directly. Then push and pop in a &lt;a href="https://www.geeksforgeeks.org/stack-data-structure-introduction-program/"&gt;Stack&lt;/a&gt; is also constant. Removing and inserting from a &lt;a href="https://www.tutorialspoint.com/data_structures_algorithms/dsa_queue.htm"&gt;Queue&lt;/a&gt; is considered to have O(1) complexity. &lt;/p&gt;

&lt;p&gt;Happy Coding 😄&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>complexity</category>
      <category>algorithms</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Intro to redux</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Wed, 29 Jul 2020 21:13:32 +0000</pubDate>
      <link>https://dev.to/saimaar/intro-to-redux-3j14</link>
      <guid>https://dev.to/saimaar/intro-to-redux-3j14</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2dBsv72i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/46f120lanbuysejckky0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2dBsv72i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/46f120lanbuysejckky0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Redux is a predictable state container for Javascript applications, as mentioned in redux documentation. It took me some time to get my head around this concept. What does it actually mean? &lt;br&gt;
Let’s break this down into three points and focus on each of them separately. &lt;strong&gt;Redux is for:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Javascript Apps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This simply means Redux can be used with any frameworks such as React, Angular, Vanilla Javascript, etc. It can be used independently and is not tied together to react.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. It is a State Container&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It stores the state of the application as a single source of truth. This means, whenever we want to look up or share information about the state, we can always go back to that one place. In a typical react application, states can be defined in different components. Imagine, you are working on a project which has nested components, it will be really messy and as well as difficult to keep track of the state. This is where Redux can help us, by storing all the information about our state in one place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. It is predictable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In react application, we use the setState() method, to change the state of a component, but in redux driven applications, all state changes happen through “reducers” which are nothing but pure functions. To learn more about reducers check out getting started with the redux doc. Keep an eye out for my next blog, where I will write about the three main concepts of redux. But the take away is we can always predict the behavior of the state of our app.&lt;/p&gt;

&lt;p&gt;React components can have their own state, then why do we need redux as a container to store all state? Let's look at the big picture:&lt;/p&gt;

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

&lt;p&gt;In the above diagram, we have a javascript app with nested components. Let's say, component A has an input field to hold username, therefore we are locally setting the state in this component. What if it’s sibling, component B wants to display the username? Then we would find a common parent, in this case, component C and move the state one level up and send the state as props to C’s children which are components A and B. But as your app grows bigger and bigger, now components I and J, needs access to the username. In this scenario, the best option is to lift the state up in the hierarchy, which is the App itself. So now we have to pass username props through all the intermediate components F, G, and H. Even though F, G, and H components don’t need the props, they still need to be informed about it in order to pass to their children. But now if we incorporate the Redux library into our app, we can move states from our app components to the &lt;strong&gt;Redux State Container&lt;/strong&gt;. Now if we change the username, in component A, Redux container will only communicate with component A and other components who are in need of the value without having to inform other components.&lt;/p&gt;

&lt;p&gt;The purpose of this blog is to introduce the bigger picture of why using redux can be useful! Understanding this concept will help to manage state in larger applications.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>100daysofcode</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>Ruby 101 part:1</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Sun, 19 Jul 2020 23:38:12 +0000</pubDate>
      <link>https://dev.to/saimaar/ruby-101-part-1-2j2k</link>
      <guid>https://dev.to/saimaar/ruby-101-part-1-2j2k</guid>
      <description>&lt;p&gt;Hello, Rubians! This blog post is for newbies who want to learn the basics of Ruby or just here to refresh their memory! &lt;/p&gt;

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

&lt;p&gt;Ruby is an object-oriented language. It simply means everything in ruby is an object, including the data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Four Basic Data Types:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Numbers (Integer &amp;amp; Floats) &lt;/li&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;Symbols &lt;/li&gt;
&lt;li&gt;Boolean (True, False, Nil)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Today I going cover &lt;strong&gt;Numbers&lt;/strong&gt; only.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Addition
2 + 2   #=&amp;gt; 4

#Subtraction
 3 - 1   #=&amp;gt; 2

#Multiplication
 3 * 3  #=&amp;gt; 9

#Division
20 / 5  #=&amp;gt; 4

#Exponent
 2 ** 2  #=&amp;gt; 4
 4 ** 3  #=&amp;gt; 64

# Modulus (find the remainder of division)
print(4 % 2 )  #=&amp;gt; 0  (4 / 2 = 4; no remainder)
print(15 % 4)  #=&amp;gt; 2  (10 / 4 = 3 with a remainder of 3)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Difference between Integers and Floats&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Integers&lt;/em&gt;&lt;/strong&gt; are whole numbers, such as 16 and &lt;strong&gt;&lt;em&gt;floats&lt;/em&gt;&lt;/strong&gt; are decimal numbers such as  16.0, 0.25, or 4.3. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ruby Things!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Ruby, when you want to do some arithmetic with two integers the answer will always be a whole number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5/2 #=&amp;gt; 2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It is weird, right? In order to get the correct answer, we have to use float.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5/2.0 #=&amp;gt; 2.5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Convert Integers to floats or vice versa&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Integer to a float:
2.to_f #=&amp;gt; 2.0 
18.to_f #=&amp;gt; 18.0 

Float to an integer
3.0.to_i #=&amp;gt; 3
1.8.to_i #=&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Number methods in Ruby:&lt;/strong&gt;&lt;br&gt;
Well, there are many numbers in Ruby, I am going to share two over here, rest you can check &lt;a href="https://www.freecodecamp.org/news/ruby-number-methods-integer-and-float-methods-with-examples/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.even?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;13.even? #=&amp;gt; false
12.even? #=&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.odd?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;14.odd? #=&amp;gt; false
15.odd? #=&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Keep an eye out for my part:2! &lt;br&gt;
Keep coding! 😁&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>100daysofcode</category>
      <category>womenintech</category>
      <category>rails</category>
    </item>
    <item>
      <title>Props in React.js</title>
      <dc:creator>Saima Rahman</dc:creator>
      <pubDate>Sat, 18 Jul 2020 17:05:30 +0000</pubDate>
      <link>https://dev.to/saimaar/props-in-react-js-3kj2</link>
      <guid>https://dev.to/saimaar/props-in-react-js-3kj2</guid>
      <description>&lt;p&gt;What are “props” and how do we really use it? Assuming, we all know about react Components, which are reusable, meaning they can return any JSX, which can be included in any part of our application. Let's build a simple app whose only job is to welcome a user by their name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Access Props in Functional Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here the parent is App.js, which is a class component, and its child Welcome.js is a functional component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this is App.js
import React, { Component } from 'react';
import Welcome from './Welcome.jsx';
class App extends Component {
 render() {
    return (
     &amp;lt;div&amp;gt;
      &amp;lt;Welcome/&amp;gt;
      &amp;lt;Welcome/&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}
export default App;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In App.js, we are rendering Welcome which is a functional component, twice, inside the return function. The Welcome.js file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this is Welcome.js file
import React from 'react';
const Welcome = () =&amp;gt; {
    return &amp;lt;h1&amp;gt;Hello Joe Goldberg&amp;lt;/h1&amp;gt;
  }
export default Welcome;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if we tune into &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;, the result should like this:&lt;/p&gt;

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

&lt;p&gt;Because we are rendering the Welcome component twice in App.js, it will print Joe Goldberg twice, returning the inner text of the h1 element from the Welcome function.&lt;/p&gt;

&lt;p&gt;But, what if we want to make this component dynamic? Meaning we want to print different usernames or welcome different people, using the same component. Now we can make good use of Props, which is also known as properties. Think about how we add attributes, such as CSS class to an HTML element. Similar idea, we want to add props to our component as their property or attribute and set it equals to the desired value, in this case, username. After assigning values to our props, we have to somehow send props from App.js to Welcome.js, let us take a look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this is App.js
import React, { Component } from 'react';
import Welcome from './Welcome.jsx';
class App extends Component {
render() {
    return (
     &amp;lt;div&amp;gt;
      &amp;lt;Welcome name="Joe Goldberg"/&amp;gt;
      &amp;lt;Welcome name="Mrs Maisel"/&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}
export default App;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In App.js, we have named our props as “name” and have set it equals to the desired username. Now we have to pass the props to the Welcome component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this is Welcome.js
import React from 'react';
const Welcome = (props) =&amp;gt; {
  //console.log(props);
    return &amp;lt;h1&amp;gt;{props.name}&amp;lt;/h1&amp;gt;
  }
export default Welcome;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Notice that App.js which is a parent component is passing props as a parameter in the Welcome function (arrow function), which can be then used in the function body. If we console.log props, we can see that props are nothing, but a plain javascript object with key and value pairs. We can access the key of “name” using (.) dot notation like this, props.name inside curly brackets because it is a JSX expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//console.log(props)
&amp;gt;{name: "Joe Goldberg"}
&amp;gt;{name: "Mrs Maisel"}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if we tune into &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;, the result should like this:&lt;/p&gt;

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

&lt;p&gt;We have successfully made our component dynamic by using props!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Access Props in a Class Component&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we will rebuild the same app, whose job is to say goodbye to the users, using their username. In App.js, we are rendering the Goodbye component which is a child, twice and passing the “name” as our props.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// this is App.js
import React, { Component } from 'react';
import Goodbye from './Goodbye.jsx'
class App extends Component {
 render() {
    return (
     &amp;lt;div&amp;gt;
      &amp;lt;Goodbye name="Joe Goldberg"/&amp;gt;
      &amp;lt;Goodbye name="Mrs Maisel"/&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}
export default App;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Unlike Welcome which was a functional component, Goodbye will be a class component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this is Goodbye.js
import React, { Component } from 'react';
class Goodbye extends Component {
  render() {
    return (
      &amp;lt;h1&amp;gt;Goodbye {this.props.name}&amp;lt;/h1&amp;gt;
    );
  }
}
export default Goodbye;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Notice the difference, we are not sending props as parameters anymore. Since Goodbye is a class component, props will be accessed with “this” keyword which is a reserved word in react. Now we can render the h1 element with the associated username using this.props.name inside curly brackets.&lt;br&gt;
Now if we tune into &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;, the result should like this:&lt;/p&gt;

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

&lt;p&gt;A key thing to remember is props are immutable! If we try to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;his.props.name = "Jon Snow";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our application will break and throw an error at us. Try it yourself!&lt;/p&gt;

&lt;p&gt;Points to be noted:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Props can be any data type&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Integer&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Props are immutable&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>100daysofcode</category>
      <category>womenintech</category>
    </item>
  </channel>
</rss>
