Skip to main content

Posts

Showing posts from August, 2020

C# : How can we access private method outside class

Introduction In object-oriented programming, encapsulation is a fundamental principle that restricts direct access to the internal implementation details of a class. Private methods, being part of this internal implementation, are designed to be accessible only within the confines of the class they belong to. However, there might be scenarios where you need to access a private method from outside the class. In this blog post, we'll explore several techniques to achieve this in C#. 1. Reflection: A Powerful Yet Delicate Approach Reflection is a mechanism in C# that allows inspecting and interacting with metadata about types, fields, properties, and methods. While it provides a way to access private methods, it should be used cautiously due to its potential impact on maintainability and performance. using System ; using System . Reflection ; public class MyClass { private void PrivateMethod ( ) { Console . WriteLine ( "This is a private method."...

C# : Architecture style vs architecture pattern

In the realm of software development, the terms "architecture style" and "architecture pattern" often surface in discussions about designing robust and scalable systems. It's crucial to understand the distinctions between these concepts to make informed decisions when shaping the architecture of a software application. Let's embark on a journey to unravel these terms using real-world analogies for clarity. Architecture Style: The Design Philosophy Definition: An architecture style represents a fundamental design philosophy that guides how software components interact. It embodies high-level principles, often influencing the overall structure and behaviour of a system. Real-World Analogy: Consider architectural styles in the context of building design. Styles like Modernist, Gothic, or Minimalist dictate overarching design principles, influencing the aesthetics and functionality of structures. Example: Microservices Architecture Style Description: The Micr...

C# : Constant vs ReadOnly

In the world of C# programming, understanding the distinctions between const and readonly is paramount for crafting robust and maintainable code. This blog post will delve into the characteristics of constants and readonly variables, drawing comparisons with real-time analogies and providing practical C# code snippets for clarity. Constants: The Unchanging Pillars Definition: Constants, declared using the const keyword, are immutable values whose values must be assigned at compile-time and cannot be modified during runtime. Real-World Analogy: Think of constants as the fundamental physical constants like the speed of light or gravitational constant—unchanging and universally applicable. public class MathOperations { public const double Pi = 3.14159 ;   public double CalculateAreaOfCircle ( double radius ) { return Pi * radius * radius ; } }   In this example, Pi is a constant representing the mathematical constant Ï€, and it remains u...

SQL : Types of Triggers

SQL triggers are the silent operators in database management, responding to events with predefined actions. This blog explores various types of triggers, providing real-world analogies for better understanding, along with practical MS SQL snippets for each. 1. AFTER Triggers: The Cleanup Crew Description: AFTER triggers execute after a triggering event completes (INSERT, UPDATE, or DELETE). Imagine them as the cleanup crew post a lively event. Real-World Analogy: After a conference, the cleanup crew meticulously restores the venue, ensuring cleanliness and order. CREATE TRIGGER AfterEventCleanup ON YourTable AFTER INSERT AS BEGIN -- Cleanup actions here END ;   2. INSTEAD OF Triggers: Decision-Making Authorities Description: INSTEAD OF triggers replace the triggering event with a defined action, acting as decision-makers redirecting the course of events. Real-World Analogy: Similar to a receptionist handling a call directly instead of transferring it. CREATE TRIGGER ...

SQL : DML Commands

For freshers venturing into the realm of databases, comprehending Data Manipulation Language (DML) commands is akin to unlocking the ability to interact with and transform data within the database. This blog post seeks to provide a beginner-friendly understanding of DML commands, shedding light on their significance and practical applications using MS SQL snippets. Background: What is DML? DML (Data Manipulation Language) is a subset of SQL that focuses on the manipulation of data stored in a database. It includes commands for inserting, updating, and deleting data, allowing users to interact with the contents of their databases. The DML Command Ensemble INSERT: Introducing New Entries The INSERT command is akin to adding new entries to a database. Suppose you want to add a new employee to the Employees table INSERT INTO Employees ( FirstName , LastName , Salary ) VALUES ( 'John' , 'Doe' , 50000.00 ) ;   UPDATE: Making Revisions The UPDATE command allows users t...

SQL : DDL Commands

In the realm of databases, understanding how data is defined and organized is crucial for effective data management. This blog post aims to provide freshers with insights into Data Definition Language (DDL) commands, shedding light on their significance and practical applications using MS SQL snippets. Background: What is DDL? DDL (Data Definition Language) is a subset of SQL responsible for defining and managing the structure of a database. It deals with creating, altering, and deleting database objects like tables, indexes, and views. DDL commands are instrumental in shaping the blueprint of your database. The DDL Command Ensemble 1. CREATE: Crafting Foundations The CREATE command is the architect's tool, defining the framework for your database objects. For instance, to craft a new table named Employees CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY , FirstName NVARCHAR ( 50 ) , LastName NVARCHAR ( 50 ) , Salary DECIMAL ( 10 , 2 ) ) ;   2. ALTER: E...

SQL : Stored Procedures - from Definition to execution

In the vast landscape of relational databases, Stored Procedures stand as stalwart guardians of efficiency and functionality. This comprehensive blog post aims to demystify the concept, exploring what stored procedures are, why they are essential, and the purposes they serve, accompanied by real-world examples with MS SQL snippets. Understanding Stored Procedures Definition and Purpose Stored Procedures are precompiled and stored sets of SQL statements that can be executed as a single unit. They serve as reusable and optimized code blocks, enhancing performance, security, and maintenance in database operations. Why We Need Stored Procedures Efficiency and Security Performance Optimization: Stored procedures are precompiled and stored in the database, reducing the overhead of parsing and optimizing SQL statements during execution. Code Reusability: As modular units of code, stored procedures promote code reusability. Changes made to a stored procedure automatically reflect in all place...