Posts

NoSQL and SQL Data Formats: A Comprehensive Guide for Students and Professionals

Image
Introduction to SQL and SQL Data Formats SQL, which stands for Structured Query Language, is the foundation of relational databases. It is the standard language for querying and managing data in systems that rely on structured, tabular data. Data is stored in tables with rows and columns in SQL databases, such as MySQL, PostgreSQL, and Oracle. These databases use a Schema-on-write approach, meaning the structure of the data is defined and enforced before data is inserted into the system. SQL databases rely on well-defined schemas to ensure data consistency and integrity. They adhere to ACID principles—Atomicity, Consistency, Isolation, and Durability—which guarantees that transactions are processed reliably. For instance, in a banking system where every transaction must be recorded accurately, SQL databases are ideal because they ensure that every deposit, withdrawal, or transfer is handled securely and consistently. Understanding NoSQL and NoSQL Data Formats NoSQL stands for “...

Understanding Partial Template Specialization In C++

Image
Partial template specialization is a nuanced feature in C++ that allows developers to customize class templates for specific categories of template arguments. This capability enhances code flexibility and efficiency by enabling tailored behavior for particular data types or conditions. Understanding Partial Template Specialization In C++, templates provide a mechanism for writing generic and reusable code. A class template serves as a blueprint for a class that can handle various data types. However, there are scenarios where the default implementation may not be optimal or applicable for certain types. Partial template specialization addresses this by allowing the customization of the template for specific types or conditions, without necessitating a complete overhaul of the original template. Syntax of Partial Template Specialization The general syntax for a partially specialized class template is as follows: template <typename T1, typename T2> class ClassName { ...

System Design Basics || Latency vs Response Times

Image
  When it comes to measuring the performance of systems, especially in networking and software engineering, the terms "latency" and "response time" are often used interchangeably. However, these terms have distinct meanings, and understanding their differences is essential for optimizing system performance and troubleshooting effectively.  What is Latency? Latency refers to the time it takes for a single data packet to travel from the source to its destination. It is the delay introduced by the system—be it due to network transmission, processing time, or other factors. In simpler terms, latency measures the delay between the moment a request is made and when it begins to be processed. Latency is often measured in milliseconds (ms). Example of Latency: Imagine you send a request to load a webpage. The latency is the time it takes for the initial request to travel from your computer to the server hosting the webpage. In the video, the example of a video confere...

Software Design Basics || Fault vs Failure

Image
In software engineering, terms like "fault" and "failure" are fundamental, yet they are often misunderstood or used interchangeably. Grasping the difference between these concepts is crucial for developing reliable software and effectively troubleshooting issues. Let’s delve into these terms, enriched with insights from the referenced video, to clarify their meanings and implications. What is a Fault? A fault refers to an incorrect step, process, or data definition in a computer program. It is essentially a flaw in the system's code or design that has the potential to cause the software to operate incorrectly. Faults are often introduced during the development phase and may remain undetected until they are triggered under specific conditions. Example of a Fault: Consider a function designed to calculate the average of a list of numbers: def calculate_average(numbers): return sum(numbers) / len(numbers) If the input list is empty, this code will resu...

C++ Condition Variable

Image
Sharing the code which demonstrates synchronization between two threads. Two threads execute interchangeably, all thanks to the condition variable. I have also shared the code execution output   Check out the Video: #include <iostream> #include <thread> #include <mutex> #include <condition_variable> using namespace std; mutex m; condition_variable cnd; int previousThreadId; void print(int threadID) { for (size_t i = 0; i < 20; i++) { unique_lock<std::mutex> ul(m); //->Threads Waiting Zone cnd.wait(ul, [&]()->bool {    if (threadID != previousThreadId) return true; else return false; }); previousThreadId = threadID; cout << "\nThread # " << threadID << " Executing..."; cout << "\nPrinting  : " << i<< "\n"; ul.unlock(); cnd.notify_one(); } } int main() { thread t[2]; for (size_t i = 0; i < 2; i++) { t[i] = th...

Unveiling Function Hiding in C++: Why Polymorphism Isn’t Parameter-Dependent?

Image
Function Hiding in C++: Understanding the Hidden Layers When working with C++, you’ve likely encountered situations where functions behave unexpectedly due to name collisions, inheritance, or ambiguous scope resolution. This phenomenon, function hiding , is a common challenge for developers. In this post, we’ll break down the mechanics of function hiding, explore its implications in object-oriented programming, and clarify why C++ does not support polymorphism for functions that differ only by their parameters . Let’s dive into function hiding and uncover the key aspects you need to know. What is Function Hiding in C++? Function hiding occurs when a derived class defines a member function with the same name as a function in its base class. In this case, the function in the derived class hides the function in the base class, regardless of their parameter lists or signatures. This behavior can confuse developers who expect polymorphism to handle calls to functions with the sam...

Making Sense of std::variant in C++: An Introductory Perspective on Holding Different Types of Values

Image
The problem of variance in C++ variables that may take on multiple values of different data types is resolved using various mechanisms, such as std::variant , a new C++ feature in C++17. For this feature, a variable can possess a value of several types, but not more than one type at a time. In this article, welcome to the world of std::variant, and learn how it is used alongside some other useful elements like std::monostate which extend its capabilities. So let’s begin. What is std::variant? In C++, std::variant replaces the traditional union’ with a typesafe union holder which holds one of a predefined set of types. std::variantoffers the extra advantage of keeping the type that is currently held, unlikeunion’ which doesn’t keep track of its active type very handy in instances where a type will be constantly changing. suggested reads : CRTP in C++ , placement new  , memory management in C++ Declaring a Variant in C++ To de...