<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by sunny Gupta on Medium]]></title>
        <description><![CDATA[Stories by sunny Gupta on Medium]]></description>
        <link>https://medium.com/@sunnyngupta?source=rss-2154da7da244------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FmXU795UsYKRdh9B</url>
            <title>Stories by sunny Gupta on Medium</title>
            <link>https://medium.com/@sunnyngupta?source=rss-2154da7da244------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:17:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sunnyngupta/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python Oops For Interview Preparation]]></title>
            <link>https://medium.com/@sunnyngupta/python-oops-for-interview-preparation-0e9e2a8f4ed5?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e9e2a8f4ed5</guid>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Fri, 30 Aug 2024 21:07:13 GMT</pubDate>
            <atom:updated>2024-08-30T21:07:13.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*V30DzBN5uttjNwND.jpg" /></figure><h3>What Is Object-Oriented Programming in Python?</h3><p>Object-oriented programming is a programming paradigm that provides a means of structuring programs so that properties and behaviors are bundled into individual <strong>objects</strong>.</p><p>For example, an object could represent a person with <strong>properties</strong> like a name, age, and address and <strong>behaviors</strong> such as walking, talking, breathing, and running.</p><h3>What Is Object ?</h3><p>It is a basic unit of Object-Oriented Programming and represents the real-life entities.</p><p>An Object is an instance of a Class. which has State and Behaviour</p><p>Example :</p><p>person is a abject</p><p>state-&gt; name , age , address</p><p>Behaviour -&gt; walking , talking , reading</p><h3>What Is Class ?</h3><p>A <strong>class</strong> is a blueprint or template for creating objects. It defines the structure and behavior that the objects created from the class will have. A class encapsulates data for the object and the methods (functions) that manipulate that data.</p><h3>Components Of Class :</h3><p><strong>1 .Attributes (Fields or Properties)</strong>:</p><ul><li>These are variables that belong to the class. They represent the state or characteristics of an object.</li><li><strong>Example</strong>: In a Car class, attributes might include color, model, and year.</li></ul><p><strong>2 . Methods</strong>:</p><ul><li>These are functions defined within a class that describe the behaviors of the object. Methods can operate on the data stored in the attributes.</li><li><strong>Example</strong>: In a Car class, methods might include startEngine(), stopEngine(), and accelerate().</li></ul><p><strong>3 .Constructor (</strong><strong>__init__ method in Python)</strong>:</p><ul><li>This is a special method used to initialize the object’s state when it is created. The constructor method is typically used to set the initial values for the attributes of the object.</li><li>When you create a new class instance, then Python automatically passes the instance to the self parameter in .__init__() so that Python can define the new <strong>attributes</strong> on the object.</li><li><strong>Example</strong>: The __init__ method in the Car class can be used to set the initial values for color, model, and year.</li></ul><h3>How to Define Class in python :</h3><p>You start all class definitions with the class keyword :</p><pre>class Dog:<br>    pass</pre><p>The body of the Dog class consists of a single statement: the <a href="https://realpython.com/python-pass/">pass</a> keyword. Python programmers often use pass as a placeholder indicating where code will eventually go. It allows you to run this code without Python throwing an error.</p><p>Update the Dog class with an .__init__() method that creates .name and .age attributes:</p><pre># dog.py<br><br>class Dog:<br>    def __init__(self, name, age):<br>        self.name = name<br>        self.age = age</pre><ol><li><strong>self.name = name</strong> creates an attribute called name and assigns the value of the name parameter to it.</li><li><strong>self.age = age</strong> creates an attribute called age and assigns the value of the age parameter to it.</li></ol><h3>What is self ?</h3><p>self is a reference to the instance of the class. It is used within a class to access attributes and methods of the current object.</p><pre>class Car:<br>    def __init__(self, color, model, year):<br>        self.color = color    # self.color refers to the instance variable<br>        self.model = model    # self.model refers to the instance variable<br>        self.year = year      # self.year refers to the instance variable<br><br>    def startEngine(self):<br>        print(f&quot;The {self.model} engine has started.&quot;)<br>        <br>    def stopEngine(self):<br>        print(f&quot;The {self.model} engine has stopped.&quot;)<br><br># Creating an object of the Car class<br>my_car = Car(&quot;Red&quot;, &quot;Toyota Camry&quot;, 2021)<br><br># Accessing attributes<br>print(my_car.color)  # Output: Red<br><br># Calling methods<br>my_car.startEngine()  # Output: The Toyota Camry engine has started.<br>my_car.stopEngine()   # Output: The Toyota Camry engine has stopped.</pre><ul><li><strong>__init__ Method</strong>: This is the constructor method, and self is used to initialize the attributes (self.color, self.model, self.year) of the instance being created.</li><li><strong>Instance Attributes</strong>: When you set self.color = color, you&#39;re telling Python that this particular instance of Car should have an attribute color with the value passed during instantiation.</li><li><strong>Methods</strong>: In the startEngine and stopEngine methods, self is used to refer to the model of the current instance so that the method knows which car&#39;s engine to start or stop.</li></ul><p><strong>self is a reference to the current instance of the class.</strong></p><h3>what is Inheritance ??</h3><p>Inheritance is the process by which one class takes on the attributes and methods of another. Newly formed classes are called <strong>child classes</strong>, and the classes that you derive child classes from are called <strong>parent classes</strong>.</p><p>You inherit from a parent class by creating a new class and putting the name of the parent class into parentheses:</p><pre># inheritance.py<br><br>class Parent:<br>    hair_color = &quot;brown&quot;<br><br>class Child(Parent):<br>    pass</pre><p>Types of Inheritance in Python:</p><p><strong>1 .Single Inheritance</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*Y1m6CWtldJ8_Eh8p.png" /></figure><ul><li>A child class inherits from one parent class.</li></ul><pre>class Vehicle:<br>    def start(self):<br>        print(&quot;Vehicle started&quot;)<br><br>class Car(Vehicle):  # Car inherits from Vehicle<br>    def openTrunk(self):<br>        print(&quot;Trunk opened&quot;)<br><br>my_car = Car()<br>my_car.start()  # Inherited method from Vehicle<br>my_car.openTrunk()  # Method defined in Car</pre><p><strong>2 .Multiple Inheritance</strong>:</p><ul><li>A child class inherits from more than one parent class.</li></ul><pre>class Engine:<br>    def startEngine(self):<br>        print(&quot;Engine started&quot;)<br><br>class Wheels:<br>    def startWheels(self):<br>        print(&quot;Wheels rolling&quot;)<br><br>class Car(Engine, Wheels):  # Car inherits from both Engine and Wheels<br>    pass<br><br>my_car = Car()<br>my_car.startEngine()  # Inherited from Engine<br>my_car.startWheels()  # Inherited from Wheels</pre><p>3 . <strong>Multilevel Inheritance</strong>:</p><ul><li>A child class inherits from a parent class, which in turn inherits from another class.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/0*S3eL_x4PdAXtjM8C.png" /></figure><pre>class Vehicle:<br>    def start(self):<br>        print(&quot;Vehicle started&quot;)<br><br>class Car(Vehicle):  # Car inherits from Vehicle<br>    def openTrunk(self):<br>        print(&quot;Trunk opened&quot;)<br><br>class SportsCar(Car):  # SportsCar inherits from Car<br>    def turbo(self):<br>        print(&quot;Turbo mode activated&quot;)<br><br>my_sportscar = SportsCar()<br>my_sportscar.start()  # Inherited from Vehicle<br>my_sportscar.openTrunk()  # Inherited from Car<br>my_sportscar.turbo()  # Method defined in SportsCar</pre><h3>What is Method Overloading And Overriding ??</h3><ol><li><strong>Method Overloading</strong>:</li></ol><p><strong>Definition</strong>: Method overloading refers to the ability to define multiple methods in the same class with the same name but with different parameters (different number, type, or order of parameters). It allows a class to perform different tasks based on the parameters passed.</p><h4>Important Points :</h4><p>(Python does not support method overloading in the traditional sense, like languages such as Java or C++. In Python, if you define multiple methods with the same name, the last defined method will override the previous ones. However, you can achieve a similar effect using default arguments or variable-length arguments (*args and **kwargs).)</p><p>2. <strong>Method Overriding</strong>:</p><p>Overriding is when a child class has its method implementation for the method already present in the parent class.</p><p>When a method in a subclass has the same name and signature as in its super-class, the subclass is originated from the super-class.</p><pre>class Animal:<br>    def speak(self):<br>        print(&quot;The animal makes a sound&quot;)<br><br>class Dog(Animal):  # Dog is inheriting from Animal<br>    def speak(self):  # Overriding the speak method<br>        print(&quot;The dog barks&quot;)<br><br>class Cat(Animal):  # Cat is inheriting from Animal<br>    def speak(self):  # Overriding the speak method<br>        print(&quot;The cat meows&quot;)<br><br>dog = Dog()<br>dog.speak()  # Output: The dog barks<br><br>cat = Cat()<br>cat.speak()  # Output: The cat meows</pre><h3>What is Polymorphism ?</h3><p>Polymorphism is a fundamental concept in Object-Oriented Programming (OOP) that allows objects of different classes to be treated as objects of a common superclass. It also allows the same method to behave differently based on the object it is acting upon. The word “polymorphism” comes from the Greek words “poly,” meaning many, and “morph,” meaning form — so it means “many forms.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*UCmkmRLvghfuxGTd.jpeg" /></figure><h3><strong>Types of Polymorphism:</strong></h3><p><strong>1 .Compile-Time Polymorphism (Static Polymorphism)</strong>:</p><ul><li><strong>Definition</strong>: This type of polymorphism is determined at compile time. It is typically achieved through method overloading or operator overloading.</li></ul><pre>class Vector:<br>    def __init__(self, x, y):<br>        self.x = x<br>        self.y = y<br><br>    def __add__(self, other):<br>        return Vector(self.x + other.x, self.y + other.y)<br><br>v1 = Vector(2, 3)<br>v2 = Vector(4, 5)<br>v3 = v1 + v2  # Overloaded &#39;+&#39; operator<br>print(v3.x, v3.y)  # Output: 6 8</pre><p><strong>Note</strong>: Python does not support traditional method overloading as seen in other languages, but it does support operator overloading, which is a form of polymorphism.</p><p><strong>2 .Run-Time Polymorphism (Dynamic Polymorphism)</strong>:</p><ul><li><strong>Definition</strong>: This type of polymorphism is determined at runtime. It is typically achieved through method overriding, where a child class overrides a method in its parent class.</li><li><strong>Example</strong>: The same method name behaves differently based on the object’s class .</li></ul><pre>class Animal:<br>    def speak(self):<br>        print(&quot;The animal makes a sound&quot;)<br><br>class Dog(Animal):<br>    def speak(self):<br>        print(&quot;The dog barks&quot;)<br><br>class Cat(Animal):<br>    def speak(self):<br>        print(&quot;The cat meows&quot;)<br><br>def make_animal_speak(animal):<br>    animal.speak()  # Calls the overridden method<br><br>dog = Dog()<br>cat = Cat()<br><br>make_animal_speak(dog)  # Output: The dog barks<br>make_animal_speak(cat)  # Output: The cat meows</pre><p><strong>Explanation</strong>: Here, the speak method is overridden in both Dog and Cat classes. When you call make_animal_speak with different objects, the method behaves according to the class of the object passed.</p><h3>Real-World Analogy:</h3><p>Consider a situation where you have a “remote control” that can operate different devices like a TV, a fan, and a light. Despite being a single remote, when you press the “on” button, it can turn on the TV, the fan, or the light, depending on the context. This is analogous to polymorphism, where the same action (pressing the “on” button) can result in different behaviors depending on the object (device) it’s acting upon.</p><h3>Benefits of Polymorphism:</h3><ul><li><strong>Flexibility</strong>: Code can handle objects of different types with a unified interface.</li><li><strong>Extensibility</strong>: New classes can be added with minimal changes to existing code.</li><li><strong>Simplification</strong>: Complex conditional statements can be avoided, leading to cleaner and more maintainable code.</li></ul><h3>What is Abstraction ?</h3><p><strong>Abstraction</strong> is a fundamental concept in Object-Oriented Programming (OOP) that focuses on hiding the implementation details and showing only the essential features of an object or system. The main goal of abstraction is to reduce complexity and allow the programmer to focus on interactions at a higher level rather than worrying about the underlying details.</p><h3>We can Achieved Through Abstract Classes and Interfaces :</h3><p><strong>Abstract Class</strong>: A class that cannot be instantiated on its own and often contains one or more abstract methods (methods without implementation). A subclass is responsible for providing the implementation.</p><p>An abstract method is a method that is declared in an abstract class but doesn’t have a body (i.e., it is not implemented). The abstract method is meant to be overridden in subclasses that inherit from the abstract class.</p><p><strong>Interface</strong>: A contract that defines a set of methods without implementing them. A class that implements an interface must provide the implementation for all the methods defined by the interface.</p><h3>Note :</h3><p>Python supports abstraction using abstract base classes (ABCs) from the abc module. An abstract base class can define abstract methods that must be implemented by any subclass.</p><pre>from abc import ABC, abstractmethod<br><br>class Vehicle(ABC):  # Abstract Base Class<br>    @abstractmethod<br>    def start(self):<br>        pass<br><br>    @abstractmethod<br>    def stop(self):<br>        pass<br><br>class Car(Vehicle):  # Concrete Class<br>    def start(self):<br>        print(&quot;Car engine started&quot;)<br><br>    def stop(self):<br>        print(&quot;Car engine stopped&quot;)<br><br>class Bike(Vehicle):  # Concrete Class<br>    def start(self):<br>        print(&quot;Bike engine started&quot;)<br><br>    def stop(self):<br>        print(&quot;Bike engine stopped&quot;)<br><br># Instantiate objects<br>my_car = Car()<br>my_bike = Bike()<br><br>my_car.start()  # Output: Car engine started<br>my_car.stop()   # Output: Car engine stopped<br><br>my_bike.start()  # Output: Bike engine started<br>my_bike.stop()   # Output: Bike engine stopped</pre><h3>Explanation:</h3><ul><li><strong>Abstract Base Class (</strong><strong>Vehicle)</strong>: The Vehicle class is an abstract class with two abstract methods: start and stop. These methods don&#39;t have implementations in the Vehicle class.</li><li><strong>Concrete Classes (</strong><strong>Car, </strong><strong>Bike)</strong>: The Car and Bike classes inherit from Vehicle and provide implementations for the start and stop methods.</li><li><strong>Instantiation</strong>: You cannot create an instance of the Vehicle class directly, but you can create instances of Car and Bike, which have implemented the required abstract methods.</li></ul><h3>Benefits of Abstraction:</h3><ul><li><strong>Reduces Complexity</strong>: By hiding complex implementation details, abstraction allows developers to work with simplified models of systems.</li><li><strong>Increases Reusability</strong>: Abstract classes and interfaces can be used to define generic templates, making it easier to reuse code across different parts of a program.</li><li><strong>Enhances Maintainability</strong>: Changes to the underlying implementation do not affect the code that interacts with the abstracted components, making the system easier to maintain and extend.</li></ul><h3>What is Encapsulation ??</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*o2G1XtsK5G1Dzd47.jpg" /></figure><p><strong>Encapsulation</strong> is one of the core principles of Object-Oriented Programming (OOP) that involves bundling the data (attributes) and methods (functions) that operate on that data into a single unit, or class. It also restricts direct access to some of an object’s components, which is a means of preventing unintended interference and misuse of the object’s internal state.</p><h3>Key Points :</h3><p><strong>1 .Bundling Data and Methods</strong>:</p><ul><li>Encapsulation ensures that the data (attributes) and the methods that operate on that data are grouped together within a class. This allows objects to manage their own state and behavior.</li></ul><p>2 . <strong>Access Modifiers</strong>:</p><ul><li>Encapsulation is often implemented using access control mechanisms to restrict access to the internal state of an object. In Python, this is typically done using naming conventions:</li><li><strong>Public</strong>: Attributes and methods that are accessible from outside the class. (e.g., self.attribute)</li><li><strong>Protected</strong>: Attributes and methods that are intended to be accessed within the class and its subclasses. Indicated by a single underscore (e.g., _attribute).</li><li><strong>Private</strong>: Attributes and methods that are intended to be accessible only within the class itself. Indicated by a double underscore (e.g., __attribute).</li></ul><p><strong>3 . Getter and Setter Methods</strong>:</p><ul><li>Encapsulation often involves providing methods to access (get) and modify (set) the values of private attributes. This allows control over how the data is accessed or modified.</li><li>(we will cover more detail on Getter And setter method in next post)</li></ul><pre>class BankAccount:<br>    def __init__(self, account_number, balance):<br>        self.__account_number = account_number  # Private attribute<br>        self.__balance = balance                # Private attribute<br><br>    def deposit(self, amount):<br>        if amount &gt; 0:<br>            self.__balance += amount<br>        else:<br>            print(&quot;Deposit amount must be positive&quot;)<br><br>    def withdraw(self, amount):<br>        if 0 &lt; amount &lt;= self.__balance:<br>            self.__balance -= amount<br>        else:<br>            print(&quot;Invalid withdrawal amount&quot;)<br><br>    def get_balance(self):<br>        return self.__balance  # Getter method<br><br>    def get_account_number(self):<br>        return self.__account_number  # Getter method<br><br># Creating an object of BankAccount<br>account = BankAccount(&quot;123456789&quot;, 1000)<br><br># Accessing methods<br>account.deposit(500)<br>print(account.get_balance())  # Output: 1500<br><br>account.withdraw(200)<br>print(account.get_balance())  # Output: 1300<br><br># Direct access to private attributes is not allowed<br># print(account.__balance)  # Raises AttributeError</pre><h3>Explanation:</h3><ul><li><strong>Private Attributes</strong>: The __account_number and __balance attributes are private, meaning they cannot be accessed directly from outside the class. This helps in protecting the internal state of the object.</li><li><strong>Public Methods</strong>: Methods like deposit, withdraw, get_balance, and get_account_number provide controlled access to the private data. These methods act as interfaces to interact with the object while hiding its internal details.</li></ul><h3>Benefits of Encapsulation:</h3><ul><li><strong>Control</strong>: Encapsulation allows you to control how the data is accessed and modified, which helps maintain the integrity of the object’s state.</li><li><strong>Flexibility</strong>: You can change the internal implementation of a class without affecting the code that uses the class, as long as the public interface remains consistent.</li><li><strong>Maintainability</strong>: Encapsulation helps in organizing code into discrete, manageable units, making it easier to maintain and debug.</li></ul><h3>What is Interface ?</h3><p>The interface is <em>a </em>mechanism to achieve abstraction. Traditionally, an interface could only have abstract methods (methods without a body) and public, static, and final variables by default. It is used to achieve abstraction and multiple inheritances.</p><p>(java does not support multiple interface but with the help of interface we can achieve multiple inheritance in java )</p><p>Python does not have explicit interface constructs like some other languages (e.g., Java), but similar functionality can be achieved using abstract base classes (ABCs) from the abc module. Abstract base classes allow you to define methods that must be implemented by subclasses, serving a similar purpose to interfaces.</p><pre>from abc import ABC, abstractmethod<br><br>class Shape(ABC):  # Abstract Base Class (Interface)<br>    @abstractmethod<br>    def area(self):<br>        pass<br><br>    @abstractmethod<br>    def perimeter(self):<br>        pass<br><br>class Rectangle(Shape):  # Concrete Class<br>    def __init__(self, width, height):<br>        self.width = width<br>        self.height = height<br><br>    def area(self):<br>        return self.width * self.height<br><br>    def perimeter(self):<br>        return 2 * (self.width + self.height)<br><br>class Circle(Shape):  # Concrete Class<br>    def __init__(self, radius):<br>        self.radius = radius<br><br>    def area(self):<br>        return 3.14 * (self.radius ** 2)<br><br>    def perimeter(self):<br>        return 2 * 3.14 * self.radius<br><br># Creating instances of Rectangle and Circle<br>rect = Rectangle(5, 10)<br>circ = Circle(7)<br><br>print(f&quot;Rectangle area: {rect.area()}&quot;)       # Output: Rectangle area: 50<br>print(f&quot;Rectangle perimeter: {rect.perimeter()}&quot;)  # Output: Rectangle perimeter: 30<br><br>print(f&quot;Circle area: {circ.area()}&quot;)           # Output: Circle area: 153.86<br>print(f&quot;Circle perimeter: {circ.perimeter()}&quot;)  # Output: Circle perimeter: 43.96</pre><h3>Explanation:</h3><ul><li><strong>Abstract Base Class (</strong><strong>Shape)</strong>: Defines the area and perimeter methods as abstract, meaning that any concrete subclass must implement these methods.</li><li><strong>Concrete Classes (</strong><strong>Rectangle, </strong><strong>Circle)</strong>: Implement the Shape interface by providing specific implementations for the area and perimeter methods.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e9e2a8f4ed5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ESSENTIAL Network Protocols]]></title>
            <link>https://medium.com/@sunnyngupta/essential-network-protocols-ed4641ebaf75?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed4641ebaf75</guid>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Thu, 11 Jul 2024 17:47:02 GMT</pubDate>
            <atom:updated>2024-07-11T17:47:02.334Z</atom:updated>
            <content:encoded><![CDATA[<h3>1 . HTTP</h3><p>HTTP (Hypertext Transfer Protocol) is one of the foundational protocols of the World Wide Web, used for transmitting hypertext documents.</p><p>HTTP defines how messages are formatted and transmitted, and how web servers and browsers should respond to various commands.</p><p>HTTP request from a client to server is independent; the server does not retain any state information between requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_zM7XRfm18HeSy6e.png" /></figure><h3>HTTP Methods :</h3><p>. <strong>GET:</strong> Requests data from a specified resource.</p><p>. <strong>POST:</strong> Submits data to be processed to a specified resource</p><p>. <strong>PUT:</strong> Updates a current resource with new data.</p><p>. <strong>DELETE:</strong> Deletes a specified resource.</p><p><strong>. HEAD:</strong> Similar to GET, but it transfers the status line and header section only.</p><p>. <strong>PATCH:</strong> Applies partial modifications to a resource.</p><h3>2 . HTTPS</h3><p>HTTPS (Hypertext Transfer Protocol Secure) is an extension of HTTP designed to ensure secure communication over a computer network, primarily the Internet. It does this by using Transport Layer Security (TLS) or its predecessor, Secure Sockets Layer (SSL), to encrypt the data being exchanged between the client and the server.</p><p><strong>Key Features of HTTPS :</strong></p><h3>1 . Encryption:</h3><ul><li><strong>Purpose:</strong> Encrypts the data exchanged between the client and server to protect it from eavesdroppers.</li><li><strong>Benefit:</strong> Ensures that even if data is intercepted, it cannot be read without the decryption key.</li></ul><h3>2 . Data Integrity:</h3><ul><li><strong>Purpose:</strong> Ensures that the data sent and received has not been tampered with during transmission.</li><li><strong>Benefit:</strong> Protects against data corruption and malicious alterations.</li></ul><h3>2 . Authentication:</h3><ul><li><strong>Purpose:</strong> Verifies that the website the client is communicating with is actually the intended website.</li><li><strong>Benefit:</strong> Prevents man-in-the-middle attacks by ensuring that the server the client is connecting to is the legitimate one.</li></ul><h3>3 . FTP :</h3><p>FTP (File Transfer Protocol) is a standard network protocol used for transferring files between a client and a server on a computer network. It is one of the oldest protocols used on the Internet and allows for the upload, download, and management of files on a remote server.</p><p>The client and the server communicate using two types of connections. These are –</p><ol><li>Control connection</li><li>Data connection</li></ol><h4>Control Connection</h4><p>The client and server communicate to send and receive commands through the control connection. FTP uses a control connection to transmit information such as user name, password, remote directory change commands, file retrieval, storage instructions, etc. It is initiated via port 21.</p><h4>Data Connection</h4><p>The data connection allows the transfer of file data between the client and server. It is initiated via port 20. FTP works via two different modes. These are:</p><ol><li><strong>Active Mode: </strong>When a client starts a session through a command channel, the server initiates a data connection and begins exchanging information with the client.</li><li><strong>Passive Mode: </strong>The server sends the client the necessary information to initiate a data channel through the command channel. To avoid being blocked by firewalls and <a href="https://www.pynetlabs.com/network-address-translation/">NAT</a> routers, the client always uses passive mode while making connections.</li></ol><h3>Types of FTP Protocol</h3><p>1 . Secure FTP (SFTP) :</p><p>SFTP stands for The SSH File Transfer Protocol. SFTP is a layer above SSH that provides all the security and authentication capabilities of SSH. This protocol is rapidly replacing FTP/S and has already overtaken legacy FTP. It provides the full range of features available via these protocols with high reliability and higher levels of security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bXqJhNeQvOxK6tpz.jpeg" /></figure><p>2 . Trivial FTP (TFTP):</p><p>TFTP is a simplified version of FTP that uses <a href="https://www.pynetlabs.com/udp-vs-tcp/#:~:text=TCP%20is%20a%20connection%2Doriented,faster%20and%20simpler%20data%20transmission.">UDP instead of TCP</a> for data transfer. Not all programs can use TCP because of its complexity and the features they don’t require. Regarding client-server interactions, TFTP’s simple structure and low cost make it suitable. TFTP is limited to File Transfer only and does not permit authentications.</p><p>TFTP is mainly used for bootstrapping network devices or transferring small files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*iDW8TxdKBuAr_uU-.jpeg" /></figure><p>3 . File Transfer Protocol Secure (FTPS):</p><p>File Transfer Protocol Secure (FTPS) is the secured variant of FTP, similar to Hypertext Transfer Protocol Secure. Transport Layer Security (TLS) and secure socket layer (SSL) safeguard these protocols. Using FTPS, companies may establish encrypted connections with their clients, partners, and end-users.</p><p>FTPS can encrypt either the control connection only (explicit FTPS) or both the control and data connections (implicit FTPS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*c-GIsib4ftx8Djmp.jpeg" /></figure><h3>4 . TCP:</h3><p>TCP (Transmission Control Protocol) is one of the core protocols of the Internet Protocol Suite, commonly known as TCP/IP. It provides reliable, ordered, and error-checked delivery of data between applications running on hosts communicating via an IP network.</p><p>Key Features of HTTPS :</p><p><strong>1 . Connection-Oriented:</strong></p><ul><li><strong>Three-Way Handshake:</strong> Establishes a connection between the client and server before data is transmitted.</li><li><strong>State Management:</strong> Maintains state information about the connection, including sequence numbers and acknowledgments.</li></ul><p><strong>2 . Reliable Data Transfer:</strong></p><ul><li><strong>Error Detection and Correction:</strong> Uses checksums to detect errors and acknowledgments (ACKs) to confirm successful data receipt.</li><li><strong>Retransmission:</strong> Lost or corrupted packets are retransmitted based on the lack of an acknowledgment.</li></ul><p>3 . <strong>Flow Control:</strong></p><ul><li><strong>Window Size:</strong> Uses a sliding window mechanism to manage the amount of data that can be sent before requiring an acknowledgment, ensuring that the sender does not overwhelm the receiver.</li></ul><p>4 . <strong>Congestion Control:</strong></p><ul><li><strong>Algorithms:</strong> Implements algorithms like slow start, congestion avoidance, fast retransmit, and fast recovery to manage network congestion.</li></ul><h3>4 . IP:</h3><p>The Internet Protocol (IP) is a core protocol of the Internet Protocol Suite (commonly referred to as TCP/IP). It is responsible for addressing, routing, and delivering packets of data from the source host to the destination host across one or more IP networks.</p><p><strong>Key Features of IP :</strong></p><p><strong>1 . Packet-Switched Protocol:</strong></p><ul><li><strong>Datagrams:</strong> IP encapsulates data into packets called datagrams, each with a header containing addressing and control information.</li><li><strong>Independence:</strong> Each datagram is treated independently and can take different paths to the destination.</li></ul><p><strong>2 .Addressing:</strong></p><ul><li><strong>IP Addresses:</strong> Provides unique numerical labels (IP addresses) for each device on a network.</li><li><strong>Hierarchical Structure:</strong> IP addresses have a hierarchical structure to facilitate routing.</li></ul><p><strong>3 .Routing:</strong></p><ul><li><strong>Route Determination:</strong> Uses routing tables and protocols to determine the best path for data to reach its destination.</li><li><strong>Forwarding:</strong> Routers forward packets from one network to another based on the destination IP address.</li></ul><p><strong>4. Fragmentation and Reassembly:</strong></p><ul><li><strong>Fragmentation:</strong> If a packet is too large for the next network segment, it is divided into smaller fragments.</li><li><strong>Reassembly:</strong> The destination host reassembles the fragments into the original packet.</li></ul><h3>5 . SMTP:</h3><p>SMTP (Simple Mail Transfer Protocol) is a protocol used for sending and receiving email. It is a fundamental protocol for email communication on the Internet, responsible for the transfer of messages between email servers and from clients to servers for outgoing mail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*PgPFPe4NX8zS45Jc.png" /></figure><p><strong>SMTP Commands:</strong></p><ul><li><strong>HELO/EHLO:</strong> Identifies the client to the server. EHLO is used for Extended SMTP (ESMTP).</li><li><strong>MAIL FROM:</strong> Specifies the sender’s email address.</li><li><strong>RCPT TO:</strong> Specifies the recipient’s email address.</li><li><strong>DATA:</strong> Indicates that the email content follows. The message body is sent after this command, ending with a single period on a line by itself.</li><li><strong>QUIT:</strong> Terminates the session.</li></ul><p><strong>Common Use Cases :</strong></p><ul><li><strong>Sending Emails:</strong> From clients (e.g., Outlook, Gmail) to email servers.</li><li><strong>Email Relaying:</strong> Between email servers to route messages to the recipient’s server.</li><li><strong>Notification Systems:</strong> Automated systems to send alerts and notifications via email.</li></ul><p><strong>Key Features of SMTP :</strong></p><p><strong>1 .Simple and Text-Based:</strong></p><ul><li><strong>Commands and Responses:</strong> SMTP uses plain text commands and responses, making it straightforward to implement and debug.</li><li><strong>ASCII Format:</strong> Emails are sent in ASCII text format.</li></ul><p><strong>2 . Client-Server Model:</strong></p><ul><li><strong>Client:</strong> The email client or sending server that initiates the email transfer.</li><li><strong>Server:</strong> The receiving server that accepts the email for delivery to the recipient’s inbox.</li></ul><p><strong>3</strong> . <strong>Store and Forward:</strong></p><ul><li><strong>Intermediary Servers:</strong> SMTP servers can relay messages to other servers, ensuring delivery even if the recipient’s server is temporarily unavailable.</li></ul><p><strong>4 </strong>.<strong>Push Protocol:</strong></p><ul><li><strong>Active Transfer:</strong> The sending server pushes the email to the receiving server, rather than the recipient server pulling the email.</li></ul><h3>5 . SSH (Secure Shell):</h3><p>SSH (Secure Shell) is a protocol used for securely accessing and managing network devices and servers over an unsecured network. It provides a secure channel over an unsecured network by using encryption for data transmission, ensuring confidentiality and integrity of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*zwgqkMCQSKurA7Xv.jpg" /></figure><p><strong>Key Features of SSH :</strong></p><p><strong>1 .Secure Authentication:</strong></p><ul><li><strong>Username and Password:</strong> Traditional login method using a username and password.</li><li><strong>Public Key Authentication:</strong> More secure method using cryptographic key pairs (private and public keys).</li><li><strong>Two-Factor Authentication:</strong> Additional security layer using methods like TOTP (Time-based One-Time Password).</li></ul><p><strong>2 .Data Encryption:</strong></p><ul><li><strong>Symmetric Encryption:</strong> Encrypts the session using a symmetric encryption algorithm (e.g., AES, Blowfish).</li><li><strong>Asymmetric Encryption:</strong> Uses key pairs for secure key exchange and session establishment.</li></ul><p><strong>3 .Integrity Protection:</strong></p><ul><li><strong>Message Authentication Codes (MACs):</strong> Ensures data integrity by verifying that the data has not been altered during transmission.</li></ul><p><strong>4. Port Forwarding:</strong></p><ul><li><strong>Local Port Forwarding:</strong> Redirects network traffic from a local port to a remote server through the SSH connection.</li><li><strong>Remote Port Forwarding:</strong> Redirects traffic from a remote port to a local server.</li><li><strong>Dynamic Port Forwarding:</strong> Uses a single SSH connection to handle multiple ports, acting as a SOCKS proxy.</li></ul><p><strong>5 .Secure File Transfer:</strong></p><ul><li><strong>SCP (Secure Copy Protocol):</strong> Transfers files securely between local and remote hosts.</li><li><strong>SFTP (SSH File Transfer Protocol):</strong> Provides secure file transfer and file system access.</li></ul><p><strong>6. Tunneling:</strong></p><ul><li><strong>Encrypted Tunnels:</strong> Creates encrypted tunnels for other network services (e.g., HTTP, VNC).</li></ul><h3>6. IMAP (Internet Message Access Protocol):</h3><p>IMAP (Internet Message Access Protocol) is a standard email protocol that enables users to access and manage their email on a remote mail server. It allows for the retrieval of messages and the management of mailboxes, enabling users to organize, read, and delete emails from various devices.</p><p>IMAP (Internet Message Access Protocol) is a standard email protocol that enables users to access and manage their email on a remote mail server. It allows for the retrieval of messages and the management of mailboxes, enabling users to organize, read, and delete emails from various devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Vl7YF2aQ2-7CHAeK.gif" /><figcaption>🧠</figcaption></figure><p><strong>Key Features of IMAP :</strong></p><p><strong>1 . Remote Mail Storage:</strong></p><ul><li><strong>Server-Side Management:</strong> Emails remain on the mail server, allowing access from multiple devices.</li><li><strong>Synchronization:</strong> Changes made on one device (such as reading, deleting, or organizing emails) are synchronized across all devices.</li></ul><p><strong>2 .Mailbox Management:</strong></p><ul><li><strong>Folders and Labels:</strong> Users can create and manage folders or labels to organize emails.</li><li><strong>Search and Filter:</strong> Provides capabilities to search and filter emails on the server.</li></ul><p><strong>3. Partial Retrieval:</strong></p><ul><li><strong>Headers Only:</strong> Users can choose to download only the headers of emails to save bandwidth.</li><li><strong>Selective Download:</strong> Allows downloading of specific parts of an email (e.g., attachments or body) as needed.</li></ul><p><strong>4 . Status Flags:</strong></p><ul><li><strong>Read/Unread Status:</strong> Marks emails as read or unread.</li><li><strong>Flagged:</strong> Users can flag important messages for follow-up.</li><li><strong>Deleted:</strong> Marks messages for deletion, which can be later expunged.</li></ul><p><strong>5. Concurrent Access:</strong></p><ul><li><strong>Multiple Sessions:</strong> Supports multiple simultaneous connections, allowing multiple devices to access the mailbox at the same time.</li></ul><h4>IMAP Commands</h4><ul><li><strong>LOGIN:</strong> Authenticates the user with the server.</li><li><strong>SELECT:</strong> Selects a mailbox to access.</li><li><strong>FETCH:</strong> Retrieves messages or parts of messages.</li><li><strong>SEARCH:</strong> Searches for messages matching specific criteria.</li><li><strong>STORE:</strong> Updates message attributes (e.g., marking as read).</li><li><strong>COPY:</strong> Copies messages to another mailbox.</li><li><strong>EXPUNGE:</strong> Permanently removes messages marked for deletion.</li><li><strong>LOGOUT:</strong> Ends the session with the server.</li></ul><h3>6. User Datagram Protocol (UDP):</h3><p>UDP (User Datagram Protocol) is a connectionless transport protocol in the Internet Protocol Suite. It operates at the transport layer and provides a way to send datagrams (packets of data) across networks without establishing a connection. UDP is known for its simplicity and efficiency but does not guarantee delivery or reliability of data transmission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*AbmzQbQAFOXPwFJu.png" /></figure><p><strong>Key Features of UDP :</strong></p><p><strong>1 . Connectionless:</strong></p><ul><li><strong>No Handshake:</strong> UDP does not establish a connection before sending data.</li><li><strong>Stateless:</strong> Each datagram is handled independently, without maintaining state information.</li></ul><p><strong>2 . Minimal Overhead:</strong></p><ul><li><strong>Header Size:</strong> UDP headers are small (8 bytes), consisting of source port, destination port, length, and checksum fields.</li><li><strong>Less Processing:</strong> Minimal processing overhead compared to connection-oriented protocols like TCP.</li></ul><p><strong>3 .Unreliable Delivery:</strong></p><ul><li><strong>No Acknowledgment:</strong> UDP does not guarantee delivery or provide acknowledgment of packet receipt.</li><li><strong>No Retransmission:</strong> If a packet is lost or arrives out of order, UDP does not attempt to recover or retransmit it.</li></ul><p><strong>4. Fast Transmission:</strong></p><ul><li><strong>Low Latency:</strong> Suitable for applications where speed and efficiency are prioritized over reliability.</li><li><strong>Streaming:</strong> Used in real-time applications like video streaming and online gaming, where occasional packet loss is acceptable.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed4641ebaf75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DOM Manipulation in JavaScript]]></title>
            <link>https://towardsdev.com/dom-manipulation-in-javascript-5927c21796b8?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/5927c21796b8</guid>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 11:14:44 GMT</pubDate>
            <atom:updated>2024-01-31T19:05:52.634Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript, the language of the web, empowers developers to create dynamic and interactive web pages. One of the key features that enables this interactivity is Document Object Model (DOM) manipulation.</p><p>DOM manipulation allows developers to interact with and modify the structure, style, and content of web pages. In this article, we’ll explore the fundamentals of DOM manipulation in JavaScript, breaking down complex concepts into easy-to-understand snippets.</p><h3>What is the DOM?</h3><p>Document Object Model (DOM) is a programming interface that represents the structure of a document as a tree of objects. The document can be an HTML or XML document, and the DOM provides a way for scripts to dynamically access and manipulate the content, structure, and style of the document.</p><p><strong>Key points about the DOM:</strong></p><ol><li><strong>Tree Structure:</strong>The DOM represents the document as a tree structure, where each node in the tree corresponds to an element, attribute, or piece of text in the document.</li><li><strong>Objects: </strong>Each element, attribute, and piece of text in the document is represented by an object in the DOM. These objects can be manipulated using JavaScript to change the content, structure, or style of the document dynamically.</li><li><strong>Document Object: </strong>The top-level object in the DOM hierarchy is called the “document” object. It represents the entire document and provides methods and properties for interacting with the document.</li><li><strong>Dynamic Interaction:</strong>JavaScript can be used to dynamically modify the content and structure of a web page by interacting with the DOM. This allows developers to create interactive and responsive web pages.</li></ol><p><strong>Visual representation of a DOM tree:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aW_0yQeGA8GOoUej.png" /></figure><h3>How to access DOM elements</h3><p>To manipulate the DOM, we need to access its elements. This is commonly done using the document object, which represents the entire HTML document. Let&#39;s look at a simple example:</p><pre>// Accessing an element by its ID<br>const headerElement = document.getElementById(&#39;header&#39;);<br><br>// Accessing elements by class name<br>const paragraphs = document.getElementsByClassName(&#39;paragraph&#39;);<br><br>// Accessing elements by tag name<br>const images = document.getElementsByTagName(&#39;img&#39;);</pre><h3>How to modify element content</h3><p>Once we have access to an element, we can modify its content using the innerHTML property:</p><pre>headerElement.innerHTML = &#39;New Header Text&#39;;</pre><h3>How to Create and Modify Elements</h3><p>In addition to modifying existing elements, JavaScript allows us to create new elements and add them to the DOM.</p><h3>How to create new elements</h3><p>The createElement method is used to create a new HTML element. Let&#39;s create a new paragraph element and append (add) it to the body of the document:</p><pre>const newParagraph = document.createElement(&#39;p&#39;);<br><br>// Setting the text content of the new paragraph<br>newParagraph.textContent = &#39;This is a new paragraph.&#39;;<br><br>// Appending the new paragraph to the body of the document<br>document.body.appendChild(newParagraph);</pre><p>we create a new p (paragraph) element, set its text content, and then append it to the body of the document.</p><p><strong>For example, here’s a simple HTML document:</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;DOM Example&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1 id=&quot;myHeading&quot;&gt;Hello, DOM!&lt;/h1&gt;<br>    &lt;p&gt;This is a paragraph.&lt;/p&gt;<br><br>    &lt;script&gt;<br>        // Accessing and modifying the DOM<br>        var heading = document.getElementById(&#39;myHeading&#39;);<br>        heading.innerHTML = &#39;Hello, Updated DOM!&#39;;<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In this example, JavaScript is used to get the element with the ID “myHeading” and change its content using the innerHTML property. This is a basic illustration of how the DOM allows dynamic interaction with the content of a web page.</p><p>Thank You…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5927c21796b8" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/dom-manipulation-in-javascript-5927c21796b8">DOM Manipulation in JavaScript</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creational Design Pattern :]]></title>
            <link>https://towardsdev.com/creational-design-pattern-60524986daab?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/60524986daab</guid>
            <category><![CDATA[creational-design-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Mon, 22 Jan 2024 18:01:28 GMT</pubDate>
            <atom:updated>2024-01-22T18:01:28.036Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creational Design Pattern :</h3><p>Introduction :</p><p>In the previous post we learn about the Singleton pattern in Creational Design pattern. if you don`t know basic of Design Pattern please go through previous blog first .</p><p>Link :</p><p><a href="https://towardsdev.com/design-pattern-fc1d98ae9760">https://towardsdev.com/design-pattern-fc1d98ae976</a></p><p>In this Post We are going To deep and dive the Factory method , Abstract Factory in Creational Design Pattern .</p><p><strong>Factory Method :</strong>The Factory Method is a creational design pattern that provides an interface for creating instances of a class, but allows subclasses to alter the type of instances that will be created. In other words, it defines an interface for creating an object, but the exact class of the object can be determined by the subclasses.</p><p>overview of the Factory Method pattern:</p><ol><li><strong>Creator Interface or Abstract Class:</strong></li></ol><ul><li>Defines the interface for creating the product (object).</li><li>Contains the factory method, which is responsible for creating instances of the product.</li><li>May include other methods that operate on the product.</li></ul><p>2. <strong>Concrete Creator Classes:</strong></p><ul><li>Subclasses of the creator interface or abstract class.</li><li>Implement the factory method to create instances of the product.</li></ul><p>3. <strong>Product Interface or Abstract Class:</strong></p><p>. Defines the interface for the product created by the factory method.</p><p>4. <strong>Concrete Product Classes:</strong></p><ul><li>Implement the product interface or extend the product abstract class.</li><li>Represent the different types of objects that can be created by the factory method.</li></ul><p>Example of Factory Method Pattern in python :</p><pre># Product interface<br>class Product:<br>    def display(self):<br>        pass<br><br># Concrete Product classes<br>class ConcreteProductA(Product):<br>    def display(self):<br>        return &quot;Concrete Product A&quot;<br><br>class ConcreteProductB(Product):<br>    def display(self):<br>        return &quot;Concrete Product B&quot;<br><br># Creator interface<br>class Creator:<br>    def factory_method(self):<br>        pass<br><br>    def create_product(self):<br>        product = self.factory_method()<br>        # Additional operations on the product, if needed<br>        return product<br><br># Concrete Creator classes<br>class ConcreteCreatorA(Creator):<br>    def factory_method(self):<br>        return ConcreteProductA()<br><br>class ConcreteCreatorB(Creator):<br>    def factory_method(self):<br>        return ConcreteProductB()<br><br># Client code<br>creator_a = ConcreteCreatorA()<br>product_a = creator_a.create_product()<br>print(product_a.display())  # Output: Concrete Product A<br><br>creator_b = ConcreteCreatorB()<br>product_b = creator_b.create_product()<br>print(product_b.display())  # Output: Concrete Product B</pre><p>. In this example, ‘Product&#39; is the interface for the products, and ‘ConcreteProductA’ and ‘ConcreteProductB’ are two concrete implementations of the product.</p><p>&#39;Creator&#39; interface declares the factory method ‘factory_method’, and concrete creator classes ‘ConcreteCreatorA&#39; and ‘ConcreteCreatorB’ implement this method to create instances of specific products.</p><p>The client code uses a creator to create a product without knowing the specific product class.</p><p><strong>Abstract Factory : </strong>The Abstract Factory pattern is a creational design pattern that provides an interface for creating families of related or dependent objects without specifying their concrete classes. It falls under the category of design patterns that deal with object creation mechanisms.</p><p>The main idea behind the Abstract Factory pattern is to define an interface or an abstract class for creating families of products (objects) related to a specific theme or variant. Concrete implementations of this interface, known as concrete factories, then produce concrete products that belong to the same family.</p><p>Components of the Abstract Factory pattern:</p><ol><li><strong>Abstract Factory Interface or Abstract Class:</strong></li></ol><ul><li>Declares the interface for creating families of products.</li><li>Typically, includes a set of abstract methods, each responsible for creating a specific type of product.</li></ul><p>2 . <strong>Concrete Factories:</strong></p><ul><li>Implement the Abstract Factory interface.</li><li>Produce concrete products that belong to a specific family.</li><li>The choice of which concrete factory to use determines the variant of the created products.</li></ul><p>3 . <strong>Abstract Products:</strong></p><ul><li>Declare interfaces for the different types of products that a family of factories can produce.</li><li>Each abstract product corresponds to one of the product types defined in the Abstract Factory interface.</li></ul><p>4 .<strong> Concrete Products:</strong></p><ul><li>Implement the interfaces defined by the abstract products.</li><li>Represent the actual objects created by the concrete factories.</li></ul><p>The Abstract Factory pattern allows a system to be independent of how its objects are created, composed, and represented. It promotes the use of families of related or dependent objects, making it easier to ensure that the created objects work together seamlessly.</p><p>Example of Abstract Factory pattern in Python :</p><pre># Abstract Factory interface<br>class AbstractFactory:<br>    def create_product_a(self):<br>        pass<br><br>    def create_product_b(self):<br>        pass<br><br># Concrete Factory 1<br>class ConcreteFactory1(AbstractFactory):<br>    def create_product_a(self):<br>        return ConcreteProductA1()<br><br>    def create_product_b(self):<br>        return ConcreteProductB1()<br><br># Concrete Factory 2<br>class ConcreteFactory2(AbstractFactory):<br>    def create_product_a(self):<br>        return ConcreteProductA2()<br><br>    def create_product_b(self):<br>        return ConcreteProductB2()<br><br># Abstract Products<br>class AbstractProductA:<br>    def operation_a(self):<br>        pass<br><br>class AbstractProductB:<br>    def operation_b(self):<br>        pass<br><br># Concrete Products<br>class ConcreteProductA1(AbstractProductA):<br>    def operation_a(self):<br>        return &quot;ConcreteProductA1 operation&quot;<br><br>class ConcreteProductB1(AbstractProductB):<br>    def operation_b(self):<br>        return &quot;ConcreteProductB1 operation&quot;<br><br>class ConcreteProductA2(AbstractProductA):<br>    def operation_a(self):<br>        return &quot;ConcreteProductA2 operation&quot;<br><br>class ConcreteProductB2(AbstractProductB):<br>    def operation_b(self):<br>        return &quot;ConcreteProductB2 operation&quot;pyt</pre><p>In this example, ‘AbstractFactory’declares the interfaces for creating two types of products (‘ProductA’and ‘ProductB&#39;).</p><p>&#39;ConcreteFactory1&#39; and ‘ConcreteFactory2’ are two concrete implementations of the abstract factory, each producing a family of related products (‘ConcreteProductA1’and ‘ConcreteProductB1’ for ‘ConcreteFactory1’, and ‘ConcreteProductA2&#39; and ‘ConcreteProductB2’ for ConcreteFactory2).</p><p>Clients can use the abstract factory to create products without specifying their concrete classes, allowing for flexibility in product variations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60524986daab" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/creational-design-pattern-60524986daab">Creational Design Pattern :</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Pattern]]></title>
            <link>https://towardsdev.com/design-pattern-fc1d98ae9760?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc1d98ae9760</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Fri, 19 Jan 2024 16:41:15 GMT</pubDate>
            <atom:updated>2024-01-19T16:41:15.654Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction :</strong></p><p>A design pattern is a general reusable solution to a recurring problem in software design. It is a template or blueprint that can be applied to different situations to solve common design issues in a flexible and efficient way. Design patterns are not specific to a particular programming language or technology; instead, they are abstract concepts that can be adapted and implemented in various contexts.</p><p>Type of Design Pattern:</p><ol><li><strong>Creational Patterns:</strong> These patterns are designed for class instantiation. They can be either class-creation patterns or object-creational patterns. Examples include the Singleton, Factory Method, and Abstract Factory patterns.</li><li><strong>Structural Patterns :</strong> These patterns are designed with regard to a class’s structure and composition. The main goal of most of these patterns is to increase the functionality of the class(es) involved, without changing much of its composition. Examples include the Adapter, Decorator, and Composite patterns.</li><li><strong>Behavioral</strong> <strong>Patterns</strong> : These patterns define how objects interact and communicate with each other. They focus on the delegation of responsibilities and the flow of control. Examples include the Observer, Strategy, and Command patterns.</li></ol><p>In this post, we will go through <strong>Creational </strong>design pattern for each type.</p><h3>Singleton Design Pattern :</h3><p>The Singleton Design Pattern is a Creational pattern, whose objective is to create only one instance of a class and to provide only one global access point to that object.</p><p>This pattern is useful when exactly one object is needed to coordinate actions across the system. The Singleton pattern is implemented by defining a class that has only one instance and providing a global point of access to that instance.</p><p>Simple example of a Singleton pattern in Python :</p><pre>class Singleton:<br>    _instance = None  # Class variable to store the singleton instance<br><br>    def __new__(cls):<br>        if cls._instance is None:<br>            cls._instance = super(Singleton, cls).__new__(cls)<br>            # Additional initialization can be done here<br>        return cls._instance<br><br># Example usage:<br>singleton_instance1 = Singleton()<br>singleton_instance2 = Singleton()<br><br>print(singleton_instance1 is singleton_instance2)  # Output: True</pre><pre>Output: True</pre><p>. The _instance variable is used to store the single instance of the class.</p><p>. The ‘__new__&#39; method is overridden to control the instantiation process. If the ‘_instance&#39; is None, a new instance is created, and it is stored in the _instance variable. If an instance already exists, the existing instance is returned.</p><p>Using the Singleton pattern ensures that only one instance of the class is created, and any subsequent attempts to create new instances return the existing one. This can be useful in scenarios where a single point of control or coordination is required, such as managing a configuration object, a connection to a database, or a logging service.</p><p>In the next post we are going to Discuss about the Factory Method, and Abstract Factory patterns in <strong>Creational design pattern</strong>….</p><p><a href="https://towardsdev.com/design-pattern-fc1d98ae9760">https://towardsdev.com/design-pattern-fc1d98ae9760</a></p><p>Thank you .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc1d98ae9760" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/design-pattern-fc1d98ae9760">Design Pattern</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON]]></title>
            <link>https://towardsdev.com/json-d5197410632e?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5197410632e</guid>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 18:53:12 GMT</pubDate>
            <atom:updated>2024-01-22T17:55:16.392Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Json ?</strong></p><p>JSON, which stands for JavaScript Object Notation, is a lightweight data interchange format. It is easy for humans to read and write, and it’s easy for machines to parse and generate. JSON is often used to transmit data between a server and a web application, as an alternative to XML.</p><h3>Key Features of JSON:</h3><ol><li><strong>Syntax: </strong>JSON has a simple and easy-to-read syntax, consisting of key-value pairs.</li><li><strong>Data Types:</strong> JSON supports various data types, including strings, numbers, objects, arrays, boolean, and null.</li><li><strong>Object:</strong>An object in JSON is an unordered collection of key-value pairs. Keys are strings, and values can be strings, numbers, objects, arrays, boolean, or null.</li></ol><p>Example of a simple JSON object:</p><pre>{<br>  &quot;name&quot;: &quot;John Doe&quot;,<br>  &quot;age&quot;: 30,<br>  &quot;isStudent&quot;: false,<br>  &quot;courses&quot;: [&quot;Math&quot;, &quot;History&quot;, &quot;English&quot;]<br>}</pre><p>JSON typically involves two main operations: serialization and deserialization.</p><p><strong>Serialization:</strong>Serialization is the process of converting data structures or objects into a JSON format.</p><p><strong>Serialization (Object to JSON):</strong></p><pre>const myObject = {<br>  name: &quot;John Doe&quot;,<br>  age: 30,<br>  isStudent: false,<br>  courses: [&quot;Math&quot;, &quot;History&quot;, &quot;English&quot;]<br>};<br><br>const jsonString = JSON.stringify(myObject);<br>console.log(jsonString);</pre><p><strong>Deserialization: </strong>deserialization is the process of converting JSON back into data structures or objects that your programming language can work with.</p><p><strong>Deserialization (JSON to Object):</strong></p><pre>const jsonString = &#39;{&quot;name&quot;:&quot;John Doe&quot;,&quot;age&quot;:30,&quot;isStudent&quot;:false,&quot;courses&quot;:[&quot;Math&quot;,&quot;History&quot;,&quot;English&quot;]}&#39;;<br><br>const myObject = JSON.parse(jsonString);<br>console.log(myObject);</pre><p>Sending data from a server to a client using JSON typically involves the server converting its data into a JSON format and then transmitting it to the client. The client can then parse the JSON data to extract the information. The communication can occur over HTTP, WebSocket, or any other suitable protocol.</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5197410632e" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/json-d5197410632e">JSON</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cookie]]></title>
            <link>https://medium.com/@sunnyngupta/cookie-ab74b23a9d4f?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab74b23a9d4f</guid>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Sat, 04 Nov 2023 20:38:13 GMT</pubDate>
            <atom:updated>2023-11-04T20:38:13.151Z</atom:updated>
            <content:encoded><![CDATA[<p>What is Cookie ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*2wcPHTxiTIXTf3vj.png" /></figure><p>Cookies are small pieces of data that websites store on your computer or device when you visit them.</p><p><strong>Purpose of Cookie:</strong></p><ol><li><strong>Session Management:</strong> Cookies are commonly used to manage user sessions on websites. They help the website remember your login status, so you don’t have to re-enter your credentials each time you navigate to a different page.</li><li><strong>Personalization:</strong> Websites can use cookies to remember your preferences and settings, such as language preferences, layout choices, or items in your shopping cart.</li><li><strong>Tracking and Analytics:</strong> Cookies are used by websites and third-party services to collect data about user behavior, such as which pages you visit and how long you spend on them. This information can be used for analytics and to improve the user experience.</li><li><strong>Targeted Advertising:</strong> Cookies are often employed in online advertising to track your interests and online behavior. Advertisers can then show you more relevant ads based on your browsing history.</li><li><strong>Security:</strong> Some cookies are used for security purposes, helping to prevent fraud and unauthorized access to websites.</li></ol><h3><strong>Cookies are typically divided into two main types:</strong></h3><ol><li><strong>Session Cookies:</strong> These cookies are temporary and are deleted from your device when you close your web browser. They are primarily used for session management and storing temporary information.</li><li><strong>Persistent Cookies:</strong> These cookies remain on your device even after you close your browser. They can be used for purposes like remembering login information or tracking your preferences over time.</li></ol><h3><strong>Working Of Cookie:</strong></h3><ol><li><strong>Request and Response:</strong> When you visit a website, your web browser sends a request to the web server hosting the site, asking for the web page and its associated resources (images, scripts, stylesheets, etc.).</li><li><strong>Server Response:</strong> The web server processes your request and sends back the requested web page along with additional instructions for the browser. These instructions often include setting cookies.</li><li><strong>Cookie Creation:</strong> When a web server wants to set a cookie on your device, it includes a “Set-Cookie” header in its response. This header contains information about the cookie, including its name, value, expiration time, and other attributes.</li><li><strong>Cookie Storage: </strong>Your web browser receives the response, reads the “Set-Cookie” header, and stores the cookie data on your device. The browser keeps track of these cookies and associates them with the website that set them.</li><li><strong>Subsequent Requests:</strong> When you navigate to other pages on the same website or return to it in the future, your web browser includes the stored cookies in its request headers for that site. This allows the website to recognize you and access the information stored in the cookies.</li><li><strong>Server-Side Processing: </strong>The web server, upon receiving your subsequent requests, can read the cookies sent with the request to retrieve information, such as your session ID, preferences, or any other data stored in the cookies. This information is then used to personalize the user experience, maintain session state, or provide targeted content.</li><li><strong>Expiration and Deletion: </strong>Cookies can have expiration times, after which they are automatically deleted from your device. Some cookies are set to expire when you close your browser (session cookies), while others may have longer lifetimes (persistent cookies). Users can also manually delete cookies from their browsers if desired.</li></ol><p>Thank You….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab74b23a9d4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DNS]]></title>
            <link>https://towardsdev.com/dns-9e2c3e7451d3?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e2c3e7451d3</guid>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 12:09:25 GMT</pubDate>
            <atom:updated>2024-01-22T17:55:23.001Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is DNS?</strong></p><p>DNS, or Domain Name System, is a fundamental component of the internet that translates human-readable domain names into IP addresses, allowing users to access websites and online services using familiar names instead of numeric IP addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*u-Ysdw4U5NcLjUzK.jpg" /></figure><p><strong>Working of DNS:</strong></p><ol><li><strong>User Input:</strong> When a user enters a domain name (e.g., <a href="http://www.example.com/">www.example.com</a>) into a web browser, their device needs to find the corresponding IP address of that domain to establish a connection.</li><li><strong>Local DNS Cache:</strong> The user’s device first checks its local DNS cache. If the domain has been recently accessed, the device might have the IP address stored, which can speed up the process. If it’s not in the cache or has expired, the device needs to query external DNS servers.</li><li><strong>DNS Resolution Request:</strong> If the IP address is not found in the local cache, the device sends a DNS resolution request to a DNS resolver. The DNS resolver can be provided by an Internet Service Provider (ISP) or a public DNS service (e.g., Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1).</li><li><strong>Root DNS Servers:</strong> If the resolver does not have the IP address in its cache, it contacts the root DNS servers. These servers maintain the authoritative information for top-level domains (TLDs), such as .com, .org, and .net.</li><li><strong>TLD DNS Servers: </strong>The root servers direct the resolver to the TLD DNS servers responsible for the specific domain extension (e.g., .com). These TLD servers store information about which authoritative name servers handle the second-level domains (e.g., example.com).</li><li><strong>Authoritative Name Servers:</strong> The TLD servers provide the resolver with the IP address of the authoritative name server for the requested domain. These authoritative servers have the most up-to-date information about the domain’s IP address.</li><li><strong>Obtaining the IP Address:</strong> The resolver then contacts the authoritative name server for the domain (e.g., ns1.example.com). This server provides the IP address associated with the domain name.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*2Bmr4LrAhOYGvMI_.png" /></figure><ol><li><strong>Caching:</strong> The resolver caches the IP address it received, which speeds up future requests for the same domain. It also returns the IP address to the user’s device.</li></ol><p>This process happens in a fraction of a second and is transparent to the user. DNS is crucial for the functioning of the internet, as it allows us to use human-friendly domain names rather than remembering and entering numeric IP addresses for every website we want to visit.</p><p>Thank You …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e2c3e7451d3" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/dns-9e2c3e7451d3">DNS</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Http ?]]></title>
            <link>https://medium.com/@sunnyngupta/what-is-http-6a43e73cd376?source=rss-2154da7da244------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a43e73cd376</guid>
            <category><![CDATA[what-is-http]]></category>
            <dc:creator><![CDATA[sunny Gupta]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 11:58:12 GMT</pubDate>
            <atom:updated>2023-10-31T11:58:12.947Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Http ?</h3><h4>Http: HTTP, or Hypertext Transfer Protocol, is an application layer protocol used for transmitting and receiving data on the World Wide Web. It is the foundation of data communication on the internet, enabling the transfer of various types of information, including text, images, videos, and more. HTTP is a request-response protocol, where a client (usually a web browser) makes requests to a server, and the server responds with the requested data.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*LgtWpGRfBmj8NE59.png" /></figure><p>Here are some key features and aspects of HTTP:</p><p>1. Statelessness: HTTP is a stateless protocol, which means that each request from a client to a server is independent and doesn’t inherently contain information about previous requests. This allows for scalability and simplicity but may require additional mechanisms like cookies to maintain user sessions.</p><p>2. URI (Uniform Resource Identifier): Resources on the web, such as web pages, images, and documents, are identified by URIs. A URI typically includes a URL (Uniform Resource Locator) that specifies the address and protocol for accessing a resource.</p><p>3. Request Methods: HTTP requests use various methods, with the most common ones being GET (retrieve data), POST (send data to be processed), PUT (update a resource), DELETE (remove a resource), and more. Each method has a specific purpose.</p><p>4. Headers: HTTP requests and responses include headers that convey additional information about the data being transferred, such as content type, length, and encoding.</p><p>5. Status Codes: HTTP responses are accompanied by status codes, which provide information about the outcome of the request. Common status codes include 200 (OK), 404 (Not Found), 500 (Internal Server Error), and many others.</p><p>6. Versions: HTTP has gone through several versions, with HTTP/1.0 and HTTP/1.1 being the most widely used versions for many years. HTTP/2 and HTTP/3 have been introduced to address performance and security improvements, including faster data transfer and better support for encrypted connections.</p><p>7. Security: While HTTP transfers data in plain text, HTTPS (HTTP Secure) uses encryption (SSL/TLS) to provide secure, encrypted communication between the client and server. HTTPS is essential for protecting sensitive information, such as login credentials and personal data.</p><p>HTTP plays a crucial role in the functioning of the World Wide Web, as it allows web browsers to retrieve web pages, display multimedia content, submit forms, and interact with web services. It’s the foundation for the transfer of information on the internet, making it a fundamental part of modern online communication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a43e73cd376" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>