<?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: Sahil Bondre</title>
    <description>The latest articles on DEV Community by Sahil Bondre (@godcrampy).</description>
    <link>https://dev.to/godcrampy</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%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png</url>
      <title>DEV Community: Sahil Bondre</title>
      <link>https://dev.to/godcrampy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/godcrampy"/>
    <language>en</language>
    <item>
      <title>☄Deep Dive into Object Oriented Programming: Part 2</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Thu, 23 Sep 2021 13:26:31 +0000</pubDate>
      <link>https://dev.to/godcrampy/deep-dive-into-object-oriented-programming-part-2-2b4</link>
      <guid>https://dev.to/godcrampy/deep-dive-into-object-oriented-programming-part-2-2b4</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/godcrampy/deep-dive-into-object-oriented-programming-part-1-1lbi"&gt;last post&lt;/a&gt;, we started with the basics of Object-Oriented Programming. We made our first class. Added some members and methods to it and initialized an object of the Car class. It's time to dive deeper now.&lt;/p&gt;

&lt;p&gt;Earlier, we had defined a &lt;code&gt;refuelTank&lt;/code&gt; method to increase the fuel in our car. Now when I have a car object with me, no one stops me from changing the &lt;code&gt;fuelLeft&lt;/code&gt; value without using the &lt;code&gt;refuelTank&lt;/code&gt; method. I can directly access the member using the dot operator and change its value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the real-life, I cannot magically change the fuel in my car. That's against the laws of physics. But apparently, I can do that in the software version of my car. To solve this, we'll introduce access modifiers.&lt;/p&gt;
&lt;h2&gt;
  
  
  Access Modifiers
&lt;/h2&gt;

&lt;p&gt;Java has three keywords to solve this problem: &lt;code&gt;public&lt;/code&gt;, &lt;code&gt;private&lt;/code&gt; and &lt;code&gt;protected&lt;/code&gt;. When something is &lt;code&gt;public&lt;/code&gt;, everyone can access it. When something is &lt;code&gt;private&lt;/code&gt;, it can only be accessed internally. We'll talk about &lt;code&gt;protected&lt;/code&gt; in some time.&lt;/p&gt;

&lt;p&gt;To prevent someone from magically changing the &lt;code&gt;fuelLeft&lt;/code&gt; member, we'll add the &lt;code&gt;private&lt;/code&gt; keyword before its definition in the class. This will prevent it from being accessed using the dot operator.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Car.java&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

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

&lt;/div&gt;


&lt;p&gt;But this creates a different problem. In our &lt;code&gt;main&lt;/code&gt; method, we used the &lt;code&gt;fuelLeft&lt;/code&gt; member to print the value. Not to magically change the value but just to have a look at its value.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Main.java&lt;/span&gt;

&lt;span class="c1"&gt;// ERROR!&lt;/span&gt;
&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

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

&lt;/div&gt;


&lt;p&gt;Running the above code will give us an error. To preserve the functionality to be able to view the data, we'll create a "getter" method in the Car class:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Car.java&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;getFuelLeft&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Since this method belongs to and is "inside" the class, it can access the private members. So it just takes the value and returns it. Now we can refactor our main function code to use this method instead of the member:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getFuelLeft&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getFuelLeft&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And voila! Everything works as before with additional security of not changing the &lt;code&gt;fuelLeft&lt;/code&gt; member magically.&lt;/p&gt;
&lt;h3&gt;
  
  
  Refactoring Other Members
&lt;/h3&gt;

&lt;p&gt;If you think about it, all the other members of the Car class should be private by the same argument of not changing their value manually. Let's make all of them private and add getter functions to them:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getColor&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getPeopleCapacity&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getFuelLeft&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getDistanceTravelled&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// other methods...&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Access of methods
&lt;/h3&gt;

&lt;p&gt;Just like members, we can add access modifiers to our class methods as well. If a class method is &lt;code&gt;private&lt;/code&gt;, it cannot be called using the dot operator in the object. It can only be used internally by other methods inside the class. And that is the reason we had&lt;/p&gt;

&lt;p&gt;In the last post, we defined our constructor as &lt;code&gt;public&lt;/code&gt;. Now let's make sense of it. Our constructor needs to be accessible from anywhere to initialize the object from the class. Hence, we made it &lt;code&gt;public&lt;/code&gt;. Let's now define a &lt;code&gt;private&lt;/code&gt; method. When we start the engine, the car also checks if all the systems are working in proper condition. Let's call this method &lt;code&gt;checkSystems&lt;/code&gt;. This method shouldn't be used by the car user but just called internally by the &lt;code&gt;startEngine&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Car.java&lt;/span&gt;

&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;checkSystems&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Checking Systems..."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;checkSystems&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Starting Engine!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now when we call &lt;code&gt;startEngine&lt;/code&gt; on the car object from the main method, it'll print "Checking Systems..." too. However, we cannot access the &lt;code&gt;checkSystems&lt;/code&gt; method externally:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Main.java&lt;/span&gt;

&lt;span class="c1"&gt;// ERROR&lt;/span&gt;
&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;checkSystems&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now you may wonder, earlier all members and methods in the &lt;code&gt;Car&lt;/code&gt; class were neither public nor private; still we could access them. Why is that? If nothing is mentioned, does java make them public by default? The short answer is not really. Let's take a step back and understand what packages are in java.&lt;/p&gt;
&lt;h2&gt;
  
  
  Packages
&lt;/h2&gt;

&lt;p&gt;Packages in java are used to group similar classes (and sub-packages) together. At the start of each java class, we mention the package name:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.godcrampy.oop_deep_dive&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Conventionally, to avoid naming collisions, companies use reverse domain names as a prefix for the package name. So if let's say if a company has its domain as &lt;code&gt;example.com&lt;/code&gt; and is developing a utility for helpful string operations, it may name it as &lt;code&gt;com.example.string_util&lt;/code&gt;. Packages can contain sub-packages too. So, suppose the string operations utility has a section for generating random names. In that case, it could be in a package called &lt;code&gt;com.example.string_util.random_name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;All the class files are structured in directories according to the package name. For example, let's consider the java project that I am using for this tutorial. I have defined the package name as &lt;code&gt;com.godcrampy.oop_deep_dive&lt;/code&gt;. All the source code for my project is in the &lt;code&gt;src/main&lt;/code&gt; folder of the repository with the following structure:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    └── src
        └── main
            └── java
                └── com
                    └── godcrampy
                        └── oop_deep_dive
                            ├── Car.java
                            └── Main.java

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

&lt;/div&gt;


&lt;p&gt;Now let's move our &lt;code&gt;Car&lt;/code&gt; class to a subpackage called &lt;code&gt;vehicle&lt;/code&gt;. To do this, I created a new directory called &lt;code&gt;vehicle&lt;/code&gt; and moved the class there:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;└── src
    └── main
        └── java
            └── com
                └── godcrampy
                    └── oop_deep_dive
                        ├── Main.java
                        └── vehicle
                            └── Car.java

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

&lt;/div&gt;


&lt;p&gt;Now we need to update the package declarations of our Car class. So I change the first line of the Car class from &lt;code&gt;package com.godcrampy.oop_deep_dive;&lt;/code&gt; to &lt;code&gt;package com.godcrampy.oop_deep_dive.vehicle;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, if you are coding along with this tutorial, you may notice that your IDE has already started showing some errors. &lt;code&gt;honda.startEngine&lt;/code&gt;, &lt;code&gt;honda.refuelTank&lt;/code&gt; and &lt;code&gt;honda.drive&lt;/code&gt; methods are not accessible in the &lt;code&gt;main&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;For these methods, we didn't add the &lt;code&gt;public&lt;/code&gt; or &lt;code&gt;private&lt;/code&gt; keywords. So when a member or method has no access modifier specified, it gets the &lt;code&gt;default&lt;/code&gt; access. This means that they can be accessed in some other class only if both the classes are in the same package. In our example, both &lt;code&gt;Main&lt;/code&gt; and &lt;code&gt;Car&lt;/code&gt; classes were in &lt;code&gt;com.godcrampy.oop_deep_dive&lt;/code&gt; package. So everything worked fine before. So when we moved &lt;code&gt;Car&lt;/code&gt; to &lt;code&gt;com.godcrampy.oop_deep_dive.vehicle&lt;/code&gt; package, all the default methods became inaccessible.&lt;/p&gt;
&lt;h2&gt;
  
  
  Fixing the defaults
