<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Rishav Kapil</title>
    <description>The latest articles on Forem by Rishav Kapil (@rishavkapil24).</description>
    <link>https://forem.com/rishavkapil24</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2379552%2Fdfe96e5b-5aa3-4e58-b8f7-43c7894d041a.png</url>
      <title>Forem: Rishav Kapil</title>
      <link>https://forem.com/rishavkapil24</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rishavkapil24"/>
    <language>en</language>
    <item>
      <title>Hard Delete vs Soft Delete in DBMS.</title>
      <dc:creator>Rishav Kapil</dc:creator>
      <pubDate>Tue, 10 Dec 2024 16:32:53 +0000</pubDate>
      <link>https://forem.com/rishavkapil24/hard-delete-vs-soft-delete-in-dbms-8lb</link>
      <guid>https://forem.com/rishavkapil24/hard-delete-vs-soft-delete-in-dbms-8lb</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/rishavkapil24" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2379552%2Fdfe96e5b-5aa3-4e58-b8f7-43c7894d041a.png" alt="rishavkapil24"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rishavkapil24/hard-delete-vs-soft-delete-in-dbms-7np" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Hard Delete Vs Soft Delete in DBMS&lt;/h2&gt;
      &lt;h3&gt;Rishav Kapil ・ Dec 10&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#dbms&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#database&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Hard Delete Vs Soft Delete in DBMS</title>
      <dc:creator>Rishav Kapil</dc:creator>
      <pubDate>Tue, 10 Dec 2024 12:16:01 +0000</pubDate>
      <link>https://forem.com/rishavkapil24/hard-delete-vs-soft-delete-in-dbms-7np</link>
      <guid>https://forem.com/rishavkapil24/hard-delete-vs-soft-delete-in-dbms-7np</guid>
      <description>&lt;p&gt;When working with databases, we often need to remove records. There are two common approaches for deletion: hard delete and soft delete. Let’s explore these concepts in simple terms with a real-world example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hard Delete
&lt;/h2&gt;

&lt;p&gt;A hard delete means permanently removing a record from the database. &lt;br&gt;
   Once deleted, the data is gone forever and cannot be retrieved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example:&lt;/strong&gt;&lt;br&gt;
Imagine you have an email inbox. If you delete an email and then empty your trash folder, that email is permanently removed. You cannot restore it anymore. This is an example of a hard delete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works in a Database:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you perform a hard delete, the database removes the record completely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM Users WHERE id = 101;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query deletes the user with ID 101 from the Users table, and the data is no longer available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Soft Delete
&lt;/h2&gt;

&lt;p&gt;A soft delete means marking a record as deleted without actually removing it from the database. This allows you to "restore" the record later if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think about your recycle bin on a computer. When you delete a file, it goes into the recycle bin instead of being permanently erased. You can still recover the file until you permanently delete it from the recycle bin. This is similar to a soft delete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works in a Database:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of removing the record, we add a flag (usually a column like is_deleted) to mark it as deleted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE Users SET is_deleted = 1 WHERE id = 101;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The record is still in the database, but the is_deleted column indicates it should not be shown in normal operations.&lt;/p&gt;

&lt;p&gt;To retrieve only active records, you add a condition in your query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM Users WHERE is_deleted = 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to Use Hard Delete&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the data is no longer needed.&lt;/li&gt;
&lt;li&gt;For sensitive data that must be permanently erased (e.g., user passwords).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to Use Soft Delete&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you want to maintain a history of data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For audit logs or when users can undo deletions (e.g., social media posts).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dbms</category>
      <category>programming</category>
      <category>database</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Method Chaining in C++</title>
      <dc:creator>Rishav Kapil</dc:creator>
      <pubDate>Mon, 18 Nov 2024 08:41:31 +0000</pubDate>
      <link>https://forem.com/rishavkapil24/method-chaining-in-c-254a</link>
      <guid>https://forem.com/rishavkapil24/method-chaining-in-c-254a</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What is method chaining ?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Method chaining is a programming technique where multiple method calls are executed sequentially on the same object, all in a single statement. Each method in the chain returns the object itself (usually *this), allowing the next method to be called on the same object without needing to reference it again.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;To enable method chaining:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Methods should return a reference to the object they belong to (typically *this in C++).&lt;/li&gt;
