<?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: Suraj Pandey</title>
    <description>The latest articles on DEV Community by Suraj Pandey (@ulbertao).</description>
    <link>https://dev.to/ulbertao</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%2F963634%2Fb447c8c6-0eff-4a97-b2b1-773b952a28c1.jpg</url>
      <title>DEV Community: Suraj Pandey</title>
      <link>https://dev.to/ulbertao</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ulbertao"/>
    <language>en</language>
    <item>
      <title>Unit Testing in Angular 15 for Developers</title>
      <dc:creator>Suraj Pandey</dc:creator>
      <pubDate>Sat, 22 Apr 2023 05:04:20 +0000</pubDate>
      <link>https://dev.to/ulbertao/unit-testing-in-angular-15-for-developers-22mh</link>
      <guid>https://dev.to/ulbertao/unit-testing-in-angular-15-for-developers-22mh</guid>
      <description>&lt;p&gt;Unit testing is something that is important for our application. Why??&lt;/p&gt;

&lt;p&gt;Because it increases the quality of our application, test and determines if it works as intended, and helps us detect bugs early in the development cycle, today we are about to cover Unit testing in general as well as in angular from basics.&lt;/p&gt;

&lt;p&gt;Let’s dive in,&lt;/p&gt;

&lt;p&gt;Here are a few types of automated testing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit Testing&lt;/li&gt;
&lt;li&gt;E2E Testing&lt;/li&gt;
&lt;li&gt;Integration Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--swO3vG05--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flojgcwh1vcjhirm1vdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--swO3vG05--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flojgcwh1vcjhirm1vdj.png" alt="Types of automated testing" width="494" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit testing&lt;/strong&gt; is focused on testing individual units or a component of an application in isolation from the rest of the application. The purpose of unit testing is to verify that each unit of code is working correctly and as expected. It involves writing and running automated test cases that check the functionality of a small piece of code, such as a function or a class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E2E testing&lt;/strong&gt; also known as end-to-end testing involves testing the entire application by automating the web browser to test a live running application with front end application, web server, and database. With E2E testing, the entire application can be validated&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration testing&lt;/strong&gt; is defined as testing more than one unit but less than a complete application. It involves checking whether one part of the application works with another part. It typically involves testing how individual units of code work together in various combinations to ensure that they integrate and function as expected.&lt;/p&gt;

&lt;p&gt;There is also, &lt;strong&gt;Functional testing&lt;/strong&gt; involves checking whether the application meets the specified requirements. It typically involves testing the application’s inputs and outputs to ensure that they meet the desired specifications and that the application behaves as expected.&lt;/p&gt;

&lt;p&gt;Different types of Unit Testing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Isolated UT&lt;/li&gt;
&lt;li&gt;Shallow UT&lt;/li&gt;
&lt;li&gt;Deep Integration Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Isolated unit tests&lt;/strong&gt;: Involves basic tests that isolate the testing of a single unit of code such as a class or function free of dependencies. It uses mock objects to simulate the behaviour of other components that the unit interacts with, to ensure that the unit functions correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shallow unit tests&lt;/strong&gt;: Involves testing one or more components or services that depend on each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deep integration tests&lt;/strong&gt;: It can be a bit complex, it tests one or more components or services that depend on each other and includes nested components.Used to test multiple components that have child components. It verifies that the unit integrates correctly with all of its dependencies and works as expected.&lt;/p&gt;

&lt;p&gt;During unit testing, components often have dependencies that may be bulky like API calls, database interaction etc. We don’t want to use it in unit testing components. To address this, mocking can be used. Mocking is a powerful technique for isolating units of code and testing them in isolation from their dependencies. By using mocks, developers can write unit tests that are fast and reliable, and that focus on the behaviour of the code being tested rather than the behaviour of external dependencies.&lt;/p&gt;