&lt;/h2&gt;

&lt;p&gt;To fix this, I'll make all the default methods in our car class &lt;code&gt;public&lt;/code&gt;. So finally, the Car class looks like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.godcrampy.oop_deep_dive.vehicle&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getColor&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getPeopleCapacity&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getFuelLeft&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="nf"&gt;getDistanceTravelled&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Car&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;peopleCapacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;checkSystems&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Checking Systems..."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;checkSystems&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Starting Engine!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;drive&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Driving..."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now all the errors are gone, and we are good to go. If you notice, at the start of the class as well, we added the public keyword: &lt;code&gt;public class Car {&lt;/code&gt;. This follows from the same access rules as we discussed before.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In summary:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Acess Modifier&lt;/th&gt;
&lt;th&gt;Within Class&lt;/th&gt;
&lt;th&gt;Within Package&lt;/th&gt;
&lt;th&gt;Outside Package&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Private&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Default&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Protected&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;protected&lt;/code&gt; keyword is still to be investigated. We will do that in the next post.&lt;br&gt;
That wraps it up for the post. We understood what access modifiers are and how they can be used to improve the security of our code. We also explored packages in java and how to organise our code. You can find the code mentioned in the post here: &lt;a href="https://github.com/godcrampy/oop-deep-dive-notes" rel="noopener noreferrer"&gt;https://github.com/godcrampy/oop-deep-dive-notes&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;I hope you liked the post. If this was helpful, please show some love by clicking ♥, 🦄 and saving the post for later. Feel free to express your suggestions and opinoins in the comments below. Oh, BTW do you want to learn Bash? Here's my crash-course post on Shell Scripting:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/godcrampy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png" alt="godcrampy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 The Missing Shell Scripting Crash Course&lt;/h2&gt;
      &lt;h3&gt;Sahil Bondre ・ Apr 21 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#bash&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#linux&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;






&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Follow me on &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt;&lt;br&gt;
📜 Check my &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>oop</category>
      <category>java</category>
    </item>
    <item>
      <title>☄Deep Dive into Object Oriented Programming: Part 1</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Fri, 17 Sep 2021 17:07:16 +0000</pubDate>
      <link>https://dev.to/godcrampy/deep-dive-into-object-oriented-programming-part-1-1lbi</link>
      <guid>https://dev.to/godcrampy/deep-dive-into-object-oriented-programming-part-1-1lbi</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this series of posts, We are going to explore object-oriented programming. We'll start with a few basic concepts, then build upon them, trying to dig more and more into the depths of object-oriented programming.&lt;br&gt;
Object-oriented programming is one of the three popular paradigms of programming. The other being functional and procedural programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Procedural programming&lt;/strong&gt; is based on making procedure calls. A procedure contains a series of instructions that need to be executed. Procedures are also commonly referred to as functions or routines. In procedural programming, we write a list of instructions to tell the computer what to do line by line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional programming&lt;/strong&gt; treats computation as a series of mathematical functions. Each function takes in data, does some computation and returns some data. A key idea in this paradigm is that state and data should be immutable. Thinking of computer programs as mathematical functions are quite an exciting idea; we'll save it for another post!&lt;/p&gt;

&lt;p&gt;Finally, &lt;strong&gt;object-oriented programming&lt;/strong&gt; tries to map real-world objects into the software. Using object-oriented programming, we can model the properties and the functions of things that appear in our natural world and simulate them in our computer programs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Class vs Object
&lt;/h2&gt;

&lt;p&gt;OOP boils down to emulating real-world things in our code. Every real-world item has some properties and a few things it can perform. Let's say we want to model a car in our code. Let's consider a few properties of a car:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is its name? &lt;code&gt;String&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;What is its colour? &lt;code&gt;String&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How many people can it accommodate? &lt;code&gt;Integer&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How much fuel is there in the car currently? &lt;code&gt;Integer&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;How much distance has it travelled so far? &lt;code&gt;Integer&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's also assume that the car can perform some essential functions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start the engine&lt;/li&gt;
&lt;li&gt;Refuel the tank&lt;/li&gt;
&lt;li&gt;Drive a certain distance etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we'll model our car in code. We need to define a class like a blueprint describing all these car characteristics to the programming language.&lt;/p&gt;
&lt;h3&gt;
  
  
  Defining the Class
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.godcrampy.oop_deep_dive&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Car&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;peopleCapacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Starting Engine!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;drive&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Driving..."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's break the code down piece by piece:&lt;/p&gt;
&lt;h4&gt;
  
  
  Members
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;distanceTravelled&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;These are known as the members of the class. Imagine them to be variables of the class. When we make a new car, every car object will get its own copy of these variables. I've defined them as either &lt;code&gt;String&lt;/code&gt; or &lt;code&gt;Integer&lt;/code&gt; as per the property of the car that they represent.&lt;/p&gt;
&lt;h4&gt;
  
  
  Methods
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Starting Engine!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;fuel&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;drive&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Driving..."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;These are the methods that we've defined to imitate various functions of a real-world car. &lt;code&gt;startEngine&lt;/code&gt; imitates the starting of the engine by printing to the console. &lt;code&gt;refuelTank&lt;/code&gt; takes in an Integer and increases the &lt;code&gt;fuelLeft&lt;/code&gt; member of the class by that amount. The same goes for the &lt;code&gt;drive&lt;/code&gt; method that increases the &lt;code&gt;distanceTravelled&lt;/code&gt; member and prints out a message on the console.&lt;/p&gt;
&lt;h4&gt;
  
  
  Constructor
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Car&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;peopleCapacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;peopleCapacity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;distanceTravelled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is a unique method of the class called the constructor. Ignore the &lt;code&gt;public&lt;/code&gt; keyword; we'll get back to it later. Notice that it has the same name as the class. Also, notice that we don't specify any return type (like &lt;code&gt;void&lt;/code&gt; or &lt;code&gt;int&lt;/code&gt;). The blueprint class tells Java about something known as a &lt;code&gt;Car&lt;/code&gt;, but it does not create a car for us. When we make a car, we need to invoke the constructor method. So essentially, the constructor is the first method that is called when we create a car from the class.&lt;/p&gt;

