<?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 Gagan Jain on Medium]]></title>
        <description><![CDATA[Stories by Gagan Jain on Medium]]></description>
        <link>https://medium.com/@gaganjain9319?source=rss-80019a39f783------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-W3gH742soIuK3Mh</url>
            <title>Stories by Gagan Jain on Medium</title>
            <link>https://medium.com/@gaganjain9319?source=rss-80019a39f783------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:17:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaganjain9319/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[How to start with spring boot web application with maven]]></title>
            <link>https://medium.com/@gaganjain9319/how-to-start-with-spring-boot-web-application-with-maven-21d2d5500291?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/21d2d5500291</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 14:12:46 GMT</pubDate>
            <atom:updated>2023-11-06T14:12:46.971Z</atom:updated>
            <content:encoded><![CDATA[<p>Starting a Spring Boot web application with Maven is a common and straightforward process. You can create a simple web application by following these steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_p8gnnNNvzn7BziM_aIFWA.png" /><figcaption>Image Ref: <a href="https://www.interviewbit.com/blog/spring-boot-architecture/">https://www.interviewbit.com/blog/spring-boot-architecture/</a></figcaption></figure><p><strong>Prerequisites</strong>:</p><ul><li>Ensure you have Java and Maven installed on your system.</li></ul><p><strong>Step 1: Create a Spring Boot Project</strong></p><ol><li>Open a terminal or command prompt.</li><li>Navigate to the directory where you want to create your Spring Boot project.</li><li>Use the Spring Initializer tool, which is a convenient way to generate a Spring Boot project with the necessary dependencies:</li></ol><pre>mvn archetype:generate -DarchetypeGroupId=org.springframework.boot -DarchetypeArtifactId=spring-boot-archetype -DarchetypeVersion=2.7.1 -DgroupId=com.example -DartifactId=my-web-app -Dversion=1.0.0 -DinteractiveMode=false</pre><p>In this command:</p><ul><li>-DgroupId: Specify the group ID for your project.</li><li>-DartifactId: Specify the project&#39;s artifact ID (your project&#39;s name).</li><li>-Dversion: Set the project&#39;s version.</li><li>-DinteractiveMode=false: Disable interactive mode.</li></ul><ol><li>After running the command, a new directory named my-web-app (or your specified project name) will be created with the Spring Boot project structure.</li></ol><p><strong>Step 2: Open the Project in an IDE</strong></p><p>You can use an Integrated Development Environment (IDE) like IntelliJ IDEA, Eclipse, or Visual Studio Code to work with your project. Import the project into your preferred IDE.</p><p><strong>Step 3: Write a Simple Web Application</strong></p><p>Now that you have your project set up, you can start writing your Spring Boot web application:</p><ol><li>Open the <strong>src/main/java/com/example/mywebapp</strong> (or your package structure) directory, and you will find a file named MyWebAppApplication.java. This file contains the main class for your Spring Boot application.</li><li>Create a simple Spring MVC controller to handle HTTP requests. You can create a new Java class, for example, HelloController.java, in the same package or a different package. Here&#39;s an example of a simple controller:</li></ol><pre>package com.example.mywebapp;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.RestController;<br>@RestController<br>public class HelloController {<br>    @GetMapping(&quot;/hello&quot;)<br>    public String hello() {<br>        return &quot;Hello, World!&quot;;<br>    }<br>}</pre><ol><li>Start your Spring Boot application by running the MyWebAppApplication class.</li></ol><p><strong>Step 4: Access the Web Application</strong></p><p>Your Spring Boot web application will start, and you can access it in a web browser or using a tool like curl or httpie. By default, it runs on <a href="http://localhost:8080.">http://localhost:8080.</a></p><ul><li>Open a web browser and go to: <a href="http://localhost:8080/hello">http://localhost:8080/hello</a></li></ul><p>You should see the “Hello, World!” message.</p><p><strong>Step 5: Customize and Build</strong></p><p>You can further customize your Spring Boot application by adding more controllers, services, and views. You can also configure properties, add dependencies, and package your application for deployment.</p><p>To build a deployable JAR file for your application, run the following command in your project’s root directory:</p><pre>mvn clean package</pre><p>This will create a JAR file in the target directory that you can run on any Java-enabled server or cloud platform.</p><p>That’s a basic guide on how to start a Spring Boot web application using Maven. You can expand your application by adding more features, views, and dependencies based on your project’s requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21d2d5500291" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EJB (Enterprise JavaBeans) use cases and scope.]]></title>
            <link>https://medium.com/@gaganjain9319/ejb-enterprise-javabeans-use-cases-and-scope-5501b300f3cc?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/5501b300f3cc</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 01:00:31 GMT</pubDate>
            <atom:updated>2023-04-11T01:00:31.694Z</atom:updated>
            <content:encoded><![CDATA[<p>EJB (Enterprise JavaBeans) is a component-based architecture for building distributed enterprise-level applications using Java. It provides a set of standard APIs for creating and managing transactional, scalable, and secure business components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zVWZsljgKzBGGU02cQY5ZA.jpeg" /><figcaption>Image Reference: Edureka</figcaption></figure><p>There are three types of EJBs:</p><ol><li>Session beans: Represent a single client-server session and perform business logic tasks. They can be stateless or stateful.</li><li>Message-driven beans: Receive and process messages asynchronously from message queues or topics.</li><li>Entity beans: Represent data stored in a database and provide a persistence layer for accessing and modifying data.</li></ol><p>EJBs are managed by a container, which provides services such as transaction management, security, concurrency, and resource pooling. The container takes care of the low-level details of managing the components, allowing developers to focus on business logic and application development.</p><p>EJBs can be deployed on different application servers such as JBoss, WebSphere, or WebLogic. They can be accessed by Java clients or web applications using Java Naming and Directory Interface (JNDI) lookup.</p><p><strong>Scope: </strong>EJB technology provides many benefits for enterprise-level applications such as:</p><ol><li>Transactional support: EJBs provide support for distributed transactions, ensuring data consistency and integrity.</li><li>Scalability: EJBs can be deployed on multiple servers, providing horizontal scalability.</li><li>Security: EJBs can be secured using various authentication and authorization mechanisms.</li><li>Reusability: EJBs are modular components that can be reused in different applications, reducing development time and cost.</li></ol><p><em>EJBs are widely used in various domains such as banking, insurance, e-commerce, and healthcare, where there is a need for transactional, scalable, and secure applications.</em></p><p>However, with the advent of modern technologies such as <em>Spring Framework and microservices, the use of EJBs has decreased in recent years</em>. Spring Framework provides a lightweight and flexible alternative to EJBs for building enterprise-level applications, while microservices provide a modular and scalable approach to building distributed systems.</p><p><strong>Types of EJBs with Example</strong>: As mentioned earlier, there are three types of EJBs: Session Beans, Entity Beans, and Message-driven Beans. Let’s take a look at each type of EJB and their respective usage with examples.</p><p>1.<strong> Session Beans</strong>: Session beans are used to perform business logic operations, and they can be stateful or stateless.</p><p><strong>Example Usage</strong>: Suppose we have an online shopping cart application. We can use session beans to manage the user’s cart contents, calculate the total price of the items, and process the order. We can use a stateful session bean to keep track of the user’s cart contents and a stateless session bean to calculate the total price and process the order.</p><p>2. <strong>Entity Beans</strong>: Entity beans represent persistent data stored in a database and provide a persistence layer for accessing and modifying the data.</p><p><strong>Example Usage</strong>: Suppose we have a customer management application. We can use entity beans to represent customer data, such as name, address, and contact information, stored in a database. We can use the entity beans to perform CRUD (Create, Read, Update, Delete) operations on the customer data.</p><p>3. <strong>Message-driven Beans</strong>: Message-driven beans are used to process messages asynchronously from message queues or topics.</p><p><strong>Example Usage</strong>: Suppose we have an application that needs to process data from an external system. We can use a message-driven bean to receive messages from the external system and process them asynchronously. For example, we can use a message-driven bean to receive purchase orders from a supplier and update the inventory system accordingly.</p><blockquote>In summary, EJBs provide a component-based architecture for building enterprise-level applications. Session beans are used to perform business logic operations, entity beans represent persistent data stored in a database, and message-driven beans are used to process messages asynchronously. Depending on the specific requirements of the application, one or more types of EJBs can be used to build a robust and scalable solution.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5501b300f3cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JMS(Java Message Service) detailed explanation!]]></title>
            <link>https://medium.com/@gaganjain9319/jms-java-message-service-detailed-explanation-50bc5ba6e3ef?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/50bc5ba6e3ef</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Sun, 02 Apr 2023 17:01:49 GMT</pubDate>
            <atom:updated>2023-04-03T08:41:06.857Z</atom:updated>
            <content:encoded><![CDATA[<p>Java Message Service (JMS) is a Java-based messaging API for creating, sending, receiving, and reading messages between two or more clients in a distributed computing environment.</p><p>JMS is a standard specification that defines a set of interfaces and protocols for reliable and asynchronous messaging. It provides a way for applications to communicate with each other without knowing the details of the underlying communication protocols, such as TCP/IP or HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grWlGa-q1mKUtGEtPZVVYQ.png" /></figure><p><strong><em>JMS provides a standard way for clients to create, send, receive, and read messages, regardless of the messaging style used</em></strong>. It also provides features such as transaction support, message persistence, and message filtering.</p><p><strong>Features: </strong>JMS (Java Message Service) is a powerful messaging API that provides several features to build distributed, asynchronous systems. Some of the key features of JMS are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xoSrUbGrRpl_tmM_Bhd3Q.png" /><figcaption>Image Ref: <a href="https://www.tomitribe.com/blog/5-minutes-or-less-activemq-with-jms-queues-and-topics/">https://www.tomitribe.com</a></figcaption></figure><ol><li>Messaging Models: <strong><em>JMS supports two messaging models, Publish-Subscribe and Point-to-Point</em></strong>. In Publish-Subscribe, messages are broadcasted to multiple subscribers, while in Point-to-Point, messages are delivered to only one receiver.</li><li>Reliable Delivery: JMS ensures reliable message delivery by supporting transactional messaging and message persistence. Message persistence ensures that messages are not lost in case of system failures. Transactional messaging ensures that either all or none of the messages in a transaction are delivered.</li><li>Asynchronous Communication: JMS allows applications to communicate asynchronously, which means that they do not have to wait for a response from the receiver. This is useful in situations where a sender does not need an immediate response, or when the receiver may be temporarily unavailable.</li><li>Message Filtering: JMS allows messages to be filtered based on criteria such as message properties, message content, and message headers. This is useful in situations where a receiver is interested in only certain types of messages.</li><li>Message Transformation: JMS allows messages to be transformed between different message formats, such as XML, JSON, or plain text. This is useful when different systems use different message formats.</li><li>Scalability: JMS supports distributed systems and can handle high message volumes, making it suitable for large-scale applications.</li><li>Security: JMS provides several security features, such as authentication, encryption, and authorization, to protect messages from unauthorized access.</li></ol><blockquote><em>In summary, if your application requires asynchronous communication, reliable message delivery, scalability, messaging models, message filtering and transformation, and/or security, JMS may be a good choice. However, if your application does not require these features, JMS may be unnecessary and a simpler messaging solution may suffice.</em></blockquote><ol><li><strong>Point-to-Point Messaging Model: </strong>Point-to-point (P2P) is one of the two messaging models supported by JMS (Java Message Service). In a P2P messaging model, messages are sent from a single sender to a single receiver. The sender creates a message, and sends it to a specific queue, which is then consumed by a single receiver.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*ikxBeNAc3wpe9UJ4bVlX0g.jpeg" /><figcaption>Image Ref: <a href="https://eldermoraes.com/">https://eldermoraes.com/</a></figcaption></figure><p><strong><em>Here’s how P2P messaging works in JMS:</em></strong></p><ol><li>Sender creates a message: The sender creates a JMS message and sends it to a specific queue. The message contains the information that the sender wants to send to the receiver.</li><li>Receiver creates a message consumer: The receiver creates a message consumer for the queue that the sender has sent the message to. The message consumer listens for messages on the queue.</li><li>Sender sends the message: The sender sends the message to the specific queue using a JMS producer. The message is added to the end of the queue.</li><li>Receiver receives the message: The message consumer on the receiver side listens for messages on the queue. When a message is available on the queue, the message consumer retrieves it from the queue and sends it to the receiver.</li><li>Message acknowledgement: Once the message has been successfully received and processed by the receiver, the receiver can send an acknowledgement message to the sender to indicate that the message has been successfully received.</li></ol><p><strong>2. Publish-subscribe Messaging Model</strong>: Publish-subscribe (pub-sub) is one of the two messaging models supported by JMS (Java Message Service). In a pub-sub messaging model, messages are sent from a single sender to multiple receivers. The sender creates a message and publishes it to a specific topic, which can be consumed by multiple subscribers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*YLWcp9HXRzRHkFud3488uw.jpeg" /><figcaption>Image Ref: <a href="https://eldermoraes.com/">https://eldermoraes.com/</a></figcaption></figure><p>Here’s how pub-sub messaging works in JMS:</p><ol><li><strong>Sender creates a message</strong>: The sender creates a JMS message and publishes it to a specific topic. The message contains the information that the sender wants to send to multiple receivers.</li><li><strong>Receiver creates a message consumer</strong>: Each receiver creates a message consumer for the topic that the sender has published the message to. The message consumer listens for messages on the topic.</li><li><strong>Sender publishes the message</strong>: The sender publishes the message to the specific topic using a JMS publisher. The message is added to the end of the topic.</li><li><strong>Receiver receives the message</strong>: The message consumer on each receiver side listens for messages on the topic. When a message is available on the topic, each message consumer retrieves it from the topic and sends it to the corresponding receiver.</li><li><strong>Message acknowledgement</strong>: There is no automatic message acknowledgement in the pub-sub messaging model. The receiver can manually acknowledge the receipt of the message.</li></ol><blockquote><strong>Example: </strong>To implement JMS, you will need a JMS provider such as Apache ActiveMQ, IBM MQ, or RabbitMQ. In this example, we will use Apache ActiveMQ.</blockquote><ol><li><em>First, download and install Apache ActiveMQ.</em></li><li><em>Next, create a Java project in your favorite IDE, and add the ActiveMQ library to your project’s classpath.</em></li><li><em>Create a connection factory object that will establish a connection to the ActiveMQ broker:</em></li></ol><pre>import javax.jms.*;<br>import org.apache.activemq.ActiveMQConnectionFactory;<br>public class JmsExample {<br>    private static String url = &quot;tcp://localhost:61616&quot;;<br>    private static String queueName = &quot;myQueue&quot;;<br>    public static void main(String[] args) throws JMSException {<br>        // create connection factory<br>        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);<br>        // create connection<br>        Connection connection = connectionFactory.createConnection();<br>        connection.start();<br>        // create session<br>        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);<br>        // create destination<br>        Destination destination = session.createQueue(queueName);<br>        // create producer<br>        MessageProducer producer = session.createProducer(destination);<br>        // create message<br>        TextMessage message = session.createTextMessage(&quot;Hello, world!&quot;);<br>        // send message<br>        producer.send(message);<br>        // clean up resources<br>        session.close();<br>        connection.close();<br>    }<br>}</pre><ol><li><em>In the above code, we first create a connection factory object that connects to the ActiveMQ broker at </em><em>tcp://localhost:61616.</em></li><li><em>We then create a connection and start it.</em></li><li><em>We create a session object that will be used to create a message producer and consumer.</em></li><li><em>We create a queue destination, where messages will be sent and received.</em></li><li><em>We create a message producer that will send messages to the queue.</em></li><li><em>We create a message object and set its content to “Hello, world!”.</em></li><li><em>We send the message to the queue using the producer.</em></li><li><em>Finally, we clean up the resources by closing the session and connection.</em></li></ol><p>To receive messages, you can create a message consumer as follows:</p><pre>import javax.jms.*;<br>import org.apache.activemq.ActiveMQConnectionFactory;<br>public class JmsExample {<br>    private static String url = &quot;tcp://localhost:61616&quot;;<br>    private static String queueName = &quot;myQueue&quot;;<br>    public static void main(String[] args) throws JMSException {<br>        // create connection factory<br>        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);<br>        // create connection<br>        Connection connection = connectionFactory.createConnection();<br>        connection.start();<br>        // create session<br>        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);<br>        // create destination<br>        Destination destination = session.createQueue(queueName);<br>        // create consumer<br>        MessageConsumer consumer = session.createConsumer(destination);<br>        // receive message<br>        Message message = consumer.receive();<br>        // process message<br>        if (message instanceof TextMessage) {<br>            String text = ((TextMessage) message).getText();<br>            System.out.println(&quot;Received message: &quot; + text);<br>        }<br>        // clean up resources<br>        session.close();<br>        connection.close();<br>    }<br>}</pre><p>In this code, we create a message consumer that will receive messages from the queue. We then receive the message and process it if it is a TextMessage. Finally, we clean up the resources as before.</p><p>Note that in a real-world scenario, you would typically create the producer and consumer in separate applications or threads, and use different destinations for different types of messages.</p><h4>How can JMS be integrated with other technologies, such as Spring Framework or EJB?</h4><p>JMS (Java Message Service) can be integrated with other technologies, such as the Spring Framework or EJB (Enterprise JavaBeans), in order to build robust, distributed systems that leverage the benefits of JMS. Here are some ways that JMS can be integrated with these technologies:</p><ol><li><strong>Spring Framework</strong>: The Spring Framework provides support for JMS through its JMS API. <strong><em>This API allows you to create JMS connections, sessions, producers, and consumers, and to use them within your Spring-based application</em>.</strong> <strong><em>Additionally, Spring provides support for JMS transactions, allowing you to ensure that either all or none of the messages in a transaction are delivered. Spring also provides integration with popular JMS providers, such as Apache ActiveMQ and IBM MQ.</em></strong></li><li><strong>EJB</strong>: EJB (Enterprise JavaBeans) is a server-side component architecture that provides support for distributed computing. EJB provides support for JMS through its Message-driven Beans (MDBs) feature. MDBs allow you to create components that can asynchronously receive and process JMS messages. EJB also provides support for JMS transactions, allowing you to ensure that either all or none of the messages in a transaction are delivered. Additionally, EJB provides integration with popular JMS providers, such as Apache ActiveMQ and IBM MQ.</li><li><strong>Other technologie</strong>s: JMS can also be integrated with other technologies, such as Apache Camel, which provides a powerful routing engine for JMS messages. Apache Camel can be used to route JMS messages between different systems and to transform messages between different formats. JMS can also be integrated with Apache Kafka, which provides a distributed messaging system for handling high volumes of data in real-time.</li></ol><p>In summary, JMS can be integrated with other technologies, such as Spring Framework or EJB, to build robust, distributed systems that leverage the benefits of JMS. By using these technologies, you can ensure reliable message delivery, support asynchronous communication, and handle high message volumes, making it suitable for large-scale applications.</p><blockquote>Overall, JMS provides a flexible and powerful messaging API that can be used to build complex distributed systems that require asynchronous communication and reliable message delivery.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50bc5ba6e3ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Emerging Technologies which will have a significant impact on our world.]]></title>
            <link>https://medium.com/@gaganjain9319/emerging-technologies-which-will-have-a-significant-impact-on-our-world-f90147c6204a?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/f90147c6204a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[changemaker]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 08:46:53 GMT</pubDate>
            <atom:updated>2023-03-24T08:46:53.550Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many exciting technologies that are likely to have a significant impact on our world in the coming years. Here are a few examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ySowfJq8lQKdUAMXBxWf0w.gif" /><figcaption>GIF Reference: <a href="https://dribbble.com/">https://dribbble.com/</a></figcaption></figure><ol><li><strong>Artificial Intelligence</strong> (AI) — AI is already transforming many industries, from healthcare to transportation. In the future, we can expect to see even more powerful AI systems that can perform increasingly complex tasks.</li><li><strong>Robotics</strong> — Robotics is advancing rapidly, and we can expect to see more robots that can perform a wide range of tasks, from manufacturing to healthcare.</li><li><strong>Quantum computing</strong> — Quantum computers are incredibly powerful and can solve complex problems that traditional computers cannot. As the technology develops, we can expect to see new applications in fields such as finance and cryptography.</li><li><strong>5G networks</strong> — 5G networks are already starting to roll out, and they promise faster speeds, lower latency, and more reliable connections than current 4G networks. This will enable new applications such as autonomous vehicles and smart cities.</li><li><strong>Augmented and virtual reality</strong> — Augmented and virtual reality technologies are already being used in gaming and entertainment, but they have many other potential applications, such as in education and training.</li></ol><p>These are just a few examples of the many exciting technologies that are likely to shape our future.</p><p><strong>***Augmented reality (AR) and virtual reality (VR)***</strong> are two related technologies that enable users to experience computer-generated content in different ways.</p><p>Augmented reality (AR) is a technology that overlays digital information, images, or other content onto the real-world environment. This can be done using a smartphone or tablet with a camera and AR software. For example, you could use an AR app to see a virtual dinosaur in your living room, or to get information about a product by pointing your phone’s camera at it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LkcZd9ucSfGKkVpZ8qiEQA.gif" /><figcaption>Gif Reference: <a href="https://arvrjourney.com/">https://arvrjourney.com/</a></figcaption></figure><p>Virtual reality (VR) is a technology that immerses users in a fully computer-generated environment. This is usually done using a headset that covers the eyes and ears and tracks the user’s movements, allowing them to interact with the virtual environment. VR is commonly used for gaming and entertainment, but it also has applications in fields such as education, training, and therapy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*A1S8SKQfRzMnefPWY6DcKQ.gif" /><figcaption>Gif Reference: <a href="http://www.pinterest.com/">www.pinterest.com</a></figcaption></figure><p>Both AR and VR are advancing rapidly and have many potential applications in a variety of industries. For example, AR can be used in manufacturing to provide workers with real-time information about the products they are building, while VR can be used in education to create immersive learning experiences. As the technology improves, we can expect to see even more innovative uses for AR and VR in the future.</p><p>Happy Learning !! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f90147c6204a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Heap Memory and its usages.]]></title>
            <link>https://medium.com/@gaganjain9319/java-heap-memory-and-its-usages-4dd3180f8cd0?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dd3180f8cd0</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 11:11:05 GMT</pubDate>
            <atom:updated>2023-03-23T11:11:05.040Z</atom:updated>
            <content:encoded><![CDATA[<p>In Java, the heap is a region of memory where objects are stored. It is managed by the Java Virtual Machine (JVM) and is used for dynamic memory allocation. Java heap memory is a part of the Java Virtual Machine’s memory and is used to allocate memory to Java objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*ZiV5yog0LRrcvq5U0eoUsw.png" /><figcaption>Image Ref: stackoverflow.com</figcaption></figure><p>The Java heap is divided into two regions: the Young Generation and the Old Generation. The Young Generation is where new objects are created, and the Old Generation is where long-lived objects are stored.</p><p>Java heap memory is important to manage carefully because <strong><em>if the heap runs out of memory, the JVM will throw a java.lang.OutOfMemoryError</em></strong>, which can cause your application to crash.</p><p>To manage heap memory in Java, you can use various tools such as the Java Virtual Machine Tool Interface (<strong>JVMTI</strong>),<strong> Java Mission Control</strong>, and <strong>VisualVM</strong>. These tools allow you to monitor and manage the heap memory usage of your Java applications. Additionally, you can also tune the heap memory settings of your JVM using command-line arguments such as -Xms and -Xmx to set the initial and maximum heap size respectively.</p><p><strong>Here are some examples of how heap memory is used in Java</strong>:</p><p>1. Creating Objects: Whenever an object is created using the new operator, it is allocated on the heap. For example, consider the following code snippet:</p><pre>MyClass obj = new MyClass();</pre><p>Here, the object of MyClass is allocated on the heap.</p><p>2. Dynamic Memory Allocation: Java allows dynamic memory allocation using data structures such as ArrayList, LinkedList, etc. These data structures allocate memory on the heap as required. For example, consider the following code snippet:</p><pre>List&lt;String&gt; list = new ArrayList&lt;String&gt;();<br>list.add(&quot;Java&quot;);<br>list.add(&quot;is&quot;);<br>list.add(&quot;awesome&quot;);</pre><p>Here, the ArrayList allocates memory on the heap as each string is added to the list.</p><p>3. Garbage Collection: In Java, the garbage collector is responsible for freeing up memory that is no longer being used by the program. When an object is no longer referenced by any part of the program, it becomes eligible for garbage collection, and the memory allocated to it on the heap is freed. For example, consider the following code snippet:</p><pre>MyClass obj = new MyClass();<br>obj = null; // obj no longer references the object on the heap</pre><p>Here, the object of MyClass is no longer referenced by the program and will be eligible for garbage collection.</p><p>4. Recursive Function Calls: Recursive functions can lead to the creation of a large number of objects on the heap, as each recursive call creates a new stack frame and associated objects. For example, consider the following code snippet:</p><pre>public int factorial(int n) {<br>    if (n == 0) {<br>        return 1;<br>    }<br>    return n * factorial(n - 1);<br>}</pre><p>Here, each recursive call to the factorial function creates a new stack frame and associated objects on the heap.</p><p>In summary, heap memory is a critical part of Java&#39;s memory management system, and understanding how it is used in different parts of a program is essential for writing efficient and effective Java code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dd3180f8cd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go Lang vs JAVA, how go is better than java in performance..?]]></title>
            <link>https://medium.com/@gaganjain9319/go-lang-vs-java-how-go-is-better-than-java-in-performance-3b9f3949137a?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b9f3949137a</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Wed, 22 Mar 2023 14:15:57 GMT</pubDate>
            <atom:updated>2023-03-23T10:21:31.500Z</atom:updated>
            <content:encoded><![CDATA[<p>Go (also known as Golang) and Java are both popular programming languages used for developing a wide range of applications. While they have some similarities, there are also several key differences between the two languages. Here are some details about the differences between Go and Java:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhyOsAfAU8oXlUYnkWUvuQ.jpeg" /><figcaption>Image Reference: Turing</figcaption></figure><ol><li><strong>Syntax</strong>: One of the most noticeable differences between Go and Java is their syntax. Go has a simpler syntax compared to Java, with fewer keywords and more concise code. This can make Go code easier to read and write, especially for beginners.</li></ol><p>Go:</p><pre>package main<br>import &quot;fmt&quot;<br>func main() {<br>    fmt.Println(&quot;Hello, World!&quot;)<br>}</pre><p>Java:</p><pre>public class HelloWorld {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Hello, World!&quot;);<br>    }<br>}</pre><ol><li><strong>Performance</strong>: Go is designed for high performance and efficiency, making it a good choice for applications that require fast and reliable performance. Java, on the other hand, has a larger memory footprint and can be slower than Go in certain situations.</li><li><strong>Concurrency</strong>: Go was specifically designed with concurrency in mind, and has built-in support for goroutines and channels that make it easy to write concurrent code. Java also has support for concurrency, but it requires more complex code to achieve the same level of concurrency as Go.</li><li><strong>Garbage Collection</strong>: Both Go and Java use garbage collection to manage memory, but Go’s garbage collector is more efficient and faster than Java’s, which can lead to better performance in some situations.</li><li><strong>Libraries and Frameworks</strong>: Java has been around for much longer than Go and therefore has a much larger ecosystem of libraries and frameworks available for developers. Go is still growing in popularity, but it has a smaller set of libraries and frameworks available.</li><li><strong>Error Handling</strong>: In Go, errors are handled using explicit return values, while in Java, exceptions are used for error handling. This can make error handling in Go more explicit and easier to reason about.</li></ol><p><strong>How Go Lang is better in Performance: </strong>Go’s performance advantages over Java can be demonstrated through several examples. Here are some examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*50gShCoVJvKg25EQ7ugFqw.gif" /><figcaption>Gif Ref: blog.jetbrains.com</figcaption></figure><ol><li><strong>Concurrency</strong>: Go’s concurrency model is designed to be fast and efficient, which makes it a good choice for applications that require high levels of concurrency. For example, consider a server application that needs to handle a large number of simultaneous connections. In Go, this can be achieved using goroutines and channels, which can handle large numbers of concurrent connections without incurring significant overhead. In Java, achieving the same level of concurrency would require more complex code using threads and synchronized blocks, which can be slower and less efficient than Go’s goroutines and channels.<br>Java also has support for concurrency, but it is based on a more traditional thread-based model. Java threads are heavier than goroutines, which means that creating large numbers of them can lead to higher overhead and slower performance. Java also uses locks and synchronized blocks to coordinate access to shared resources, which can lead to contention and decreased performance in heavily concurrent environments.</li><li><strong>Memory Management</strong>: Go’s garbage collector is designed to be fast and efficient, which can lead to better performance in memory-intensive applications. For example, consider an application that processes large amounts of data in memory. In Go, the garbage collector can quickly reclaim memory that is no longer needed, which can reduce memory usage and improve performance. In Java, the garbage collector can be slower and less efficient, which can lead to higher memory usage and slower performance.</li><li><strong>Compilation Time</strong>: Go’s simple syntax and lack of legacy features can make it faster to compile and execute code compared to Java. For example, consider a large codebase that needs to be compiled and deployed. In Go, the compiler can quickly generate optimized code, which can reduce deployment time and improve performance. In Java, the compiler can be slower and less efficient, especially for large codebases.</li><li><strong>Networking</strong>: Go’s standard library includes efficient networking features that can improve performance in network-intensive applications. For example, consider an application that needs to make a large number of network requests. In Go, the standard library includes efficient networking features like HTTP/2 support and connection pooling, which can improve performance and reduce latency. Java also has a robust networking stack, but it can be more complex to use and configure compared to Go.</li></ol><p>Overall, Go’s focus on simplicity, concurrency, and efficient memory management, as well as its efficient networking features, can make it faster and more performant.</p><p><strong>Conclusion: </strong>Overall, both Go and Java have their strengths and weaknesses, and the choice between the two will depend on the specific needs of the application being developed. Go is a good choice for applications that require high performance and concurrency, while Java is a good choice for larger, more complex applications that require a wide range of libraries and frameworks.</p><p>Happy Learning !! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b9f3949137a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redis in-memory database and detailed explanation with examples..]]></title>
            <link>https://medium.com/@gaganjain9319/redis-in-memory-database-and-detailed-explanation-with-examples-a6eaa0576a09?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6eaa0576a09</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Wed, 22 Mar 2023 08:46:27 GMT</pubDate>
            <atom:updated>2023-03-23T10:24:09.790Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Redis: </strong>Redis is an in-memory data structure store that is commonly used as a database, cache, and message broker. It offers high-speed data access and processing, support for advanced data structures, and a simple key-value data model. In this answer, we’ll go over some details about Redis and provide examples of how to use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jed-UVwaIqf16oq5f8ATDQ.png" /><figcaption>image Reference: <a href="https://www.logo.wine/logo/Redis">Logo.wine</a></figcaption></figure><p><strong>Redis Cache: </strong>Redis cache works by storing frequently accessed data in memory, instead of repeatedly fetching it from disk or database. This helps to improve the performance of applications by reducing the time needed to access data.</p><p>When a client requests data that is stored in the cache, Redis first checks whether the data is already available in memory. If the data is available, Redis returns it to the client. If the data is not available, Redis fetches it from disk or database, stores it in memory, and returns it to the client. This process is called caching.</p><p><strong>Redis Server Features: </strong>Here are some of the important features of Redis:</p><ol><li><strong>Data Types</strong>: Redis supports a variety of data types, including strings, hashes, lists, sets, and sorted sets. Each data type has its own set of operations for manipulating data in memory.</li><li><strong>In-Memory Storage</strong>: Redis stores data in memory, which allows for extremely fast data access and manipulation. Redis also supports persistence, allowing data to be saved to disk for durability.</li><li><strong>High Performance</strong>: Redis is designed for high performance and can handle a large number of requests per second. Redis achieves high performance through its use of in-memory data storage, single-threaded architecture, and asynchronous I/O.</li><li><strong>Distributed Caching</strong>: Redis can be used as a distributed cache, allowing multiple instances of Redis to work together to store and retrieve data. This can help to improve the scalability and performance of applications that require high throughput.</li><li><strong>Pub/Sub Messaging</strong>: Redis provides a pub/sub messaging system that allows applications to publish messages to channels and subscribe to receive messages from channels. This can be used to build real-time applications, such as chat applications or real-time analytics.</li><li><strong>Lua Scripting</strong>: Redis supports Lua scripting, allowing complex operations to be performed on data in memory. Lua scripts can be executed atomically, ensuring that complex operations are performed consistently.</li><li><strong>Transactions</strong>: Redis provides support for transactions, allowing multiple operations to be grouped together and executed atomically. This can be used to ensure that multiple operations are performed consistently.</li></ol><p><strong>Redis-CLI: <em>Redis CLI (Command-Line Interface) provides a variety of commands for interacting with the Redis server</em></strong>. Here are some of the important commands in Redis CLI:</p><ol><li><strong>GET </strong>key: Returns the value of the specified key.</li><li><strong>SET</strong> key value: Sets the value of the specified key.</li><li><strong>DEL</strong> key: Deletes the specified key.</li><li><strong>EXISTS</strong> key: Returns 1 if the key exists, 0 otherwise.</li><li><strong>KEYS</strong> pattern: Returns all keys matching the specified pattern.</li><li><strong>TTL</strong> key: Returns the remaining time to live of a key that has an expiration set.</li><li><strong>INCR</strong> key: Increments the value of the specified key by 1.</li><li><strong>DECR</strong> key: Decrements the value of the specified key by 1.</li><li><strong>EXPIRE</strong> key seconds: Sets an expiration time (in seconds) for the specified key.</li><li><strong>INFO</strong>: Returns information and statistics about the Redis server.</li><li><strong>FLUSHDB</strong>: Deletes all keys from the current database.</li><li><strong>SCAN</strong> cursor [MATCH pattern] [COUNT count]: Iterates over the keys in the current database.</li><li><strong>HSET</strong> key field value: Sets the value of a field in a hash.</li><li><strong>HGET</strong> key field: Returns the value of a field in a hash.</li><li><strong>RPUSH</strong> key value [value …]: Appends one or more values to a list.</li></ol><p>These are just a few examples of the many commands available in Redis CLI. The full list of commands and their syntax can be found in the Redis documentation.</p><p><strong>Redis Key-Value Data Model</strong>:</p><p>Redis uses a simple key-value data model where <strong><em>keys are unique identifiers for the data</em></strong>, and <strong><em>values can be a variety of data types</em></strong> including strings, hashes, lists, sets, and sorted sets. Keys can expire after a set time, and Redis supports a variety of operations for manipulating data including set, get, delete, increment, and decrement.</p><p>Examples of Redis Operations:</p><p>1. Set and Get:</p><pre>&gt; SET mykey &quot;Hello World&quot;<br>OK<br>&gt; GET mykey<br>&quot;Hello World&quot;</pre><p>In this example, we set the value of mykey to &quot;Hello World&quot; using the SET command, and retrieve the value of mykey using the GET command.</p><p>2. Hashes:</p><pre>&gt; HSET user:123 name &quot;John Doe&quot;<br>OK<br>&gt; HSET user:123 email &quot;johndoe@example.com&quot;<br>OK<br>&gt; HGETALL user:123<br>1) &quot;name&quot;<br>2) &quot;John Doe&quot;<br>3) &quot;email&quot;<br>4) &quot;johndoe@example.com&quot;</pre><p>In this example, we create a hash for a user with ID 123, and set the user&#39;s name and email using the HSET command. We then retrieve all the fields and values for the hash using the HGETALL command.</p><p>3. Lists:</p><pre>&gt; LPUSH mylist &quot;one&quot;<br>1<br>&gt; LPUSH mylist &quot;two&quot;<br>2<br>&gt; LRANGE mylist 0 -1<br>1) &quot;two&quot;<br>2) &quot;one&quot;</pre><p>In this example, we create a list named mylist and add two items to the list using the LPUSH command. We then retrieve all items in the list using the LRANGE command.</p><p>4. Sets:</p><pre>&gt; SADD myset &quot;one&quot;<br>1<br>&gt; SADD myset &quot;two&quot;<br>1<br>&gt; SADD myset &quot;three&quot;<br>1<br>&gt; SMEMBERS myset<br>1) &quot;one&quot;<br>2) &quot;two&quot;<br>3) &quot;three&quot;</pre><p>In this example, we create a set named myset and add three items to the set using the SADD command. We then retrieve all items in the set using the SMEMBERS command.</p><p>5. Sorted Sets:</p><pre>&gt; ZADD myzset 1 &quot;one&quot;<br>1<br>&gt; ZADD myzset 2 &quot;two&quot;<br>1<br>&gt; ZADD myzset 3 &quot;three&quot;<br>1<br>&gt; ZRANGE myzset 0 -1 WITHSCORES<br>1) &quot;one&quot;<br>2) &quot;1&quot;<br>3) &quot;two&quot;<br>4) &quot;2&quot;<br>5) &quot;three&quot;<br>6) &quot;3&quot;</pre><p>In this example, we create a sorted set named myzset and add three items to the set using the ZADD command. We then retrieve all items in the set and their scores using the ZRANGE command.</p><p><strong>Conclusion</strong>:</p><p>Redis is a versatile and powerful in-memory data structure store that can be used for a variety of use cases including caching, messaging, and real-time analytics. It provides a simple key-value data model and supports advanced data structures and operations, making it a popular choice for many applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6eaa0576a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge Sort explanation using JAVA.]]></title>
            <link>https://medium.com/@gaganjain9319/merge-sort-explanation-using-java-547e05d5c607?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/547e05d5c607</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 08:29:07 GMT</pubDate>
            <atom:updated>2023-03-19T08:29:07.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Merge Sort is a <strong>divide-and-conquer algorithm</strong> for sorting arrays or lists. It works by dividing the input array into two halves, recursively sorting each half, and then merging the two sorted halves into a single sorted output array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*ae_SYNxn2tYH6Nm4LRFvzA.gif" /><figcaption>Image Ref: wikipedia</figcaption></figure><p>The algorithm works as follows:</p><ol><li>Divide the input array into two halves, if it has more than one element.</li><li>Recursively sort each half.</li><li>Merge the two sorted halves into a single sorted output array.</li></ol><p>The merging step is the core of the algorithm. It involves comparing the first elements of each half and selecting the smaller one to be added to the output array. This process is repeated until all elements from both halves have been added to the output array.</p><p>Merge Sort is an efficient algorithm for sorting arrays or lists with a time complexity of O(n log n), which makes it much faster than quadratic-time sorting algorithms like Bubble Sort and Selection Sort. It is also a stable sorting algorithm, which means that it maintains the relative order of equal elements in the sorted output.</p><p><strong>Implementation of Merge Sort in Java: </strong>Here is an example implementation of Merge Sort in Java:</p><pre>public class MergeSort {<br>    public static void sort(int[] arr) {<br>        if (arr == null || arr.length &lt;= 1) {<br>            return;<br>        }<br>        int mid = arr.length / 2;<br>        int[] left = new int[mid];<br>        int[] right = new int[arr.length - mid];<br>        System.arraycopy(arr, 0, left, 0, left.length);<br>        System.arraycopy(arr, mid, right, 0, right.length);<br>        sort(left);<br>        sort(right);<br>        merge(arr, left, right);<br>    }<br>    <br>    private static void merge(int[] arr, int[] left, int[] right) {<br>        int i = 0, j = 0, k = 0;<br>        while (i &lt; left.length &amp;&amp; j &lt; right.length) {<br>            if (left[i] &lt;= right[j]) {<br>                arr[k++] = left[i++];<br>            } else {<br>                arr[k++] = right[j++];<br>            }<br>        }<br>        while (i &lt; left.length) {<br>            arr[k++] = left[i++];<br>        }<br>        while (j &lt; right.length) {<br>            arr[k++] = right[j++];<br>        }<br>    }<br>}</pre><p>Merge Sort is a divide-and-conquer algorithm that divides an array into two halves, sorts each half separately, and then merges the two halves into a single sorted array.</p><p><strong>Here&#39;s a real-life example of how Merge Sort can be used</strong>:</p><p>Imagine you are managing a large online store that sells various products. You have a database of customer orders that need to be processed and shipped. Each order consists of a customer&#39;s name, address, payment information, and the list of products they ordered. You need to process these orders efficiently and quickly so that your customers receive their products on time.</p><p>To do this, you can use Merge Sort to sort the orders based on the customer&#39;s shipping address. This will help you group orders based on their destination, so you can process and ship them more efficiently. You can also use Merge Sort to sort the products in each order based on their category or price, which will help you organize your inventory and make it easier to pick and pack products for shipping.</p><p>By using Merge Sort in your order processing system, you can ensure that your customers receive their products on time and that your business runs smoothly and efficiently.</p><p><strong>Merge Sort Complexity Calculation: </strong>The time complexity of Merge Sort can be analyzed using the Master Theorem, which gives us a general formula for the time complexity of divide-and-conquer algorithms.</p><p>Let T(n) be the time complexity of Merge Sort for an input array of size n. In each recursive call, the array is divided in half and two subarrays of size n/2 are sorted recursively. Then, the two subarrays are merged together in linear time, which takes O(n) time. Therefore, we can write the following recurrence relation:</p><p>T(n) = 2T(n/2) + O(n)</p><p>The first term on the right side of the equation represents the time complexity of sorting the two subarrays recursively, and the second term represents the time complexity of merging the two sorted subarrays.</p><p>Using the Master Theorem, we can determine the time complexity of Merge Sort by comparing the recurrence relation to three possible cases:</p><p><strong>Case 1</strong>: If a &gt; b, where T(n) = aT(n/b) + O(n^k), then T(n) = O(n^logb a).</p><p><strong>Case 2</strong>: If a = b, where T(n) = aT(n/b) + O(n^k), then T(n) = O(n^k log n).</p><p><strong>Case 3</strong>: If a &lt; b, where T(n) = aT(n/b) + O(n^k), then T(n) = O(n^k).</p><p>In the case of Merge Sort, a = 2, b = 2, and k = 1. Therefore, we have:</p><p>T(n) = 2T(n/2) + O(n)</p><p>Since a = b, we apply Case 2 of the Master Theorem, which gives us:</p><p>T(n) = O(n^k log n) = O(n log n)</p><p>Therefore, the time complexity of Merge Sort is O(n log n). This means that as the input size n grows, the time required to sort the array grows at a rate proportional to n log n.</p><p><strong>Example: </strong>Let’s consider an example to illustrate the time complexity of Merge Sort. Suppose we have an array of 8 elements that we want to sort using Merge Sort:</p><p>[8, 4, 2, 7, 1, 5, 3, 6]</p><p>The algorithm will divide the array into two subarrays of size 4 each:</p><p>[8, 4, 2, 7] and [1, 5, 3, 6]</p><p>Then, it will recursively sort each subarray by dividing them into two sub-subarrays of size 2 each:</p><p>[8, 4] [2, 7] and [1, 5] [3, 6]</p><p>Then, it will recursively sort each sub-subarray by dividing them into two sub-sub-subarrays of size 1 each:</p><p>[8] [4] [2] [7] and [1] [5] [3] [6]</p><p><em>At this point, each sub-subarray is sorted, and the algorithm will start merging them back together</em>. It will merge the two sub-subarrays [8] and [4] into the subarray [4, 8], and it will merge the two sub-subarrays [2] and [7] into the subarray [2, 7], and so on. The merged subarrays are then merged again into larger subarrays until the entire array is sorted.</p><p>The merging process takes linear time, which means that the time required to merge two subarrays of size n/2 is proportional to n. In our example, each merge operation will take the following time:</p><p>Merging two subarrays of size 1: O(2) = O(1) Merging two subarrays of size 2: O(4) = O(2) Merging two subarrays of size 4: O(8) = O(4)</p><p>Since there are log n levels of recursion, each level of the recursion tree takes O(n) time for merging the subarrays. Therefore, the total time complexity of Merge Sort for an array of size n is:</p><p>T(n) = O(n log n)</p><p>In our example, the array has size 8, so the time complexity of Merge Sort is:</p><p>T(8) = O(8 log 8) = O(24)</p><p>Therefore, the time required to sort this array using Merge Sort is proportional to 24 operations. This illustrates how Merge Sort’s time complexity grows at a rate proportional to n log n, which is much faster than other sorting algorithms that have a quadratic time complexity, such as Bubble Sort or Selection Sort.</p><p><strong>Merge Sort Use Cases: </strong>Merge Sort is a highly efficient sorting algorithm that can be used in a variety of situations. Some possible use cases for Merge Sort include:</p><ol><li><strong>Sorting large data sets</strong>: Merge Sort’s time complexity of O(n log n) makes it a great choice for sorting large data sets. It is efficient enough to handle large data sets without causing performance issues.</li><li><strong>Stable sorting</strong>: Merge Sort is a stable sorting algorithm, which means that it maintains the relative order of equal elements in the sorted output. This is particularly useful in cases where you want to sort data based on multiple criteria.</li><li><strong>External sorting</strong>: Merge Sort is often used for external sorting, which involves sorting data sets that are too large to fit into memory. External sorting is common in databases, where sorting is often required on disk-resident data.</li><li><strong>Parallel processing</strong>: Merge Sort is a good candidate for parallel processing because it is easy to split the data set into smaller subarrays and sort them in parallel. This can help to speed up the sorting process when dealing with very large data sets.</li><li><strong>Pre-sorting</strong>: Merge Sort is often used as a pre-sorting algorithm in other sorting algorithms, such as Quick Sort. This is because Merge Sort can efficiently sort small subarrays, which reduces the overhead of the recursive calls in Quick Sort.</li></ol><p><strong>Time and Space Complexity:</strong></p><ol><li>The <strong>time complexity</strong> of the divide step is O(logn) because the array is divided in half each time. The merge step takes O(n) time because each element of the two subarrays needs to be compared and merged. Therefore, the total time complexity of the algorithm is O(nlogn).</li><li>The <strong>space complexity </strong>of Merge Sort is O(n) because it creates temporary arrays during the merge step to store the sorted elements before copying them back to the original array. This additional space requirement can be a disadvantage in situations where memory usage is a concern.</li></ol><p>Happy Learning !! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=547e05d5c607" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RESTful Web Service, and how it differs with other web services like SOAP.]]></title>
            <link>https://medium.com/@gaganjain9319/power-of-restful-web-service-and-how-it-differs-with-other-web-services-like-soap-d722a5a36687?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/d722a5a36687</guid>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Sat, 18 Mar 2023 09:41:41 GMT</pubDate>
            <atom:updated>2023-03-19T06:07:55.984Z</atom:updated>
            <content:encoded><![CDATA[<p>RESTful web services have become the de-facto standard for building APIs due to their simplicity, flexibility, and scalability. Here are some of the key features that make RESTful web services powerful:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HxTFTk_6uoP_uxlN7ZIZkg.png" /></figure><ol><li><strong>Stateless Architecture</strong>: RESTful web services are stateless, meaning that each request is independent of previous requests. This makes them highly scalable and allows them to handle a large number of concurrent requests without the need for maintaining session state.</li><li><strong>Resource-Based</strong>: RESTful web services are based on resources, which can be anything that can be identified by a unique URI, such as a user, a product, or an order. Each resource can be accessed using a specific set of HTTP methods, such as GET, POST, PUT, and DELETE, making it easy to interact with the API.</li><li><strong>Uniform Interface</strong>: RESTful web services have a uniform interface that consists of four constraints: identification of resources; manipulation of resources through representations; self-descriptive messages; and hypermedia as the engine of application state (HATEOAS). This allows clients to interact with the API using a standard set of HTTP methods and media types, making it easy to understand and use.</li><li><strong>Platform-Independent</strong>: RESTful web services are platform-independent, meaning that they can be accessed from any device or platform that supports HTTP and can understand the representation format of the response, such as JSON or XML.</li><li><strong>Cacheable</strong>: RESTful web services support caching, which can improve performance by reducing the number of requests to the server. This allows clients to store the response to a request locally and use it for subsequent requests, reducing the load on the server.</li><li><strong>Layered System</strong>: RESTful web services are designed to be a layered system, meaning that each layer is independent of the other layers, making it easy to modify or update a single layer without affecting the entire system.</li><li><strong>Easy to Test</strong>: RESTful web services are easy to test, as each resource can be accessed using a specific URI and HTTP method, making it easy to write automated tests.</li><li><strong>Security</strong>: RESTful web services provide security features, such as encryption and authentication, to ensure that sensitive data is protected and only authorized users can access the API.</li></ol><p>Overall, the power of RESTful web services lies in their simplicity, flexibility, and scalability, making them an ideal choice for building APIs that can be easily accessed and integrated with other applications.</p><p><strong>Hidden Features of RESTful:</strong></p><p>There are several hidden features of RESTful web services that developers can leverage to improve the functionality and efficiency of their APIs. Here are a few examples:</p><p>1. <strong>HATEOAS </strong>(Hypermedia as the Engine of Application State) is a constraint of the REST architectural style that allows the API to provide links to related resources in the response. This makes it easier for clients to navigate the API without hardcoding URLs, and enables the server to change the API’s structure without breaking existing clients. Here’s an example of HATEOAS in action:</p><p>Suppose we have a RESTful API for a bookstore. A request to the API might return a response like this:</p><pre>{<br>    &quot;title&quot;: &quot;The Hitchhiker&#39;s Guide to the Galaxy&quot;,<br>    &quot;author&quot;: &quot;Douglas Adams&quot;,<br>    &quot;published&quot;: &quot;1979-10-12&quot;,<br>    &quot;links&quot;: [<br>        {<br>            &quot;rel&quot;: &quot;self&quot;,<br>            &quot;href&quot;: &quot;/books/42&quot;<br>        },<br>        {<br>            &quot;rel&quot;: &quot;author&quot;,<br>            &quot;href&quot;: &quot;/authors/Adams&quot;<br>        },<br>        {<br>            &quot;rel&quot;: &quot;similar&quot;,<br>            &quot;href&quot;: &quot;/books?similarTo=42&quot;<br>        },<br>        {<br>            &quot;rel&quot;: &quot;reviews&quot;,<br>            &quot;href&quot;: &quot;/books/42/reviews&quot;<br>        }<br>    ]<br>}</pre><p>In this example, the response includes links to related resources such as the author of the book, other books similar to this book, and the reviews of the book. The links have a “rel” attribute that describes the relationship between the current resource and the linked resource, and a “href” attribute that provides the URL for the linked resource.</p><p>By including these links in the response, the client can navigate the API without having to know the URL structure ahead of time. For example, if the client wants to see the reviews for the book, they can follow the “reviews” link instead of having to construct the URL themselves. This makes the API more flexible and easier to use, and allows the server to evolve the API without breaking existing clients.</p><p>2. <strong>Content Negotiation</strong>: Content Negotiation is a feature of RESTful APIs that allows clients to request data in different formats using the Accept header. This allows the API to provide different representations of the same resource, based on client preferences. Here&#39;s an example:<br>Suppose we have a RESTful API that returns information about a user’s profile. A request to the API might look like this:</p><pre>GET /users/12345 HTTP/1.1<br>Accept: application/json</pre><p>In this example, the client is requesting information about the user with ID 12345, and is specifying that it wants the response in JSON format using the Accept header.</p><p>If the server supports multiple representations of the same resource, it can use content negotiation to provide the appropriate format based on the client&#39;s request. For example, the server might provide JSON and XML representations of the user&#39;s profile, and the client can choose which one to use by specifying the appropriate Accept header.</p><p>Here&#39;s an example of how the server might respond to the client&#39;s request using content negotiation:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br><br>{<br>    &quot;id&quot;: 12345,<br>    &quot;name&quot;: &quot;John Doe&quot;,<br>    &quot;email&quot;: &quot;johndoe@example.com&quot;<br>}</pre><p>In this example, the server has provided the user&#39;s profile information in JSON format, as requested by the client. If the client had specified a different Accept header, such as Accept: application/xml, the server could have provided the user&#39;s profile information in XML format instead.</p><p>By using content negotiation, RESTful APIs can provide flexible representations of resources that can be tailored to the needs of different clients. This can help to improve the performance and usability of the API, and make it easier to integrate with other systems.</p><p>3. <strong>Caching</strong>: Caching is an important aspect of RESTful APIs as it can significantly improve the performance and scalability of the system. Caching is the process of storing a response from a server temporarily so that the same response can be used again if requested within a certain period of time.</p><p>Here is an example of caching in a RESTful API:</p><p>Suppose we have an endpoint GET /products that returns a list of all products. This endpoint can be quite expensive in terms of resources and time, especially if the number of products is very large. To improve performance, we can add caching to this endpoint.</p><p>To implement caching, we can add an HTTP cache control header to the response of the GET /products endpoint. The cache control header specifies the duration for which the response can be cached by the client. For example, we can set the cache control header to:</p><pre>Cache-Control: max-age=3600</pre><p>This header tells the client to cache the response for a maximum of 3600 seconds (1 hour). The client can use the cached response for subsequent requests to the same endpoint within the cache lifetime period.</p><p>If a client requests the GET /products endpoint within the cache lifetime period, the client can use the cached response instead of making a new request to the server. This can significantly reduce the server load and improve the performance of the system.</p><p>However, if a client requests the GET /products endpoint after the cache lifetime period has expired, the client must make a new request to the server, and the server will return a fresh response.</p><p>Note that caching is only suitable for endpoints that return data that does not change frequently. If an endpoint returns data that changes frequently, caching can lead to stale data being returned to the client, which can be confusing and misleading.</p><p>In summary, caching is an effective technique to improve the performance and scalability of RESTful APIs. By adding cache control headers to the response, clients can use cached responses for subsequent requests, reducing the server load and improving the overall performance of the system.</p><p>4. <strong>Conditional Requests</strong>: Conditional requests are a technique used in RESTful APIs to reduce unnecessary network traffic by allowing clients to request resources only if they have been modified since the last time they were requested. This technique is based on HTTP headers that specify the conditions under which the client is willing to accept the requested resource.</p><p>Here is an example of conditional requests in a RESTful API:</p><p>Suppose we have an endpoint GET /products/{id} that returns a specific product with the given ID. To implement conditional requests, we can add the following headers to the request:</p><ol><li>If-Modified-Since: This header specifies the date and time of the last time the client received the resource. The server will only return the resource if it has been modified since this date and time.</li><li>If-None-Match: This header specifies the ETag (entity tag) of the last response received by the client. The server will only return the resource if its ETag has changed since the last time the client received it.</li></ol><p>If the resource has not been modified since the last time the client requested it, the server will return a 304 Not Modified response with an empty body. This tells the client that it can use the cached response it already has. If the resource has been modified, the server will return the new version of the resource with a 200 OK response.</p><p>Here’s an example of a request with conditional headers:</p><pre>GET /products/123 HTTP/1.1<br>Host: example.com<br>If-Modified-Since: Tue, 15 Feb 2022 10:00:00 GMT<br>If-None-Match: &quot;abc123&quot;</pre><p>In this example, the client is requesting the product with ID 123. It includes the If-Modified-Since header with a date and time indicating the last time the resource was received. It also includes the If-None-Match header with the ETag of the last response received. If the resource has not been modified since the last time it was received, the server will return a 304 Not Modified response. Otherwise, it will return the new version of the resource.</p><p>Conditional requests are an effective technique to reduce unnecessary network traffic and improve the performance of RESTful APIs. By using conditional headers, clients can request resources only when they have been modified, reducing the load on the server and improving the overall performance of the system.</p><p>5. <strong>Pagination</strong>: Pagination is a technique used in RESTful APIs to limit the number of results returned by an endpoint and provide a way for clients to navigate large sets of data. It involves breaking up the results into smaller, more manageable chunks, or pages, and returning only a subset of the results with each request.</p><p>Here is an example of pagination in a RESTful API:</p><p>Suppose we have an endpoint GET /products that returns a list of all products. To implement pagination, we can add query parameters to this endpoint to specify the page number and the number of results per page:</p><pre>GET /products?page=2&amp;per_page=10</pre><p>In this example, the client is requesting the second page of results with 10 results per page. The server will return the second set of 10 results.</p><p>The server can also include additional information in the response, such as the total number of results and the number of pages, to help the client navigate the results:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br>Link: &lt;http://example.com/products?page=1&amp;per_page=10&gt;; rel=&quot;first&quot;,<br>      &lt;http://example.com/products?page=3&amp;per_page=10&gt;; rel=&quot;next&quot;,<br>      &lt;http://example.com/products?page=10&amp;per_page=10&gt;; rel=&quot;last&quot;<br>{<br>  &quot;total&quot;: 100,<br>  &quot;per_page&quot;: 10,<br>  &quot;current_page&quot;: 2,<br>  &quot;last_page&quot;: 10,<br>  &quot;data&quot;: [<br>    { &quot;id&quot;: 11, &quot;name&quot;: &quot;Product 11&quot; },<br>    { &quot;id&quot;: 12, &quot;name&quot;: &quot;Product 12&quot; },<br>    ...<br>    { &quot;id&quot;: 20, &quot;name&quot;: &quot;Product 20&quot; }<br>  ]<br>}</pre><p>In this example, the server includes a Link header with links to the first, next, and last pages of results. The response also includes the total number of results, the number of results per page, the current page, and the last page. The data field contains the actual results for the requested page.</p><p>Pagination is a useful technique for managing large sets of data in RESTful APIs. By breaking up the results into smaller pages and providing links and metadata, clients can easily navigate the results and find the information they need.</p><p>6. <strong>Partial Updates</strong>: Partial updates, also known as PATCH requests, are a common technique used in RESTful APIs to update only specific fields of a resource instead of replacing the entire resource. This technique reduces network traffic and improves performance by allowing clients to send only the data that needs to be updated.</p><p>Here is an example of a partial update in a RESTful API:</p><p>Suppose we have an endpoint PATCH /products/{id} that updates a specific product with the given ID. To implement a partial update, the client can send a JSON object with the fields to be updated:</p><pre>PATCH /products/123 HTTP/1.1<br>Host: example.com<br>Content-Type: application/json<br>{<br>  &quot;name&quot;: &quot;New Product Name&quot;,<br>  &quot;price&quot;: 9.99<br>}</pre><p>In this example, the client is updating the name and price fields of the product with ID 123. The server will update only these fields, leaving the other fields unchanged.</p><p>The server can also include a response with the updated fields:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br>{<br>  &quot;id&quot;: 123,<br>  &quot;name&quot;: &quot;New Product Name&quot;,<br>  &quot;description&quot;: &quot;Product Description&quot;,<br>  &quot;price&quot;: 9.99,<br>  &quot;created_at&quot;: &quot;2022-03-18T15:28:00Z&quot;,<br>  &quot;updated_at&quot;: &quot;2022-03-18T16:05:00Z&quot;<br>}</pre><p>In this example, the server includes the updated fields of the product in the response.</p><p>Partial updates are a useful technique for updating resources in RESTful APIs without sending unnecessary data. By allowing clients to send only the data that needs to be updated, partial updates can reduce network traffic and improve performance.</p><p>7. <strong>Versioning</strong>: Versioning is a technique used in RESTful APIs to manage changes to the API over time. It involves creating different versions of the API to handle changes in the data model, business logic, or client requirements without breaking existing clients.</p><p>Here is an example of versioning in a RESTful API:</p><p>Suppose we have an endpoint GET /products that returns a list of all products. To version this endpoint, we can add a version number to the URL:</p><pre>GET /v1/products</pre><p>In this example, the client is requesting version 1 of the products endpoint.</p><p>Suppose we need to make a change to the API by adding a new field to the product resource. To avoid breaking existing clients that rely on the old version of the API, we can create a new version of the endpoint:</p><pre>GET /v2/products</pre><p>In this example, version 2 of the products endpoint includes the new field.</p><p>Clients can choose which version of the API to use by specifying the version number in the URL or in the request headers. For example, a client can request version 2 of the API by sending a request like this:</p><pre>GET /products HTTP/1.1<br>Host: example.com<br>Accept: application/json;version=2</pre><p>In this example, the client is requesting version 2 of the products endpoint by setting the Accept header to application/json;version=2.</p><p>Versioning is a useful technique for managing changes to RESTful APIs over time. By creating different versions of the API, developers can make changes without breaking existing clients and give clients control over which version of the API to use.</p><p><strong>SOAP vs RESTful: </strong>SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are two different architectural styles used for building web services. Both of them can be used to achieve similar goals, but there are some significant differences between the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*m2L5WaEYvb9pIyQoGOPpaA.png" /><figcaption>Image Reference: phoenixnap</figcaption></figure><p>Here are some key differences between SOAP and REST:</p><ol><li><strong>Protocol</strong>: SOAP is a messaging protocol that uses XML for communication, while REST is an architectural style that uses a simpler, lightweight approach to communication, typically using JSON or XML.</li><li><strong>Messaging</strong>: SOAP uses a messaging format, which includes a request and response envelope, whereas REST uses a simple request-response model where data is transmitted directly over HTTP.</li><li><strong>WSDL</strong>: SOAP services use a WSDL (Web Services Description Language) file to describe the available operations and data types, while REST services use a human-readable documentation such as Swagger or OpenAPI to describe the API.</li><li><strong>Transport</strong>: SOAP can use any transport protocol, but most commonly uses HTTP or SMTP. REST relies exclusively on HTTP, and it uses the different HTTP methods (GET, POST, PUT, DELETE, etc.) to interact with resources.</li><li><strong>Flexibility</strong>: REST is more flexible than SOAP and can be used in a wider range of contexts, such as mobile devices, IoT devices, and web browsers, whereas SOAP is more suitable for complex enterprise applications that require strict security, transactional integrity, and reliability.</li><li><strong>Caching</strong>: REST provides better support for caching, which can help improve performance and reduce network traffic. SOAP messages are often too large to be cached efficiently.</li></ol><p>In summary, SOAP is a heavyweight, XML-based messaging protocol that is suited for complex enterprise applications, while REST is a lightweight, flexible architectural style that is better suited for simpler, more distributed systems. Both approaches have their strengths and weaknesses, and the choice between them depends on the specific requirements of the application being developed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d722a5a36687" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High Level Design (HLD) understanding with example (Part1).]]></title>
            <link>https://medium.com/@gaganjain9319/high-level-design-hld-understanding-with-example-part1-a2bb9a0b8826?source=rss-80019a39f783------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2bb9a0b8826</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[architects]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gagan Jain]]></dc:creator>
            <pubDate>Sat, 18 Mar 2023 06:41:57 GMT</pubDate>
            <atom:updated>2023-03-18T06:41:57.281Z</atom:updated>
            <content:encoded><![CDATA[<p>Designing a high-level design (HLD) for a software requires a broad understanding of the system’s architecture, functionality, and requirements. Here are some key things to consider when designing an HLD for a software:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*AsLocsy2g3h58vQy9t5zDQ.png" /><figcaption>HLD Breakdown: Image Ref: <a href="https://softwaredominos.com/home/software-design-development-articles/high-level-solution-design-documents-what-is-it-and-when-do-you-need-one/">softwaredominos</a></figcaption></figure><ol><li><strong>Understand the system requirements</strong>: Start by understanding the requirements of the system. This involves identifying the problem that the system is trying to solve, the stakeholders who will use the system, and the features that the system must have.</li><li><strong>Identify the major components</strong>: Identify the major components of the system and how they interact with each other. This involves defining the system architecture, which includes the major modules or subsystems and how they are connected.</li><li><strong>Define the data model</strong>: Define the data model for the system, which includes the types of data that the system will store, how the data will be organized, and how the data will be accessed and manipulated.</li><li><strong>Consider the system’s scalability</strong>: Consider the scalability of the system, which involves how the system will handle increasing levels of data and users over time. This includes defining the system’s capacity requirements and designing the system to handle future growth.</li><li><strong>Consider the system’s security</strong>: Consider the security of the system, which involves identifying potential security risks and designing the system to protect against them. This includes defining access controls, authentication mechanisms, and encryption requirements.</li><li><strong>Consider the system’s performance</strong>: Consider the performance of the system, which involves identifying potential bottlenecks and designing the system to perform efficiently. This includes defining the system’s response time requirements, throughput requirements, and load balancing mechanisms.</li><li><strong>Identify third-party components</strong>: Identify any third-party components that the system will use, such as APIs, libraries, and frameworks. This includes defining the integration points for these components and ensuring that they meet the system’s requirements.</li><li><strong>Create high-level architecture diagrams</strong>: Create high-level architecture diagrams that depict the major components of the system and how they interact with each other. This will help stakeholders understand the overall structure and functionality of the system.</li></ol><p>Overall, designing an HLD for a software requires a deep understanding of the system’s requirements and how its components will work together to solve the problem at hand. By considering scalability, security, performance, and other factors, you can design a system that meets the needs of its users and stakeholders.</p><p>High-level design (HLD) diagrams are visual representations of the system architecture and major components of a software system. They are typically used to provide an overview of the system’s structure and functionality and are useful for communicating with stakeholders and developers.</p><p><strong>Here are some common types of HLD diagrams</strong>:</p><ol><li><strong>Block diagrams</strong>: Block diagrams are used to depict the major components of the system and how they interact with each other. Each component is represented as a block, and the connections between the blocks show how they communicate with each other. For example, a block diagram for an e-commerce website might include blocks for the web server, application server, and database server, with arrows indicating the flow of data between them.</li><li><strong>Data flow diagrams</strong>: Data flow diagrams (DFDs) are used to show how data moves through the system. They are particularly useful for showing how data is processed and transformed by different components of the system. In a DFD, data is represented as a flow, with arrows showing how it moves through the system. For example, a DFD for an e-commerce website might show how product data is entered into the system, stored in the database, and displayed to users.</li><li><strong>Use case diagrams</strong>: Use case diagrams are used to show how users interact with the system. They are particularly useful for showing the system’s functionality from the perspective of the user. In a use case diagram, each use case (i.e. a specific interaction that a user can have with the system) is represented as an oval, with actors (i.e. users or other systems) represented as stick figures. For example, a use case diagram for an e-commerce website might include use cases for searching for products, adding products to a shopping cart, and checking out.</li><li><strong>Sequence diagrams</strong>: Sequence diagrams are used to show the interactions between different components of the system over time. They are particularly useful for showing the flow of data and control between different components of the system. In a sequence diagram, each component is represented as a rectangle, with arrows showing the flow of control and data between them. For example, a sequence diagram for an e-commerce website might show how a user’s request to purchase a product is processed by the web server, application server, and database server.</li></ol><p>Overall, HLD diagrams are a powerful tool for communicating the structure and functionality of a software system. By using different types of diagrams, you can provide a comprehensive overview of the system from different perspectives, helping stakeholders and developers understand the system’s architecture and behavior.</p><p><strong><em>Here is one example of high-level design (HLD) and its real-world application:</em></strong></p><p><strong>Yulu bike-sharing platform:</strong></p><p>2. <strong>User mobile app</strong>: The Yulu mobile app allows users to find and rent bikes, as well as manage their accounts and payments. The app has several features, including:</p><ul><li><strong><em>Bike map</em></strong>: This shows the locations of bike stations and the availability of bikes at each station.</li><li><strong><em>Bike rental</em></strong>: Users can reserve a bike using the app, which will hold the bike for a set amount of time until the user arrives to pick it up. The user can then unlock the bike using a QR code or Bluetooth connection.</li><li><strong><em>Payment</em></strong>: The app allows users to add payment details and pay for their rentals using a credit or debit card.</li><li><strong><em>Account management</em></strong>: Users can manage their account settings, view their rental history, and access support through the app.</li></ul><p>2. <strong>Bike stations</strong>: Yulu has designated bike stations throughout the city, where users can pick up and drop off bikes. Each station has a physical bike rack with designated spots for the bikes, as well as a kiosk with a touchscreen display that shows the station map and bike availability.</p><p>3. <strong>IoT-enabled bikes</strong>: Yulu bikes are equipped with IoT sensors that allow users to unlock the bike and track its location. The bikes have several features, including:</p><ul><li><strong><em>QR code lock</em></strong>: The bike has a QR code that users can scan using the Yulu app to unlock the bike.</li><li><strong><em>Bluetooth lock</em></strong>: The bike can also be unlocked using a Bluetooth connection to the user’s smartphone.</li><li><strong><em>GPS tracking</em></strong>: The bike has a GPS sensor that allows Yulu to track its location and ensure that it is returned to a designated bike station.</li><li><strong><em>Battery and diagnostics</em></strong>: The bike has a battery and sensors that can detect any issues with the bike’s performance, such as low tire pressure or a malfunctioning brake.</li></ul><p>4. <strong>Payment gateway</strong>: Yulu uses a payment gateway to process transactions for bike rentals. The payment gateway securely stores users’ payment information and processes transactions in real-time.</p><p>5. <strong>Maintenance and operations</strong>: Yulu manages bike maintenance, repair, and cleaning, as well as the operation of bike stations. This includes:</p><ul><li><strong><em>Routine maintenance</em></strong>: Yulu performs regular maintenance on the bikes, such as checking the brakes, tires, and chain.</li><li><strong><em>Repair</em></strong>: If a bike is damaged or needs repair, Yulu will take it out of service and perform the necessary repairs.</li><li><strong><em>Cleaning</em></strong>: Yulu cleans the bikes regularly to ensure that they are sanitary and in good condition.</li><li><strong><em>Bike station management</em></strong>: Yulu manages the placement and availability of bikes at each station, as well as the kiosks and other infrastructure at the stations.</li></ul><p>6. <strong>Analytics and data</strong>: Yulu collects data on bike usage and user behavior, which is used to optimize bike placement and improve the user experience. The data includes:</p><ul><li><strong><em>Bike usage</em></strong>: Yulu tracks the number of rentals, duration of rentals, and popular bike stations.</li><li><strong><em>User behavior</em></strong>: Yulu collects data on user demographics, rental history, and feedback.</li></ul><p>HLD diagrams will be covered in details in next article.</p><p>Thanks to visit :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2bb9a0b8826" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>