Skip to main content

Posts

What is the difference between IOC and DI?

Inversion of Control (IOC) and Dependency Injection (DI) are related concepts in software development, but they are not the same thing.   IOC (Inversion of control) is the design target intended to achieve between the classes and their dependencies, In other words a class should not create or control the objects it uses, but instead should rely on an external source to provide those objects. This is typically achieved by using a container or framework that creates objects and manages their lifetimes    DI (Dependency Injection) is one of the design patterns used to achieve this target There are other ways to achieve IOC which is subjected to the application  As the name suggests the flow of controls is inverted to improve the performance, maintainability and scalability.   Simply put (DI) is a specific implementation of IOC where a class's dependencies (i.e. the objects it uses) are provided to it by an external source, rather than the class creating or controlling them direc

What are EC2 (Elastic Computing Cloud) placement groups in AWS?

EC2 placement groups are a logical grouping of Amazon Elastic Compute Cloud (EC2) instances within a single availability zone. They allow for low-latency network performance between instances and enable the placement of instances in a physically isolated section of an availability zone, providing a higher level of isolation from other instances and failures. Placement groups are recommended for applications that require high performance network traffic, such as high-performance computing, video encoding, and scientific modeling. When launching a new EC2 instance AWS automatically make sure that the instances are placed interdependently in hardware to avoid any co-related failure Users can setup 3 different placement groups   Cluster, Partition & Spread Cluster :  Places the instances closely in a single availability zone Partition:  Places the instances in logical partitions but not share the hardware Spread:  Places the instances strictly in distinct hardware

Why and how the C# strings are immutable? Explained with examples

C# strings are immutable, meaning that once a string object is created, its value cannot be changed. Instead, any operation that modifies a string, such as concatenation or replacement, creates a new string object with the modified value. One reason for this immutability is that strings are often used as keys in dictionaries or as elements in collections, and immutable objects are more efficient for these uses because their hash code does not change. Another reason is that strings are often used in multithreaded environments, and immutability allows multiple threads to access the same string object without the risk of data corruption.  Example: The string which is a reference type stored in a memory heap Suppose we are creating a string str and assign a value  "a"; That will be stored in the memory location like this Again if we assigning another value to the same string that is "b"  This will not replace the existing value Instead this will create another memory