&lt;p&gt;Have a look at the bunch of &lt;code&gt;this&lt;/code&gt; keyword here. The constructor has three parameters &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;color&lt;/code&gt; and &lt;code&gt;peopleCapacity&lt;/code&gt;. We use these to set the initial values of our own members in the class. Now to distinguish between the &lt;code&gt;name&lt;/code&gt; of our class and &lt;code&gt;name&lt;/code&gt; of the constructor, we use th&lt;code&gt;is&lt;/code&gt; keyword. The parameter &lt;code&gt;name&lt;/code&gt; belongs to the function scope and just writing &lt;code&gt;name&lt;/code&gt; points to the parameter. To access the member &lt;code&gt;name&lt;/code&gt;, we use &lt;code&gt;this.name&lt;/code&gt; as it is in the outer scope of the class. Now let's actually make a car object from the class that we have defined over here.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating the Object
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.godcrampy.oop_deep_dive&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Main&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;honda&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="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Honda"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Starting Engine!
100
200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's step through the code line by line and see what's happening:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;honda&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="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Honda"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We use the &lt;code&gt;new&lt;/code&gt; keyword to instantiate an object from a class. The &lt;code&gt;Car&lt;/code&gt; in &lt;code&gt;Car honda =&lt;/code&gt; refers to the type of the variable &lt;code&gt;honda&lt;/code&gt;. The &lt;code&gt;Car&lt;/code&gt; in &lt;code&gt;new Car(...)&lt;/code&gt; is a call to the constructor. Observe the parameters we are passing are precisely the same as the constructor above expects. This runs the code in the constructor and sets the members accordingly.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;startEngine&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here we are calling the &lt;code&gt;startEngine&lt;/code&gt; method of the &lt;code&gt;Car&lt;/code&gt;. We use &lt;code&gt;.&lt;/code&gt; operator to access members and methods of the object. This, in turn, runs the imaginary code to start our car's engine and prints "Starting Engine!" on our console.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here we are accessing the value of the&lt;code&gt;fuelLeft&lt;/code&gt; variable of the car and printing it out.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;refuelTank&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;honda&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fuelLeft&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;refuelTank&lt;/code&gt; function increases the &lt;code&gt;fuelLeft&lt;/code&gt; of the &lt;code&gt;honda&lt;/code&gt; car, and on the following line, when we print it again, we can see the final value to be &lt;code&gt;200&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  What did we discover?
&lt;/h2&gt;

&lt;p&gt;We have now established the basics of Object-oriented programming. Let's take a step back and analyze the consequences of what we have discovered so far. In procedural programming, we used to pass data into procedures to performs computations. In this paradigm, the data itself can perform operations on itself. The Car class has all its properties built-in and knows all the tasks it is supposed to serve. This new way of thinking about programs has its own advantages and disadvantages:&lt;/p&gt;
&lt;h4&gt;
  
  
  Advantages:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Classes are logically a layer of abstraction above writing simple procedures. This makes it easier to write complex software.&lt;/li&gt;
&lt;li&gt;It's easier to write and maintain code (open to debate :P)&lt;/li&gt;
&lt;li&gt;Object-oriented code has a reasonable degree of reusability. The standard library of Java is a beautiful example of this.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Disadvantages:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Look at the lines of code we wrote and what we printed out. A large number of lines of code is required to set up things and bootstrap even the most straightforward programs.&lt;/li&gt;
&lt;li&gt;Computer hardware still executes code pretty much in a procedural way, line by line. Object-oriented code runs a bit slower as it requires extra processing layers before it reaches the silicon level.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That wraps it up for the post. We laid the foundation to build upon even more object-oriented programming concepts in the upcoming stream of posts. You can find the code mentioned in the post here: &lt;a href="https://github.com/godcrampy/oop-deep-dive-notes" rel="noopener noreferrer"&gt;https://github.com/godcrampy/oop-deep-dive-notes&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;I hope you liked the post. If this was helpful, please show some love by clicking ♥, 🦄 and saving the post for later. Oh, BTW do you want to learn Bash? Here's my crash-course post on Shell Scripting:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/godcrampy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png" alt="godcrampy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 The Missing Shell Scripting Crash Course&lt;/h2&gt;
      &lt;h3&gt;Sahil Bondre ・ Apr 21 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#bash&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#linux&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;






&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Find me on &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>oop</category>
    </item>
    <item>
      <title>🌞 Java I/O with java.io Package</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Wed, 14 Jul 2021 10:30:10 +0000</pubDate>
      <link>https://dev.to/godcrampy/java-i-o-with-java-io-package-lm9</link>
      <guid>https://dev.to/godcrampy/java-i-o-with-java-io-package-lm9</guid>
      <description>&lt;p&gt;In this video, we'll look at the java.io package. This package implements input and output through streams of data.&lt;/p&gt;

&lt;p&gt;I'll go over various classes in the java.io package that allows us to perform operations on data streams. I'll explain the hierarchy of these classes and show how to use them together in a program to perform IO.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/f7PrLM2d6HQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/8/docs/api/java/io/package-summary.html" rel="noopener noreferrer"&gt;Oracle java.io Documentation&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;And that is it, folks. Let me know your takeaways from the video. If you have any other video or article ideas, comment on them too. Oh, BTW, do you want to learn Bash? Here's my crash-course post on Shell Scripting:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/godcrampy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png" alt="godcrampy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 The Missing Shell Scripting Crash Course&lt;/h2&gt;
      &lt;h3&gt;Sahil Bondre ・ Apr 21 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#bash&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#linux&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;





&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.youtube.com/c/SahilBondre" rel="noopener noreferrer"&gt;Youtube&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>📦 How is C++ Compiled?</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Sun, 11 Jul 2021 12:16:25 +0000</pubDate>
      <link>https://dev.to/godcrampy/how-is-c-compiled-4668</link>
      <guid>https://dev.to/godcrampy/how-is-c-compiled-4668</guid>
      <description>&lt;p&gt;I've been using C++ for quite a while now. This got me into thinking, how does C++ work under the hood? So I came up with this short video in which I explain the whole C++ compilation process.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rUtprDA0bgc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;And that is it, folks. Let me know your takeaways from the video. If you have any other video or article ideas, comment on them too. Oh, BTW, do you want to learn Bash? Here's my crash-course post on Shell Scripting:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/godcrampy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png" alt="godcrampy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 The Missing Shell Scripting Crash Course&lt;/h2&gt;
      &lt;h3&gt;Sahil Bondre ・ Apr 21 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#bash&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#linux&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;





&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.youtube.com/c/SahilBondre" rel="noopener noreferrer"&gt;Youtube&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>c</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>🐋 ELI5 Docker: Easy Docker Concepts in 5 Minutes!</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Sun, 17 Jan 2021 14:13:40 +0000</pubDate>
      <link>https://dev.to/devunf/eli5-docker-easy-docker-concepts-in-5-minutes-3812</link>
      <guid>https://dev.to/devunf/eli5-docker-easy-docker-concepts-in-5-minutes-3812</guid>
      <description>&lt;h1&gt;
  
  
  A Story
&lt;/h1&gt;

&lt;p&gt;Let's start with a story first. Mary was a painter in the Medieval era who was really good at drawing portraits. She wanted some career change. Nature was more exciting to her than the faces of people. So she decided to travel. She travelled all the way to the beautiful Fjords in Norway for some inspiration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu7q52ia106w8gz5w6cj5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu7q52ia106w8gz5w6cj5.jpg" alt="Fjords" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@robertbye?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Robert Bye&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/fjords?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;She quickly realized that the environment around her was not suitable. &lt;br&gt;
It was way too cold. Norwegian food wasn't her favourite either. And she couldn't work without her canvas and pigments.&lt;/p&gt;

&lt;p&gt;She came up with a plan. On a piece of paper, she noted all the things she needed to live, eat, sleep, and paint in the foreign land. She further listed where to get them and wrote the steps to build a small abode to live and work for a few weeks peacefully.&lt;/p&gt;

&lt;p&gt;She went to Amazon (the internet was built in Renaissance!), fetched all the things and made her a small cabin according to her paper's recipe. She then could work peacefully in an environment that was suitable to her. A few days later, a friend who fancied changing jobs wanted to join her too. Mary then gave the page containing the instructions to John. Since all the ingredients and steps were already documented, John made his own cabin in no time and got to work in Norway too. End of story!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F382bghpw20g8hkazqceu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F382bghpw20g8hkazqceu.jpg" alt="Cabin in Woods" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@olivier_twwli?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Olivier Guillard&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/cabin?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  What's Docker
&lt;/h1&gt;

&lt;p&gt;Let's get back to Docker now:&lt;/p&gt;