&lt;p&gt;There are different types of mock objects:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dummies&lt;/strong&gt;: These are dummy classes or objects that replace actual objects in the unit test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stubs&lt;/strong&gt;: These are classes that take control and simulate the behaviour of dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spies&lt;/strong&gt;: These are objects that record information about how a dependency is used during the test. They can be used to verify that certain methods are called the expected number of times or with the expected parameters.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Till now we discussed unit testing in general, now let’s talk about unit testing in Angular.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jOHkMfCR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itswst1872etve2lwuxx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jOHkMfCR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itswst1872etve2lwuxx.png" alt="Angular jasmine karma" width="696" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we create an Angular project using the Angular CLI, it automatically installs all the necessary utilities for testing. This includes the Karma test runner and the Jasmine testing framework, as well as other dependencies.&lt;/p&gt;

&lt;p&gt;Jasmine is a popular JavaScript testing library that provides a clean syntax for writing tests, as well as powerful features such as spies and matchers, which allow you to track function calls and arguments. Jasmine is often used for testing Angular applications because of its ease of use and powerful features.&lt;/p&gt;

&lt;p&gt;Matchers are a key feature of the Jasmine testing framework that allows you to test whether a value or object meets certain expectations. Jasmine provides a rich set of matchers that you can use to test various aspects of your code. To use a matcher, call the expect function with the value that you want to test, and then chain it with the matcher that you want to use.&lt;/p&gt;

&lt;p&gt;Some examples of matchers that Jasmine provides include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBe(y):&lt;/strong&gt; checks whether x is equal to y using the === operator.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toEqual(y):&lt;/strong&gt; checks whether x is deeply equal to y, which means that all of their properties and values are the same.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeDefined():&lt;/strong&gt; checks whether x is defined, which means that it is not undefined.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeNull():&lt;/strong&gt; checks whether x is null.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeTruthy():&lt;/strong&gt; checks whether x is truthy, which means that it is not false, 0, null, undefined, or an empty string or array.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeFalsy():&lt;/strong&gt; checks whether x is falsy, which means that it is false, 0, null, undefined, or an empty string or array.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toContain(y):&lt;/strong&gt; checks whether x contains y, which can be a string, array, or object property.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeGreaterThan(y):&lt;/strong&gt; checks whether x is greater than y.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;expect(x).toBeLessThan(y):&lt;/strong&gt; checks whether x is less than y.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expect(2+3).toEqual(5);

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

&lt;/div&gt;



&lt;p&gt;If these built-in matchers don’t fit your requirement, Jasmine also allows you to define custom matchers, for a specific condition that is not covered by the built-in matchers using "jasmine.addMatchers()"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define a custom matcher using jasmine.addMatchers()
beforeEach(function() {
  jasmine.addMatchers({
    toBeDivisibleByTwo: function() {
      return {
        compare: function(actual, expected) {
          var result = {};
          result.pass = actual % 2 === 0;
          if (result.pass) {
            result.message = actual + ' is divisible by 2';
          } else {
            result.message = actual + ' is not divisible by 2';
          }
          return result;
        }
      };
    }
  });
});

