<?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 Vishal Mahto on Medium]]></title>
        <description><![CDATA[Stories by Vishal Mahto on Medium]]></description>
        <link>https://medium.com/@Vishal_28m?source=rss-4024ae7a96d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*N5FmxOXAWHuQuJ6W-GTUWw.png</url>
            <title>Stories by Vishal Mahto on Medium</title>
            <link>https://medium.com/@Vishal_28m?source=rss-4024ae7a96d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:49:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Vishal_28m/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[What is Factory Design pattern , Why do we need it , How can we implement in C++, What are the…]]></title>
            <link>https://medium.com/@Vishal_28m/what-is-factory-design-pattern-why-do-we-need-it-how-can-we-implement-in-c-what-are-the-788c9074386c?source=rss-4024ae7a96d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/788c9074386c</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[low-level-design]]></category>
            <dc:creator><![CDATA[Vishal Mahto]]></dc:creator>
            <pubDate>Wed, 06 Sep 2023 11:53:39 GMT</pubDate>
            <atom:updated>2023-09-06T11:53:39.953Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Factory Design pattern , Why do we need it , How can we implement in C++, What are the pros and cons of factory design pattern .</h3><p>What is the Factory Design Pattern?</p><p>Think of the Factory Design Pattern like a magical factory that makes toys. Imagine you love stuffed animals, and you want a new stuffed animal toy. Instead of making it yourself (which could be complicated), you visit the magical stuffed animal factory, tell them what kind of animal you want, and they give you the perfect toy without you needing to know how it was made.</p><p>Why do we need it?</p><p>Imagine you’re building a computer game where different types of monsters appear. You don’t want to create each monster manually because it’s time-consuming and error-prone. Instead, you can use the Factory Design Pattern to create monsters on demand. It makes your code more organized, maintainable, and flexible.</p><p>How can we implement it in C++?</p><p>Let’s say you want to create different shapes like circles and squares using the Factory Design Pattern in C++:</p><p>#include &lt;iostream&gt;</p><p>// The base Shape class<br>class Shape {<br>public:<br> virtual void draw() = 0;<br>};</p><p>// Concrete Circle class<br>class Circle : public Shape {<br>public:<br> void draw() override {<br> std::cout &lt;&lt; “Drawing a Circle.” &lt;&lt; std::endl;<br> }<br>};</p><p>// Concrete Square class<br>class Square : public Shape {<br>public:<br> void draw() override {<br> std::cout &lt;&lt; “Drawing a Square.” &lt;&lt; std::endl;<br> }<br>};</p><p>// The ShapeFactory class<br>class ShapeFactory {<br>public:<br> static Shape* createShape(const std::string&amp; shapeType) {<br> if (shapeType == “Circle”) {<br> return new Circle();<br> } else if (shapeType == “Square”) {<br> return new Square();<br> } else {<br> return nullptr; // Return null for unknown shapes<br> }<br> }<br>};</p><p>int main() {<br> Shape* shape1 = ShapeFactory::createShape(“Circle”);<br> shape1-&gt;draw();</p><p>Shape* shape2 = ShapeFactory::createShape(“Square”);<br> shape2-&gt;draw();</p><p>// Remember to delete the objects to avoid memory leaks<br> delete shape1;<br> delete shape2;</p><p>return 0;<br>}</p><p>In this example, the `ShapeFactory` is like the magical factory that creates shapes for you. You just tell it what type of shape you want, and it gives you the right object.</p><p>Pros and Cons:</p><p>Pros:</p><p>1. Flexibility:You can easily add new types of objects without changing existing code.<br>2. Encapsulation: The creation logic is separated from the client code, making it easier to manage and maintain.<br>3. Reusability: You can reuse the factory for creating similar objects throughout your program.<br>4. Code Organization: It makes your code more organized and readable.</p><p>Cons:</p><p>1. Complexity: In some cases, the Factory Pattern can add extra complexity to the code.<br>2. Increased Classes: It can lead to a higher number of classes if you have many different types of objects to create.</p><p>Remember, patterns are like tools in a programmer’s toolbox. You choose the right one based on the problem you’re trying to solve. The Factory Design Pattern is handy when you need to create objects without worrying about how they’re made, just like getting your favorite stuffed animal from a magical toy factory.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788c9074386c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Store Password in Database?]]></title>
            <link>https://medium.com/@Vishal_28m/how-to-store-password-in-database-382a47d3a3c?source=rss-4024ae7a96d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/382a47d3a3c</guid>
            <category><![CDATA[database-management]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Vishal Mahto]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 04:30:43 GMT</pubDate>
            <atom:updated>2023-09-03T04:30:43.546Z</atom:updated>
            <content:encoded><![CDATA[<p>Storing passwords securely in a database is crucial for protecting user data. You should never store passwords in plain text, as this can lead to security vulnerabilities. Instead, you should follow best practices for password storage, which typically involve using a combination of hashing and salting. Here’s a step-by-step guide on how to securely store passwords in a database:</p><p>1. Hashing:<br> — Choose a strong, cryptographic hashing algorithm such as bcrypt, scrypt, or Argon2. These algorithms are designed to be slow and computationally intensive, making it difficult for attackers to brute-force passwords.<br> — Hash the user’s password using the selected algorithm. This process converts the password into a fixed-length string of characters, which is typically a hash value.</p><p>2. Salting:<br> — Generate a random and unique salt value for each user. A salt is a random string that is combined with the user’s password before hashing. This ensures that even if two users have the same password, their hashed passwords will be different due to the unique salt.</p><p>3. Hash and Store:<br> — Combine the user’s password and salt, then hash the result using the selected algorithm.<br> — Store the hashed password and the salt in your database.</p><p>4. Verification:<br> — When a user attempts to log in, retrieve their stored salt and hashed password from the database using their username or ID.<br> — Combine the entered password with the retrieved salt and hash it.<br> — Compare the generated hash with the stored hashed password. If they match, the entered password is correct.</p><p>By following these steps, you can securely store passwords in your database, protecting user data from potential breaches. Additionally, make sure to keep your database secure and apply other security best practices to safeguard user information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=382a47d3a3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Kafka is Fast?]]></title>
            <link>https://medium.com/@Vishal_28m/why-kafka-is-fast-1bea8f643046?source=rss-4024ae7a96d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bea8f643046</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Vishal Mahto]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 10:47:12 GMT</pubDate>
            <atom:updated>2023-08-31T10:47:12.527Z</atom:updated>
            <content:encoded><![CDATA[<p>Kafka is considered fast primarily due to its architectural design and the specific optimizations it employs. Here are some key reasons why Kafka is fast:</p><p>1. Distributed Architecture: Kafka is built with a distributed architecture that allows it to horizontally scale across multiple servers or nodes. This enables Kafka to handle large amounts of data and throughput by distributing the workload.</p><p>2. Partitioning: Kafka topics are divided into partitions, and each partition is distributed across different brokers. This allows Kafka to parallelize read and write operations, leading to increased throughput and reduced latency.</p><p>3. Write Optimizations: Kafka optimizes write operations by appending new data to the end of each partition. This sequential write pattern is more efficient than random writes and helps to minimize disk seeks, enhancing overall write performance.</p><p>4. Batching: Kafka is capable of batching multiple messages together before writing them to a partition. This batching mechanism reduces the overhead of individual write operations, resulting in improved throughput.</p><p>5. Replication: Kafka supports replication of data across multiple brokers, ensuring data durability and fault tolerance. This replication also allows for distributed reading of data, which contributes to faster data access.</p><p>6. Zero-Copy: Kafka uses a zero-copy approach, which means that data is not duplicated in memory when being transferred between processes or components. This reduces CPU and memory overhead, leading to improved performance.</p><p>7. Disk Storage: Kafka uses an efficient storage mechanism that involves segmenting data files and using an index to locate messages quickly. This design helps in optimizing disk I/O operations.</p><p>8. Data Compression: Kafka supports data compression, which reduces the amount of data that needs to be transferred between producers and brokers, as well as between brokers and consumers. This leads to better network utilization and overall performance.</p><p>9. Caching: Kafka employs caching mechanisms to store frequently accessed metadata and intermediate results. This reduces the need for repeated disk access, enhancing response times.</p><p>10. Async Communication: Kafka’s producers and consumers communicate asynchronously with the brokers, enabling higher levels of parallelism and improving overall performance by reducing wait times.</p><p>11. Tuning Options: Kafka provides various configuration options that allow users to fine-tune the system according to their specific use cases and performance requirements. This flexibility enables optimization for different workloads.</p><p>12. Community Contributions: Kafka benefits from a large and active open-source community. This means that performance enhancements and optimizations are continuously being developed and shared by the community, contributing to Kafka’s overall speed and efficiency.</p><p>It’s important to note that while Kafka offers inherent performance advantages due to its design, achieving optimal performance also depends on proper configuration, hardware resources, network setup, and data access patterns specific to each use case.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bea8f643046" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>