&lt;p&gt;The painters in the story are like the programs that we write. They might work correctly on our machine but maybe not on someone else's computer. The other system may have a different version of Python or Node, different pre-installed packages or even a completely different OS. As in the story, our applications won't work in a completely different environment, so we need to build a small cabin to do their job comfortably. These are known as &lt;strong&gt;Images&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Images
&lt;/h3&gt;

&lt;p&gt;Docker Images include our application's source code and all the tools, libraries, and packages that it needs to run. We can run these Images as an instance of a &lt;strong&gt;Container&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Container
&lt;/h3&gt;

&lt;p&gt;A Container is a lightweight, independent, executable software package with everything you need to run the application. Images are more of a blueprint, and Containers are more like an executable file.&lt;br&gt;
Remember the page that Mary had made? In the Docker world, we call it the &lt;strong&gt;Dockerfile&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Dockerfile&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A Dockerfile is a text file that includes the recipe to build the Docker Image. It specifies the OS, languages, environmental variables, file locations, network ports, and other components that our app requires.&lt;/p&gt;

&lt;p&gt;Mary could build everything she needed with the help of Renaissance Amazon. Now that's like Docker. To quote the official documentation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Docker Registry
&lt;/h3&gt;

&lt;p&gt;Now let's assume she posted a picture of her page with the recipe (along with links to Amazon) on her Medieval Blog so other people can use it, that would be an example of a public Docker Registry. &lt;br&gt;
A Docker Registry is where the Docker Images are stored. The registry can be either private or public. Several people can collaborate and share images by uploading them to the registry.&lt;br&gt;
One such example of a Docker registry is the Docker Hub. What Github is for code, Docker Hub is for Docker Images.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Steps
&lt;/h1&gt;

&lt;p&gt;So, I've covered all the basic concepts that you'll require to get started to use Docker. There are several resources on the internet from where you can learn docker. I'll list down a few that I've used personally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/get-started/" rel="noopener noreferrer"&gt;Docker's Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/veggiemonk/awesome-docker" rel="noopener noreferrer"&gt;Awesome Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=fqMOX6JJhGo" rel="noopener noreferrer"&gt;Docker Tutorial for Beginners (2 hour video)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=gAkwW2tuIqE" rel="noopener noreferrer"&gt;Learn Docker in 7 Easy Steps (11 minute video)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=aLipr7tTuA4" rel="noopener noreferrer"&gt;MicroNugget: What is Docker and How Does it Work? (10 minute video)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installing Docker
&lt;/h3&gt;

&lt;p&gt;The Docker suite contains two principal tools: Docker Engine and Docker Desktop. &lt;br&gt;
The &lt;a href="https://docs.docker.com/engine/" rel="noopener noreferrer"&gt;Docker Engine&lt;/a&gt; is the core set of docker tools required to run docker commands and containers on your machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.docker.com/desktop/" rel="noopener noreferrer"&gt;Docker Desktop&lt;/a&gt; is a GUI that talks to the underlying Docker Engine to make your life easy.&lt;/p&gt;

&lt;h1&gt;
  
  
  What's next?
&lt;/h1&gt;

&lt;p&gt;Docker is among the first steps to learn about Microservices and DevOps. You can start learning about the microservice vs monolith philosophy, container orchestration, Kubernetes there's lots and lots of great stuff to learn!&lt;/p&gt;




&lt;p&gt;🌟 Thank's for reading! I'd love to hear any feedback, opinions, and ideas for what I should write on next.&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>🚀 Github Hidden Feature: Profile README</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Thu, 09 Jul 2020 13:31:10 +0000</pubDate>
      <link>https://dev.to/godcrampy/github-hidden-feature-profile-readme-57m5</link>
      <guid>https://dev.to/godcrampy/github-hidden-feature-profile-readme-57m5</guid>
      <description>&lt;p&gt;Github has a brand new secret feature! Now you can setup a README for your entire profile. Here's how mine looks: &lt;a href="https://github.com/godcrampy" rel="noopener noreferrer"&gt;godcrampy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To enable this, make a repository with the same name as your username:&lt;/p&gt;

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

&lt;p&gt;Then add a &lt;code&gt;README.md&lt;/code&gt; which will then be displayed on your profile page. And that's it!&lt;br&gt;
Thanks, Github for this super cool feature!&lt;/p&gt;




&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>github</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Discuss: What's the one thing you hate about programming?</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Fri, 26 Jun 2020 17:01:41 +0000</pubDate>
      <link>https://dev.to/godcrampy/discuss-what-s-the-one-thing-you-hate-about-programming-4565</link>
      <guid>https://dev.to/godcrampy/discuss-what-s-the-one-thing-you-hate-about-programming-4565</guid>
      <description>&lt;p&gt;What's that &lt;strong&gt;one thing&lt;/strong&gt; that annoys you? What's that &lt;strong&gt;one thing&lt;/strong&gt; that you would improve if you were made the god of programming?&lt;/p&gt;

&lt;p&gt;Alternatively, what was that &lt;strong&gt;one thing&lt;/strong&gt; that was a significant roadblock in your programming history?&lt;/p&gt;

&lt;p&gt;(PS: You can rant about more than one issue)&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>watercooler</category>
      <category>career</category>
    </item>
    <item>
      <title>To Die List: My first indie app!</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Fri, 05 Jun 2020 08:46:40 +0000</pubDate>
      <link>https://dev.to/godcrampy/to-die-list-my-first-indie-app-47b5</link>
      <guid>https://dev.to/godcrampy/to-die-list-my-first-indie-app-47b5</guid>
      <description>&lt;p&gt;&lt;a href="https://www.producthunt.com/posts/to-die-list?utm_source=badge-featured&amp;amp;utm_medium=badge&amp;amp;utm_souce=badge-to-die-list" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fapi.producthunt.com%2Fwidgets%2Fembed-image%2Fv1%2Ffeatured.svg%3Fpost_id%3D205010%26theme%3Dlight" alt="To Die List - Complete your tasks before they die! | Product Hunt Embed" width="250" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I made my first app as an indie dev! It's a todo list app with some &lt;a href="https://en.wikipedia.org/wiki/Gamification" rel="noopener noreferrer"&gt;gamification&lt;/a&gt; dust sprinkled on it. The idea is that every time you create a todo/task, there's a timer running down. If you complete the job before the timer hits zero, some additional time is added to the timer for the rest of your tasks. But instead, if the timer hits zero, then one of your tasks will be randomly killed(deleted).&lt;/p&gt;

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

&lt;p&gt;The app is currently available on Android only. If people end up liking the Android version, I'll make one for IOS. Here are the links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.godcrampy.to_die_list" rel="noopener noreferrer"&gt;To Die List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.godcrampy.to_die_list_pro" rel="noopener noreferrer"&gt;To Die List Pro&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pro version offers additional features such as dark mode and starrable todos. I'd really appreciate it if you could buy the pro version and help me in my indie app journey!&lt;/p&gt;

&lt;p&gt;I'd love to hear feedback from you guys. Please feel free to let me know about any suggestions and bugs you may find.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I built this
&lt;/h2&gt;

&lt;p&gt;I've made this app using &lt;a href="http://flutter.dev/" rel="noopener noreferrer"&gt;flutter&lt;/a&gt; which allows you to create cross-platform apps. Flutter makes it really easy to quickly build mobile apps. If you know React, flutter is a weekend job to learn. If you don't, then two weekends are enough!&lt;/p&gt;