// Use the custom matcher in a test case
it('should test whether a number is divisible by 2', function() {
  expect(10).toBeDivisibleByTwo();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"&lt;strong&gt;describe&lt;/strong&gt;" and "&lt;strong&gt;it&lt;/strong&gt;" functions are used to define test suites and test cases.&lt;/p&gt;

&lt;p&gt;describe function is used to group related test cases together. It takes two arguments: a string that describes the group of tests, and a callback function that contains the actual tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Test Suite', function() {
  // tests go here
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it function is used to define a single test case. It takes two arguments: a string that describes what the test is checking, and a callback function that contains the actual test code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it('should return true when given an even number', function() {
  expect(isEven(2)).toBe(true);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;disable or focus a test by using the 'x' or 'f' prefix, respectively, before the describe or it function. A disabled test will be skipped when the tests are run, while a focused test will be the only test that is run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xdescribe('my disabled tests', function() {
  // tests that will be skipped go here
});

fdescribe('my focused tests', function() {
  // only these tests will be run
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jasmine provides hooks (beforeAll, beforeEach, afterAll, afterEach) for setting up and tearing down test fixtures. What it means is preparing the environment for running tests and cleaning up after the tests have been completed.&lt;/p&gt;

&lt;p&gt;**beforeAll **function is called once before all of the tests in a test suite are run.&lt;br&gt;
**beforeEach **function is called before each test case.&lt;br&gt;
**afterAll **function is called once after all of the tests in a suite have been run&lt;br&gt;
**afterEach **function is called after each test case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Test Suite 1', function() {
  let value;

  beforeEach(function() {
    value = 42;
  });

  it('should return the correct value', function() {
    expect(myFunction(value)).toEqual(84);
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here before each test case value will be set to 42&lt;/p&gt;

&lt;p&gt;Karma, on the other hand, is a test runner that can be used to execute tests written with Jasmine. It provides an easy way to run tests in multiple browsers and provides real-time feedback on test results, which makes the testing process more efficient.&lt;/p&gt;

&lt;p&gt;Results of tests are shown in the terminal window in real-time, as well as in the browser window that Karma opens to run your tests.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/UlbertAO/AngularUnitTesting"&gt;AngularUnitTesting&lt;/a&gt;: a simple angular project to demonstrate angular unit testing from basics.&lt;/p&gt;

&lt;p&gt;We have covered the fundamentals here, Next time will dive deep into writing test cases from scratch and exploring concepts like spies, TestBed, ComponentFixture and a lot more.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>unittest</category>
      <category>webdev</category>
    </item>
    <item>
      <title>OSI Model</title>
      <dc:creator>Suraj Pandey</dc:creator>
      <pubDate>Sat, 08 Apr 2023 10:49:36 +0000</pubDate>
      <link>https://dev.to/ulbertao/osi-model-56eb</link>
      <guid>https://dev.to/ulbertao/osi-model-56eb</guid>
      <description>&lt;h2&gt;
  
  
  In and Out of networking.
&lt;/h2&gt;

&lt;p&gt;Whether you know it all or not Networking is complex. Complex architectures are hard to understand right? To make it simpler for everyone, to understand networking, the OSI model was introduced it’s just a conceptual model that was adopted by networking devices and software vendors so that communication is possible seamlessly.&lt;/p&gt;

&lt;p&gt;OSI model is the reason devices from different vendors that you have, don’t have a hard time communicating with each other because everyone, participating in this are on one page. Also if the entire communication of such a complex architecture is understood then for any specific problem, troubleshooting becomes easy and if some new requirement came in then it can also be implemented easily.&lt;/p&gt;

&lt;p&gt;There exist ‘N’ number of use case of why OSI model? What is the need?&lt;/p&gt;

&lt;p&gt;Let’s discuss more on what is OSI (Open System Interconnection) model.&lt;/p&gt;

&lt;p&gt;Data is sent out as well as received by your system and the ­­­same model is used to visualize its flow of it. For the sake of simplicity, the OSI model is divided into 7 layers and each layer has a defined goal. Each layer works independently without worrying about other layers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8bDTbx9L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yiov2spnupu0e9qace1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8bDTbx9L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yiov2spnupu0e9qace1t.png" alt="7 Layers of OSI model" width="322" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application:&lt;/strong&gt;&lt;br&gt;
This layer is closest to the end user, here data is created/consumed using some kind of tool which can be a browser, software, mail client and many more.&lt;br&gt;
eg: HTTP, FTP, SMTP, POP3 …&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rl_Amg4r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdlaa5gvnpruvb01rxpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rl_Amg4r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdlaa5gvnpruvb01rxpa.png" alt="Data in Application Layer" width="406" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Presentation:&lt;/strong&gt;&lt;br&gt;
This layer ensures that data is in understandable format to a machine when data is sent out and to end users when data is received, encoding/decoding, and compression of data are also part of this.&lt;br&gt;
eg: SSL, SSH, JPEG, MPEG…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5kyxEPr3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8mij0riuqykoqad07bp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5kyxEPr3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8mij0riuqykoqad07bp.png" alt="Data in Presentation Layer" width="420" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session:&lt;/strong&gt;&lt;br&gt;
This layer ensures and manages a communication channel is kept open/close and functional while data transfer is in progress. This communication channel “sessions” are used between devices for long period communication without interruption.&lt;br&gt;
eg: API’s, Sockets, WinSock…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gvdydXW3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ixli4omvq888m9lzf17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gvdydXW3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ixli4omvq888m9lzf17.png" alt="Data in Session Layer" width="438" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transport:&lt;/strong&gt;&lt;br&gt;
This layer is responsible for the transmission of data, data received from the session layer is broken into smaller chunks and more data is added “Headers” for identification purposes called “segments” and also assembles all the segments turning back into data when received from the network layer. At a time on a system multiple applications/tools may use the internet and this layer identifies data received is for which application using ports. It controls many things like at which rate to send data so that receiving device matches the connection speed, validating received data, requesting again if not received, delivery quality and all.&lt;br&gt;
eg: TCP, UDP…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hKe4YBiL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c9oe7421cwkhsajzn8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hKe4YBiL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c9oe7421cwkhsajzn8r.png" alt="Segment in Transport Layer" width="598" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network:&lt;/strong&gt;&lt;br&gt;
This layer is responsible for deciding the path for data transmission and facilitates communication between networks. Segments received from the transport layer is broken into smaller chunks and more data is added for identification purpose called “packets” and also assembles all the packets and turn them back into segments when received from the data Link layer. The best path is discovered by this layer in the physical network for the transmission/routing of packets.&lt;br&gt;
eg: IP, IPSec, ICMP…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pL1MSy74--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnks402ovoac5s98qo7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pL1MSy74--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnks402ovoac5s98qo7r.png" alt="Packet in Network Layer" width="660" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Link:&lt;/strong&gt;&lt;br&gt;
This layer is responsible for establishing and terminating connections between connected nodes on the network. Packets received from the network layer is broken into smaller chunks and more data is added for identification purpose called “frames” and also assembles all the frames turning back into packets when received from the physical layer. At this layer, Logical Link Control and Media Access Control works, which identifies network protocols, performs error checking and synchronizes frames, and uses MAC addresses to connect devices and define permissions to transmit and receive data.&lt;br&gt;
eg: ARP, VLAN, Ethernet, Switch&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qC-A76Il--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kv958gk3pdkeu75t0v7j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qC-A76Il--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kv958gk3pdkeu75t0v7j.png" alt="Frame in Data Link Layer" width="678" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Physical:&lt;/strong&gt;&lt;br&gt;
This layer is responsible for physical or wireless connections between nodes. Raw data is transmitted in the form of series of 0s and 1s, also takes care of bit rate control.&lt;br&gt;
eg: Cables, Hubs, Fiber&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---lbO7wGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x02ebh9dlv1biluya5uv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---lbO7wGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x02ebh9dlv1biluya5uv.png" alt="Bits At Physical Layer" width="675" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Data flow is bidirectional, at each layer additional information is added such as IP, TCP, Ethernet headers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WZBcSKzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s2ot23uzkr7x93prxa7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WZBcSKzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s2ot23uzkr7x93prxa7.png" alt="How Data flows in OSI model" width="708" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lot of times OSI model and TCP/IP model is used interchangeably but it is wrong because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The TCP/IP model is the functional model and OSI model is the conceptual model. What I mean is OSI model is a generic model which can be used to visualize any form of networking whereas TCP/IP model is designed to work with specific network communication and protocols.&lt;/li&gt;
&lt;li&gt;Another difference is several layers are collapsed into one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0GPnTKlh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fy7doek2k75j9u3xq2oi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0GPnTKlh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fy7doek2k75j9u3xq2oi.png" alt="OSI model vs TCP/IP model" width="490" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>network</category>
      <category>computerscience</category>
      <category>webdev</category>
      <category>osi</category>
    </item>
    <item>
      <title>A to Z of git and GitHub</title>
      <dc:creator>Suraj Pandey</dc:creator>
      <pubDate>Wed, 02 Nov 2022 23:59:30 +0000</pubDate>
      <link>https://dev.to/ulbertao/a-to-z-of-git-and-github-4l1c</link>
      <guid>https://dev.to/ulbertao/a-to-z-of-git-and-github-4l1c</guid>
      <description>&lt;p&gt;Before diving into what is git and GitHub lets understand what is “version control system”.&lt;/p&gt;

&lt;h2&gt;
  
  
  Version Control System
&lt;/h2&gt;

&lt;p&gt;It is a fancy term used to represent management of the changes in project development lifecycle. Also known as source control or revision control.&lt;br&gt;
This practice allows developers to track entire history of changes and who made them, if at any point of time incompatible changes are pushed into main codebase then it can be easily rolled back.&lt;/p&gt;

&lt;p&gt;Collaboration is made possible because of version control systems, it can be centralized where tracked files are stored in a single server or distributed where tracked files can be cloned into multiple locations and also can be accessed from multiple locations.&lt;/p&gt;

&lt;p&gt;Well known VCS tools are :&lt;br&gt;
Git, Subversion and Mercurial&lt;/p&gt;

&lt;h2&gt;
  
  
  git
&lt;/h2&gt;

&lt;p&gt;Among all git is the most popular option among developers. Also it is an open source distributed VCS.&lt;br&gt;
Take a look at git source code &lt;a href="https://github.com/git/git"&gt;here&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://git-scm.com/"&gt;git&lt;/a&gt; provide GUI and command line tool.&lt;/p&gt;

&lt;p&gt;I recommend using command line as it offers to use git more freely with all set of commands.&lt;/p&gt;

&lt;p&gt;There are 4 stages we encounter when using git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Untracked : files which are not being tracked.&lt;/li&gt;
&lt;li&gt;Unmodified : files which are not modified but git is tracking them.&lt;/li&gt;
&lt;li&gt;Modified : files contains changes and git is tracking them.&lt;/li&gt;
&lt;li&gt;Staged : files are ready to commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In development process we create a new file to write code which are in untracked stage, after done with writing code we may want to commit this change so that later if something wrong happens we can revert back. File is moved to staged area and committed.&lt;br&gt;
Now this file is in unmodified stage and if developer want to make any changes it will be under modified stage indicating there are some changes which developer may want to commit.&lt;br&gt;
Each commit is recorded in history of the project(repository).&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub
&lt;/h2&gt;

&lt;p&gt;Repositories are like folders which contains files and different versions of a project.&lt;/p&gt;

&lt;p&gt;GitHub is a platform where we can host these repositories and others can collaborate.&lt;br&gt;
Similar platform which provide same kind of services are: Gitbucket, Bitbucket, GitLab and many more&lt;/p&gt;

&lt;p&gt;Others have read only access to public repositories on specific account in GitHub until or unless proper access is not provided to others.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Command ;&lt;/p&gt;

&lt;p&gt;— What that command does&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once git is installed you will need to configure author information locally or globally, Author details are necessary before committing so,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git config — global user.name “[name]” ;&lt;/p&gt;

&lt;p&gt;— Sets the name of author to your commit transactions&lt;/p&gt;

&lt;p&gt;git config — global user.email “[email address]” ;&lt;/p&gt;

&lt;p&gt;— Sets the email of author to your commit transactions&lt;/p&gt;

&lt;p&gt;git config –global -l ;&lt;/p&gt;

&lt;p&gt;— there are many other configurations, which can be listed&lt;/p&gt;

&lt;p&gt;When we proceed with our project we have to initialize it as git repository first.&lt;/p&gt;

&lt;p&gt;git init [projectName] ;&lt;/p&gt;

&lt;p&gt;— initialize git repository&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the development process many files may be added or already tracked files may be edited, those files can be added to stage area. * means add all files to stage area&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git add [fileName] or git add * ;&lt;/p&gt;

&lt;p&gt;— add files to stage area&lt;/p&gt;

&lt;p&gt;git restore — -staged [filename];&lt;/p&gt;

&lt;p&gt;— remove specified file from stage area&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes we may want to exclude files from tracking ,like files which are only required in development environment and others. Path of those files can be added in “.gitignore” file and it will be ignored by git.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git commit -m “commit message” ;&lt;/p&gt;

&lt;p&gt;— commit staged changes to project version history&lt;/p&gt;

&lt;p&gt;git reset [commitHash] ;&lt;/p&gt;

&lt;p&gt;— remove commits done after specified commit preserving changes locally&lt;/p&gt;

&lt;p&gt;git status ;&lt;/p&gt;

&lt;p&gt;— at any point of time status of files can be checked&lt;/p&gt;

&lt;p&gt;git log ;&lt;/p&gt;

&lt;p&gt;— at any point of time logs of repository can be checked&lt;/p&gt;

&lt;p&gt;git clone [url] ;&lt;/p&gt;

&lt;p&gt;— clone a git repository to your local system&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Branches are one of the superpower of git which helps to create parallel version of main repository and work in that without affecting main branch.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git branch [branchName] ;&lt;/p&gt;

&lt;p&gt;— creates a new branch, -d can be used to delete a branch&lt;/p&gt;

&lt;p&gt;git checkout [branchName] ;&lt;/p&gt;

&lt;p&gt;— switch to specified branch, -b can be used to create and switch to it at the same time.&lt;/p&gt;

&lt;p&gt;git merge [branchName] ;&lt;/p&gt;

&lt;p&gt;— merge specified branch changes into current branch&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Stash area is a place where changes can be stored temporarily without committing changes into repository. It can be used in a place where we want to try out many alternative solutions without committing any changes. Stash area is like a STACK, every stashed item is placed on top.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git stash -m “stash message” ;&lt;/p&gt;

&lt;p&gt;— move changes to stash area and have clean codebase, -a can be used to stash untracked items[all] also&lt;/p&gt;

&lt;p&gt;git stash pop ;&lt;/p&gt;

&lt;p&gt;— bring back changes from stash area, — index n can be used to bring back specific stash item&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Repositories in local and repositories hosted in GitHub can be synchronized , in this operation every repository is associated with unique URL, “remote ” command is used to work with URLs in git. After creating a repository in GitHub and project development is done locally, Now it is the time to push/sync local repository to remote repository in GitHub.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git remote add origin [RepositoryURL] ;&lt;/p&gt;

&lt;p&gt;— map URL to origin[naming convention] and when dealing with local and remote repositories this origin name can be used in place of entire url.&lt;/p&gt;

&lt;p&gt;git fetch ;&lt;/p&gt;

&lt;p&gt;— gets history updates from remote repository&lt;/p&gt;

&lt;p&gt;git pull ;&lt;/p&gt;

&lt;p&gt;— updates working directory with commits in remote repository, it is combination of fetch and merge&lt;/p&gt;

&lt;p&gt;git push ;&lt;/p&gt;

&lt;p&gt;— updates remote repository with all the commits in local repository&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In both, push and pull commands which branch to push and where to push can be specified&lt;br&gt;
git push [whereToPush] [whichBranchToPush]&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git push origin main&lt;/p&gt;

&lt;p&gt;git pull origin main&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Forking a repository means copying a repository from someone else’s account to your GitHub account, cause while making contribution we cannot directly push our commits to their repository that will raise security concerns.&lt;/p&gt;

&lt;p&gt;Once repository in our GitHub account we can make changes as we like and when we want to merge it to original codebase of this forked repository we can raise a Pull Request and maintainers of that repository may review and merge it into their code base.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do check out &lt;a href="https://education.github.com/pack"&gt;GitHub student developer pack&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