&lt;li&gt;Each method can then be called on the returned reference, forming a chain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lets take an example of "Rectangle class"..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Rectangle{
    public:
    int length;
    int width;
    string color;
    Rectangle(int set_length , int set_width , string set_color){
        length = set_length;
        width = set_width;
        color = set_color;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void print()
    {
        cout &amp;lt;&amp;lt; "Lenght : "  &amp;lt;&amp;lt; length &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; "Width : " &amp;lt;&amp;lt; width &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; "Colour : " &amp;lt;&amp;lt; color &amp;lt;&amp;lt; endl;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rectangle&amp;amp; setColor(string set_color){
        color = set_color;
        return *this;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rectangle&amp;amp; setLength(int set_length){
        length = set_length;
        return *this;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;};&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int main()
{
    Rectangle r1(4,5,"red");
    r1.setColor("orange").setLength(10);
    r1.print();
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;without method chaining we have to repeat the object like&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;object1.method1();&lt;br&gt;
object1.method2();&lt;br&gt;
object1.method3();&lt;/p&gt;

&lt;p&gt;here the object is getting repeated again and again but with the help of method chaining we can resolve this issue &lt;/p&gt;

&lt;p&gt;&lt;em&gt;with method chaining&lt;/em&gt;&lt;br&gt;
object1.method1().method2().method3()&lt;/p&gt;

&lt;p&gt;here when the method1 is executed it will return the object itself which will help in the execution of method2 and so on.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope you got my point :)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>oop</category>
      <category>programming</category>
      <category>this</category>
    </item>
    <item>
      <title>Understanding Constructors in C++: A Complete Guide for Beginners</title>
      <dc:creator>Rishav Kapil</dc:creator>
      <pubDate>Fri, 08 Nov 2024 03:40:41 +0000</pubDate>
      <link>https://forem.com/rishavkapil24/understanding-constructors-in-c-a-complete-guide-for-beginners-1f32</link>
      <guid>https://forem.com/rishavkapil24/understanding-constructors-in-c-a-complete-guide-for-beginners-1f32</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In C++, constructors are special functions that allow for efficient and controlled initialization of objects. They provide a way to assign initial values when an object is created, making them a crucial part of object-oriented programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Constructor in C++?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A constructor is a unique member function automatically called when an object of a class is created. It has the same name as the class and doesn’t return a value. Constructors are essential for setting up initial values or allocating resources at the time of object creation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Constructors in C++&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Default Constructor&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A default constructor is one that takes no arguments. If no constructor is defined, C++ automatically provides a default constructor. If we make another constructor then default constructor is automatically removed and if we want to use the functionalities of default constructor then we have to make a new default constructor. Below is the code of default constructor in C++&lt;/p&gt;

&lt;p&gt;class Car {&lt;br&gt;
public:&lt;br&gt;
    int speed;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Default constructor
Car() {
    speed = 0;
    std::cout &amp;lt;&amp;lt; "Default constructor called, speed set to 0." &amp;lt;&amp;lt; std::endl;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;int main() {&lt;br&gt;
    Car myCar;  // Default constructor called&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Parameterized Constructor&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A parameterized constructor allows passing values to initialize an object. A class can have multiple parameterized constructors but with different parameters and if are passing the same parameters than the order of that parameters should be different. Below is the code of parameterized constructor.&lt;/p&gt;

&lt;p&gt;class Car {&lt;br&gt;
public:&lt;br&gt;
    int speed;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Parameterized constructor
Car(int s) {
    speed = s;
    std::cout &amp;lt;&amp;lt; "Parameterized constructor called, speed set to " &amp;lt;&amp;lt; speed &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; std::endl;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;int main() {&lt;br&gt;
    Car myCar(100);  // Parameterized constructor called&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Copy Constructor&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The copy constructor initializes a new object as a copy of an existing object. In this, we pass object as the parameter to the constructor. Below is the code of copy constructor in C++.&lt;/p&gt;

&lt;p&gt;class Car {&lt;br&gt;
public:&lt;br&gt;
    int speed;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Copy constructor
Car(const Car &amp;amp;c) {
    speed = c.speed;
    std::cout &amp;lt;&amp;lt; "Copy constructor called, speed copied: " &amp;lt;&amp;lt; speed &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; std::endl;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;int main() {&lt;br&gt;
    Car myCar(120);&lt;br&gt;
    Car anotherCar = myCar;  // Copy constructor called&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Constructors are the backbone of C++ class initialization, providing flexible ways to create and configure objects. By understanding the types of constructors and best practices, you can write more efficient and robust code in C++.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>oop</category>
      <category>constructors</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