&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>android</category>
      <category>flutter</category>
    </item>
    <item>
      <title>💡 10 VS Code extensions I can't code without</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Thu, 30 Apr 2020 16:00:38 +0000</pubDate>
      <link>https://dev.to/godcrampy/10-vs-code-extensions-i-can-t-code-without-3ann</link>
      <guid>https://dev.to/godcrampy/10-vs-code-extensions-i-can-t-code-without-3ann</guid>
      <description>&lt;p&gt;VS Code is my favourite text editor. It is the most extensible and popular code editors out there. And surprisingly it's made by Microsoft (i know). In my opinion, no other IDE or editor comes even half as close as to what VS Code does. What makes it so robust is it's extension system. It allows you to write an extension for every possible use case you can think of. Here are my top 10 extensions.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;a href="https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify" rel="noopener noreferrer"&gt;Beautify&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6jh0tui9nh993l4zzlwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6jh0tui9nh993l4zzlwd.png" alt="Beautify" width="256" height="256"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install HookyQR.beautify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Beautify allows you to format &lt;code&gt;html&lt;/code&gt;, &lt;code&gt;js&lt;/code&gt;, &lt;code&gt;css&lt;/code&gt;, &lt;code&gt;JSON&lt;/code&gt; and &lt;code&gt;sass&lt;/code&gt; file with your own custom style configuration. It extends over the internal &lt;code&gt;js-beautify&lt;/code&gt; and makes it customizable to your personal style.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. &lt;a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments" rel="noopener noreferrer"&gt;Better Comments&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqwhm3kqyvp22rox4unwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqwhm3kqyvp22rox4unwy.png" alt="Better Comments" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install aaron-bond.better-comments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This extension allows you to add semantics to your comments. It categorizes into categories like comments into alerts, queries, todos and highlights.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3c804dilaxhlgqhfpmmy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3c804dilaxhlgqhfpmmy.png" alt="Better Comments Screen Shots" width="459" height="414"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. &lt;a href="https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks" rel="noopener noreferrer"&gt;Bookmarks&lt;/a&gt;
&lt;/h2&gt;

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

&lt;p&gt;This one is a lifesaver, especially if you find yourself lost in hundreds of lines of code. This extension allows you to bookmark any line of code. Then when you need to go back all you need to do is browse through the list of bookmarks and select the line you want to visit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3mzmg6eqru89d3l0nzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3mzmg6eqru89d3l0nzc.png" alt="Alt Text" width="749" height="471"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. &lt;a href="https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2" rel="noopener noreferrer"&gt;Bracket Pair Colorizer 2&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8whhlyzqn5a9pni5q9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq8whhlyzqn5a9pni5q9o.png" alt="Bracket Pair Colorizer" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install CoenraadS.bracket-pair-colorizer-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This one does exactly what its name suggests. It colour codes correlated pairs of brackets. This helps a lot when you end up several scopes deep into code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftz0fet4e1is8kurpzdl4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftz0fet4e1is8kurpzdl4.png" alt="Bracket Pair Colorizer" width="625" height="119"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  5. &lt;a href="https://marketplace.visualstudio.com/items?itemName=lacroixdavid1.vscode-format-context-menu" rel="noopener noreferrer"&gt;Format in Context Menus&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flklut6q62ky3ia64h6wo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flklut6q62ky3ia64h6wo.png" alt="Alt Text" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install lacroixdavid1.vscode-format-context-menu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This extension allows you to format all your files by just selecting them from the side-bar. This is especially useful when you have tonnes of files, and your environment does not support formatters and linters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhgqnbo219iis3i8ru9vf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhgqnbo219iis3i8ru9vf.gif" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  6. &lt;a href="https://marketplace.visualstudio.com/items?itemName=mhutchie.git-graph" rel="noopener noreferrer"&gt;Git Graph&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffj1eujct11n0k02805rg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffj1eujct11n0k02805rg.png" alt="Alt Text" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install mhutchie.git-graph
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It allows you to view a Git Graph of your repository, and quickly perform Git actions from the graph. It is highly configurable and has lots of features. Explaining the goodness of this extension will probably take a whole new post.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv800jt7z8zif3k4eo11n.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv800jt7z8zif3k4eo11n.gif" alt="Alt Text" width="1208" height="682"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  7. &lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens" rel="noopener noreferrer"&gt;Git Lens&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm7a2x37bh157ly1c7egp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm7a2x37bh157ly1c7egp.png" alt="Alt Text" width="419" height="132"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install eamodio.gitlens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;GitLens helps you to reflect code authorship at a glance via Git blame annotations and code lens. It enables you to seamlessly navigate and explore Git repositories, gain valuable insights via robust comparison commands, and so much more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6v0fm7xih9z5so6h0fno.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6v0fm7xih9z5so6h0fno.png" alt="Alt Text" width="610" height="216"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  8. &lt;a href="https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow" rel="noopener noreferrer"&gt;indent-rainbow&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F79m9505m369sxfm44m2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F79m9505m369sxfm44m2v.png" alt="Indent Rainbow" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install oderwat.indent-rainbow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This extension colourizes the indentation of code, in different colours on each indent level. This is especially helpful in deep scopes with languages like Python.&lt;/p&gt;
&lt;h2&gt;
  
  
  9. &lt;a href="https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense" rel="noopener noreferrer"&gt;Path Intellisense&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fckei8za87rr4pjdq4tzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fckei8za87rr4pjdq4tzd.png" alt="Alt Text" width="128" height="128"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install christian-kohler.path-intellisense
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Path Intellisense adds auto-completion to file paths. While VS-Code natively supports auto-completion, it is limited to only HTML, CSS and JavaScript files. This extends it to all languages and file types.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkoon5g53xuxxi3zsko9y.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkoon5g53xuxxi3zsko9y.gif" alt="Alt Text" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  10. &lt;a href="https://marketplace.visualstudio.com/items?itemName=praveencrony.total-lines" rel="noopener noreferrer"&gt;Total Lines&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fne5j4t2bg6rlfcktfe76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fne5j4t2bg6rlfcktfe76.png" alt="Alt Text" width="274" height="174"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ext install praveencrony.total-lines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This a handy little extension add the number of lines of the currently opened file in the status bar. A neat addition to your extension collection.&lt;/p&gt;



&lt;p&gt;And that is it folks. These are my top VS Code extensions. I'd like to hear your favorite extensions in the comments. Oh, BTW do you want to learn Bash? Here's my crash-course post on Shell Scripting:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/godcrampy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F205514%2F0dd8c32b-08d0-4003-991f-b9084ee99d91.png" alt="godcrampy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 The Missing Shell Scripting Crash Course&lt;/h2&gt;
      &lt;h3&gt;Sahil Bondre ・ Apr 21 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#bash&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#linux&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;






&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>🔭 Git Stalker: Stalk GitHub users without leaving your terminal!</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Sat, 25 Apr 2020 13:35:40 +0000</pubDate>
      <link>https://dev.to/godcrampy/git-stalker-stalk-github-users-without-leaving-your-terminal-1moj</link>
      <guid>https://dev.to/godcrampy/git-stalker-stalk-github-users-without-leaving-your-terminal-1moj</guid>
      <description>&lt;p&gt;Github is &lt;em&gt;the&lt;/em&gt; platform for code and for developers. I'd spend tons of time stalking friends, colleagues and pros like &lt;a href="https://github.com/sindresorhus" rel="noopener noreferrer"&gt;Sindre Sorhus&lt;/a&gt;, &lt;a href="https://github.com/ry" rel="noopener noreferrer"&gt;Ryan Dahl&lt;/a&gt;, starring and forking repos and just slacking off Github. I'm sure you do too. Stalking code and devs on Github is fun. Can we make it &lt;em&gt;efficient&lt;/em&gt;? Can we make it &lt;em&gt;mouse-less&lt;/em&gt;? Can we do it from the &lt;em&gt;terminal&lt;/em&gt; itself?&lt;/p&gt;

&lt;p&gt;Well, now you can with Git Stalker.&lt;/p&gt;

&lt;p&gt;I made &lt;a href="https://github.com/godcrampy/git-stalker" rel="noopener noreferrer"&gt;git-stalker&lt;/a&gt;, which is a CLI that allows you to stalk people on GitHub from your terminal. It shows you the profile of the dev, what (programming) languages do they speak and what have they been up to lately. Here's the demo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F87zcnhbytb5u3wjy4g1i.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F87zcnhbytb5u3wjy4g1i.gif" alt="Demo Gif" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9lv1m9flc4vtsgk7lje4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9lv1m9flc4vtsgk7lje4.png" alt="Demo" width="721" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;You need &lt;code&gt;node&lt;/code&gt; + &lt;code&gt;npm&lt;/code&gt; to install this CLI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; git-stalker

&lt;span class="c"&gt;# or using yarn&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;yarn global add git-stalker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;stalk &amp;lt;github-username&amp;gt;

&lt;span class="c"&gt;# For example&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;stalk godcrampy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Built With
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;Typescript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.github.com/v3/" rel="noopener noreferrer"&gt;GitHub API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;And several awesome &lt;a href="https://github.com/godcrampy/git-stalker/blob/master/package.json#L56#L67" rel="noopener noreferrer"&gt;dependencies&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;So the current release allows stalking people. Why not hunt repos? I'll probably work on that. If you have any ideas, please open up an &lt;a href="https://github.com/godcrampy/git-stalker/issues/new" rel="noopener noreferrer"&gt;issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's the repo for Git Stalker.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/godcrampy" rel="noopener noreferrer"&gt;
        godcrampy
      &lt;/a&gt; / &lt;a href="https://github.com/godcrampy/git-stalker" rel="noopener noreferrer"&gt;
        git-stalker
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🔭 Stalk GitHub users without leaving your terminal
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Git Stalker&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/2596065fc2ab4c7a382c945b9db8d6147396ae05ab13b1708e94e6bdbae6f70a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6769742d7374616c6b6572"&gt;&lt;img src="https://camo.githubusercontent.com/2596065fc2ab4c7a382c945b9db8d6147396ae05ab13b1708e94e6bdbae6f70a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6769742d7374616c6b6572" alt="npm"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/c8408a357d11b78e6041549e640f5208578e39495b523e65a3a17d48c84c5b35/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f6769742d7374616c6b6572"&gt;&lt;img src="https://camo.githubusercontent.com/c8408a357d11b78e6041549e640f5208578e39495b523e65a3a17d48c84c5b35/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f6769742d7374616c6b6572" alt="NPM"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/db8c3b22e2691c4fe398c48ed0fa693f7ff2e2c30ac2e29e3c73f50262c81397/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f676f646372616d70792f6769742d7374616c6b65723f7374796c653d736f6369616c"&gt;&lt;img src="https://camo.githubusercontent.com/db8c3b22e2691c4fe398c48ed0fa693f7ff2e2c30ac2e29e3c73f50262c81397/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f676f646372616d70792f6769742d7374616c6b65723f7374796c653d736f6369616c" alt="GitHub stars"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Stalk GitHub users without leaving your terminal.&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/godcrampy/git-stalkerdocs/git-stalk.gif"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fgodcrampy%2Fgit-stalkerdocs%2Fgit-stalk.gif" alt="demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Install&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ npm i -g git-stalker

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; or using yarn&lt;/span&gt;

$ yarn global add git-stalker&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Usage&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ stalk &lt;span class="pl-k"&gt;&amp;lt;&lt;/span&gt;username&lt;span class="pl-k"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; For example&lt;/span&gt;
$ stalk godcrampy&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Authors&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sahil Bondre&lt;/strong&gt; - &lt;a href="https://github.com/godcrampy" rel="noopener noreferrer"&gt;godcrampy&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;License&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;This project is licensed under the MIT License - see the &lt;a href="https://github.com/godcrampy/git-stalkerLICENSE" rel="noopener noreferrer"&gt;LICENSE&lt;/a&gt; file for details&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/godcrampy/git-stalker" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Stalk me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>github</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Publish your Dart Package</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Thu, 23 Apr 2020 14:17:45 +0000</pubDate>
      <link>https://dev.to/godcrampy/how-to-publish-your-dart-package-i2f</link>
      <guid>https://dev.to/godcrampy/how-to-publish-your-dart-package-i2f</guid>
      <description>&lt;p&gt;In this tutorial, I'll be making a &lt;a href="https://dart.dev/guides/packages" rel="noopener noreferrer"&gt;Dart Package&lt;/a&gt; from scratch. I'll be going over all the steps for creating a package from coding till publishing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Package
&lt;/h2&gt;

&lt;p&gt;For this tutorial, I made a &lt;a href="https://pub.dev/packages/regex_toolkit" rel="noopener noreferrer"&gt;package&lt;/a&gt; that provides commonly used regex patterns. Let's go over how the library works before building it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Installation
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# pubspec.yaml&lt;/span&gt;
&lt;span class="na"&gt;dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;regex_toolkit&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^1.0.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pub&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Usage
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:regex_toolkit/regex_toolkit.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'john@doe.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RegexToolkit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;emailId&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasMatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Valid Email'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Invalid Email'&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;dart main.dart
Email Valid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building
&lt;/h2&gt;

&lt;p&gt;Let's build our package now.&lt;/p&gt;

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

&lt;p&gt;We'll use &lt;a href="https://github.com/dart-lang/stagehand" rel="noopener noreferrer"&gt;stagehand&lt;/a&gt; to bootstrap a starter template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pub global activate stagehand
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &amp;lt;project_name&amp;gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; &amp;lt;project-name&amp;gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;stagehand package-simple
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets us up with a boiler template of a simple Dart package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── analysis_options.yaml
├── CHANGELOG.md
├── example
│   └── &amp;lt;project-name&amp;gt;_example.dart
├── lib
│   ├── &amp;lt;project-name&amp;gt;.dart
│   └── src
│       └── &amp;lt;project-name&amp;gt;_base.dart
├── .gitignore
├── pubspec.lock
├── pubspec.yaml
├── README.md
└── test
    └── &amp;lt;project-name&amp;gt;_test.dart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Code
&lt;/h3&gt;

&lt;p&gt;Next up is the actual coding part. Dart package &lt;a href="https://dart.dev/guides/libraries/create-library-packages#organizing-a-library-package" rel="noopener noreferrer"&gt;convention&lt;/a&gt; is to write all of your code in &lt;code&gt;lib/src&lt;/code&gt; directory and export required code through in &lt;code&gt;src/&amp;lt;project-name&amp;gt;.dart&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lib/src/regex_toolkit_base.dart&lt;/span&gt;
&lt;span class="c1"&gt;/// Base class containing all the [RegExp] instances&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RegexToolkit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// All the code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lib/regex_toolkit.dart&lt;/span&gt;
&lt;span class="c1"&gt;/// A collection of commonly used regular expressions.&lt;/span&gt;
&lt;span class="kn"&gt;library&lt;/span&gt; &lt;span class="n"&gt;regex_toolkit&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;export&lt;/span&gt; &lt;span class="s"&gt;'src/regex_toolkit_base.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Test
&lt;/h3&gt;

&lt;p&gt;Tests are written in &lt;code&gt;test/&lt;/code&gt; directory. Each test-suite comprises of a &lt;code&gt;group&lt;/code&gt; which consists of several &lt;code&gt;test&lt;/code&gt;s. Each &lt;code&gt;test&lt;/code&gt; test one specific functionality. Assertions are done using the &lt;code&gt;expect&lt;/code&gt; function, which takes in two arguments: &lt;code&gt;actual&lt;/code&gt; and &lt;code&gt;expected&lt;/code&gt;. If both of them match, then the test passes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Common regualer expressions'&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="n"&gt;setUp&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 setup code if any&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'adds two numbers'&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="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// More tests...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Documentation
&lt;/h3&gt;

&lt;p&gt;When it comes to documentation, there are three places you need to write documentation in: &lt;code&gt;README.md&lt;/code&gt;, &lt;code&gt;example&lt;/code&gt; and &lt;code&gt;comments&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;README.md&lt;/code&gt; is reasonably apparent, every GitHub repo has that. The example directory should some code showing a sample use of the package. Here's how I have done in my package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// example/main.dart&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:regex_toolkit/regex_toolkit.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'john@doe.com'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RegexToolkit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;emailId&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasMatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Valid Email'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Invalid Email'&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;You might have noticed that comments with three forward slashes: &lt;code&gt;///&lt;/code&gt;. These are used by Dart to form the package documentation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;/// Description of what this function does&lt;/span&gt;
&lt;span class="kt"&gt;void&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="c1"&gt;// code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This documentation is what is shown in the &lt;a href="https://pub.dev/documentation/regex_toolkit/latest/" rel="noopener noreferrer"&gt;API Reference&lt;/a&gt; of your package once published. To get a preview, run &lt;a href="https://pub.dev/documentation/dartdoc/latest/" rel="noopener noreferrer"&gt;&lt;code&gt;dartdoc&lt;/code&gt;&lt;/a&gt; in your project directory. &lt;code&gt;dartdoc&lt;/code&gt; will create the documentation preview in &lt;code&gt;doc/api&lt;/code&gt; directory. You can open up the &lt;code&gt;doc/api/index.html&lt;/code&gt; to preview the generated documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Publish
&lt;/h3&gt;

&lt;p&gt;Once you are confident enough with your code, tests and documentation, it's time to publish your code to &lt;a href="https://pub.dev" rel="noopener noreferrer"&gt;pub.dev&lt;/a&gt;. Before publishing, it's a good practice to check for the following things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure all tests pass &lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;dartanalyzer&lt;/code&gt; and fix errors is any&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;dartdoc&lt;/code&gt; and verify the docs&lt;/li&gt;
&lt;li&gt;Make sure that &lt;code&gt;README.md&lt;/code&gt;, &lt;code&gt;CAHNGELOG.md&lt;/code&gt; and &lt;code&gt;pubspec.yaml&lt;/code&gt; are updated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before you can publish, you need to sign in with your Google account on &lt;a href="https://pub.dev" rel="noopener noreferrer"&gt;pub.dev&lt;/a&gt;. Once that is done, run the following command to test your build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pub publish &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get no errors, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pub publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI will ask you to login again, which is trivial.&lt;/p&gt;

&lt;p&gt;And there you have it. That's how you make your own dart package. As mentioned above, I made my own &lt;a href="https://pub.dev/packages/regex_toolkit" rel="noopener noreferrer"&gt;package&lt;/a&gt; which is a collection of common regex patterns. If you are getting started with Open Source, contributing to this package will be a good starting point. You can add any of the regex patterns which you feel are missing. One major regex which is missing is the time pattern. Hope someone sends a pull request for add that 😄.&lt;/p&gt;

&lt;p&gt;🌟 I made some &lt;a href="https://github.com/godcrampy/cheat-sheets" rel="noopener noreferrer"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Find me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>dart</category>
      <category>flutter</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🚀 The Missing Shell Scripting Crash Course</title>
      <dc:creator>Sahil Bondre</dc:creator>
      <pubDate>Tue, 21 Apr 2020 11:32:18 +0000</pubDate>
      <link>https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk</link>
      <guid>https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk</guid>
      <description>&lt;p&gt;&lt;em&gt;Bash&lt;/em&gt; is a &lt;a href="https://en.wikipedia.org/wiki/Shell_(computing)" rel="noopener noreferrer"&gt;shell&lt;/a&gt; and a &lt;a href="https://en.wikipedia.org/wiki/Command_language" rel="noopener noreferrer"&gt;command language&lt;/a&gt;. You can use it like any other language to write scripts. Bash scripts can run on Linux and Mac right off. For Windows, there's a small &lt;a href="https://stackoverflow.com/questions/6413377/is-there-a-way-to-run-bash-scripts-on-windows" rel="noopener noreferrer"&gt;workout&lt;/a&gt; to be done. In this tutorial I'll be going over &lt;em&gt;Shell Syntax&lt;/em&gt; and not &lt;em&gt;Shell Commands&lt;/em&gt; like &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This crash-course will teach you all the necessary stuff you need to get up and running with writing shell scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Hello World
&lt;/h2&gt;

&lt;p&gt;All you need in this tutorial is your terminal and a text editor. Let's write a simple hello world in bash. Create a new file called &lt;code&gt;script.sh&lt;/code&gt; and write the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now save this file. To make this executable, run &lt;code&gt;chmod +x ./script.sh&lt;/code&gt; in your terminal. Then you can run the above script using &lt;code&gt;./script.sh&lt;/code&gt; in your terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Hello World
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tah Dah! Your first bash script. Let's examine the code closely. The first line &lt;code&gt;#!/bin/bash&lt;/code&gt; is called a &lt;a href="https://en.wikipedia.org/wiki/Shebang_(Unix)" rel="noopener noreferrer"&gt;&lt;em&gt;shebang&lt;/em&gt;&lt;/a&gt;. It tells your computer which program to give this code to run. In our case, it is &lt;code&gt;/bin/bash&lt;/code&gt;.&lt;br&gt;
If you wanted to write &lt;em&gt;javascript&lt;/em&gt; instead of &lt;em&gt;bash&lt;/em&gt; you could write the following code.&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="cp"&gt;#!/bin/node
&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;Hello Javascript&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;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./script.sh
Hello Javascript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will work only if you have node installed in &lt;code&gt;/bin/&lt;/code&gt; directory. So essentially you can write code in any language. All you need to do is specify which &lt;em&gt;program&lt;/em&gt; can handle that code and your system will pass on that file to that program.&lt;/p&gt;

&lt;p&gt;Let's hop back to bash now. In the above code, the second line is &lt;code&gt;echo "Hello World"&lt;/code&gt;. &lt;code&gt;echo&lt;/code&gt; is a &lt;em&gt;command&lt;/em&gt; which prints stuff to the &lt;a href="https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)" rel="noopener noreferrer"&gt;Standard Output&lt;/a&gt; which is the terminal in our case.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Variables
&lt;/h2&gt;

&lt;p&gt;Let's modify the above code a little bit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Bash"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, &lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./script.sh
Hello, Bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We create a variable called &lt;code&gt;name&lt;/code&gt; and store the string &lt;code&gt;"Bash"&lt;/code&gt; to it. Then to access it, we need to reference it with &lt;code&gt;$&lt;/code&gt;. If you forget the &lt;code&gt;$&lt;/code&gt; sign, bash will treat &lt;code&gt;name&lt;/code&gt; as a string literal, and you'll get &lt;code&gt;Hello name&lt;/code&gt; as output instead.&lt;/p&gt;

&lt;p&gt;Note that there are no spaces around the &lt;code&gt;=&lt;/code&gt; while defining a variable. Also, use &lt;em&gt;double quotes&lt;/em&gt; while referencing.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. User Input
&lt;/h2&gt;

&lt;p&gt;Let's continue modifying our script. We'll request the user for their name and then greet them back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"What is you name: "&lt;/span&gt; name

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello &lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./script.sh
What is you name: godcrampy
Hello godcrampy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;read&lt;/code&gt; command takes in one line of input from the &lt;a href="https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)" rel="noopener noreferrer"&gt;Standard Input&lt;/a&gt; and saves it to the variable &lt;code&gt;name&lt;/code&gt;. The &lt;code&gt;-p&lt;/code&gt; flag allows us to pass a prompt of &lt;code&gt;"What is your name: "&lt;/code&gt; before taking in the input.&lt;/p&gt;

&lt;p&gt;One neat trick to reference variables in a string is to use curly braces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Enter an action: "&lt;/span&gt; verb

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"You are &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;verb&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ing"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./script.sh
Enter an action: cook
You are cooking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Comments
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Comments start with hash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://unix.stackexchange.com/questions/37411/multiline-shell-script-comments-how-does-this-work" rel="noopener noreferrer"&gt;Multiline Comments&lt;/a&gt; are a bit of a complicated mess.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Arguments
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt; and so on, store the arguments passed into the script. &lt;code&gt;$0&lt;/code&gt; stores the file name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# Access all the arguments [More on this later]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./script.sh first second
./script.sh
first
second
first second
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Expressions
&lt;/h2&gt;

&lt;p&gt;There are 3 common expressions: return values, arithmetic evaluation and &lt;code&gt;test&lt;/code&gt; command. All three of these return either a true or false value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Return Values&lt;/strong&gt;&lt;br&gt;
This is literally the return value of programs like &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic Evaluation&lt;/strong&gt;&lt;br&gt;
Bash uses a parenthesis to denote arithmetic expressions.&lt;br&gt;
Example: &lt;code&gt;(( 1 &amp;lt;= 5))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Test&lt;/code&gt; Command&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;test&lt;/code&gt; command often denoted by &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;[[&lt;/code&gt; can carry out more complex operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# True if file exists&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# True if file exists and is a directory&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# True if file exists and is a regular file&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;  &lt;span class="c"&gt;# True if string is of length zero&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;  &lt;span class="c"&gt;# True is string is not of length zero&lt;/span&gt;

&lt;span class="c"&gt;# Compare Strings&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$str2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;

&lt;span class="c"&gt;# Integer Comparisions&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 == $int2&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 != $int2&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 &amp;gt; $int2&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 &amp;lt; $int2&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-ge&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 &amp;gt;= $int2&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$int2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# $int1 &amp;lt;= $int2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;[&lt;/code&gt; is actually a command. Try running &lt;code&gt;$ where [&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;test&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;[[&lt;/code&gt; are almost similar. There are a few &lt;a href="http://mywiki.wooledge.org/BashFAQ/031" rel="noopener noreferrer"&gt;subtle differences&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And &amp;amp; Or&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[[&lt;/span&gt; ... &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; ... &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# And&lt;/span&gt;
&lt;span class="o"&gt;[[&lt;/span&gt; ... &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; ... &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="c"&gt;# Or&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Conditionals
&lt;/h2&gt;

&lt;p&gt;Now since we know, expressions let's use them in conditional statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Return values&lt;/span&gt;

&lt;span class="c"&gt;# If notes.md file doesn't exist, create one and &lt;/span&gt;
&lt;span class="c"&gt;# add the text "created by bash"&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;find notes.md
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"notes.md file already exists"&lt;/span&gt;
&lt;span class="k"&gt;else
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"created by bash"&lt;/span&gt; | &lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; notes.md
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 2. Arithmetic Evaluations&lt;/span&gt;
&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Enter your age: "&lt;/span&gt; age

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 18 &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Adult!"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$age&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 12 &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Teen!"&lt;/span&gt;
&lt;span class="k"&gt;else
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Kid"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 3. Test Expressions&lt;/span&gt;
&lt;span class="c"&gt;# Check if argument was passed&lt;/span&gt;
&lt;span class="c"&gt;# "$1" corresponds to first argument&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Your first argument was &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;else
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No Arguments passed"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; statement has to end with &lt;code&gt;fi&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you are keen enough, you might wonder why I am using &lt;code&gt;"$var"&lt;/code&gt; and not &lt;code&gt;$var&lt;/code&gt; to reference the variables. Here's your &lt;a href="https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable" rel="noopener noreferrer"&gt;answer&lt;/a&gt;. (Hint: Both work but double quotes are safer).&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Looping
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# print numbers 1 to 10&lt;/span&gt;

&lt;span class="c"&gt;# c like for loop&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i &lt;span class="o"&gt;=&lt;/span&gt; 1&lt;span class="p"&gt;;&lt;/span&gt; i &amp;lt;&lt;span class="o"&gt;=&lt;/span&gt; 10&lt;span class="p"&gt;;&lt;/span&gt; ++i &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# for in&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;1..10&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# while&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; 10 &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;((&lt;/span&gt;i++&lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# until&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;until&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 11 &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"unitl &lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;((&lt;/span&gt;i++&lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Iterating over arrays&lt;/strong&gt;&lt;br&gt;
Arrays are declared using parenthesis without commas between elements. More on arrays later on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;a b c d&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# For in&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# c like for&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt; i &lt;span class="o"&gt;=&lt;/span&gt; 0&lt;span class="p"&gt;;&lt;/span&gt; i &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${#&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; i++&lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# while&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${#&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;((&lt;/span&gt; i++ &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;${arr[@]}&lt;/code&gt; allows you to iterate over an array while &lt;code&gt;${#arr[@]}&lt;/code&gt; returns the length of the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iterating over arguments&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;@&lt;/code&gt; holds all the arguments passed in to the script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;continue&lt;/code&gt; and &lt;code&gt;break&lt;/code&gt; work the same way as in other programming languages. &lt;code&gt;continue&lt;/code&gt; skips the current iteration. &lt;code&gt;break&lt;/code&gt; quits the loop.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  9. Arrays
&lt;/h2&gt;

&lt;p&gt;Arrays in bash are defined with parenthesis with no commas separating the elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;a b c d&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[1]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;     &lt;span class="c"&gt;# Single element&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[-1]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;    &lt;span class="c"&gt;# Last element&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;:1&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;   &lt;span class="c"&gt;# Elements from 1&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;:1:3&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# Elements from 1 to 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;arr[5]&lt;span class="o"&gt;=&lt;/span&gt;e                            &lt;span class="c"&gt;# direct address and insert/update&lt;/span&gt;
&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;:0:1&lt;span class="k"&gt;}&lt;/span&gt; new &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;:1&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="c"&gt;# Adding 'new' to array&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;a b c d&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;unset &lt;/span&gt;arr[1]
&lt;span class="nb"&gt;echo&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[1]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# Outputs nothing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how once we delete the element at position 1, the following item does not take up its place. Once removing is done, we need to re-index the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;a b c d&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;unset &lt;/span&gt;arr[1]
&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[1]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. Functions
&lt;/h2&gt;

&lt;p&gt;Functions in &lt;em&gt;bash&lt;/em&gt; have a kind of similar syntax as in other programming languages. Arguments to a function are accessed identically to the arguments to the script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;greet&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

greet Bash &lt;span class="c"&gt;# Hello, Bash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function definition does not specify any information of the arguments passed to it. Notice how while calling a function, parenthesis is not used. Instead, arguments are passed in separated by space.&lt;/p&gt;

&lt;p&gt;All the arguments of a function can be accessed using &lt;code&gt;@&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;greet&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

greet every single body &lt;span class="c"&gt;# Hello, every single body&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it for this crash course. You can now start writing your own shell scripts. There's more to be explored beyond what I have mentioned here.&lt;/p&gt;

&lt;p&gt;🌟 I made some &lt;a href="//dev-cheats.surge.sh"&gt;Cheat-Sheets&lt;/a&gt;&lt;br&gt;
🚀 Find me on &lt;a href="https://www.instagram.com/godcrampy/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="//github.com/godcrampy"&gt;Github&lt;/a&gt; | &lt;a href="//twitter.com/godcrampy"&gt;Twitter&lt;/a&gt; | &lt;a href="//sahil.surge.sh"&gt;Website&lt;/a&gt;&lt;br&gt;
😄 Have a wonderful day!&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
