Latest

  • How Lazy works in .NET

    For this post let’s be Lazy. What is Lazy<T>? The Lazy<T> class in C# provides a way to delay the instantiation of an object until it is actually needed. This is particularly useful when the object is resource-intensive to create or may not be needed immediately. Benefits of Lazy Initialization How to Use Lazy<T> Using…

  • Efficient Searching with SearchValues in .NET

    .NET 8 continues to enhance its collection of performance-oriented tools with the introduction of the SearchValues<T> class, found in the System.Buffers namespace. What is SearchValues<T>? SearchValues<T> is designed to provide an immutable, read-only set of values that is optimized for efficient searching. The class is particularly useful in scenarios where the same set of values…

  • IEnumerable vs IQueryable in .NET

    Two key interfaces that play a significant role in data manipulation and querying are IEnumerable and IQueryable. Both interfaces are foundational for LINQ, but they serve different purposes and are suited for different scenarios. Let’s try and understand what each of them does and how they are compared. What is IEnumerable? IEnumerable is an interface…

  • Vertical and Horizontal Scaling for Dummies

    Have you ever heard about Vertical and Horizontal scaling and you never bothered to ask? Well in this post I will try to give some simple definitions about both and in the end I have a some FAQs (even though nobody asked any questions 😢). What is Vertical Scaling? Vertical scaling, or “scaling up”, means…

  • Idempotency for dummies

    A common interview question is about Idempotency. Let’s try and explain what it is and also explain some of the places we want to apply this concept. Idempotency, refers to the characteristic of certain operations that, regardless of how many times they’re executed, yield the same outcome after the initial application. Imagine pressing an elevator…

  • The Decorator Pattern in C#

    Design patterns serve as blueprints for solving common design problems. The Decorator Pattern is great for extending the functionality of objects at runtime, without altering their structure. This pattern is particularly useful in C#, a language known for its robustness and versatility in object-oriented programming. What is the Decorator Pattern? The Decorator Pattern is a…

  • Composition Over Inheritance in C#

    The principle of “composition over inheritance” has gained substantial traction over the years as a powerful design strategy. This approach advocates for creating flexible and maintainable software architectures by favoring composition of objects over the traditional inheritance hierarchies. In this post, we’ll explore what composition over inheritance means, why it’s beneficial, and how you can…

  • Records and Immutability in .NET

    The principles of immutability and data integrity are the cornerstones for building reliable, maintainable, and concurrent applications. The .NET ecosystem, with its rich set of features and language enhancements, provides developers with powerful tools to embrace these principles. Among these innovations, records stand out as a significant addition to C#, offering a simple syntax for…

  • The Interlocked class in .NET

    Concurrency is a powerful tool that, when harnessed correctly, can significantly boost the performance and responsiveness of applications. However, with great power comes great responsibility (Thanks Uncle Ben). The shared state’s management across multiple threads can be a daunting challenge, often leading to notorious bugs that are hard to track and fix. This is where…

  • IAsyncEnumerable in .NET

    From the early days of callbacks and events to the modern async and await patterns, .NET has continually provided developers with powerful abstractions to handle asynchronous operations. Among these advancements, IAsyncEnumerable<T> stands out as a pivotal addition for working with asynchronous streams of data. Introduced in C# 8.0 and .NET Core 3.0, IAsyncEnumerable<T> allows developers…

  • Reflection in .NET with practical examples

    Reflection in .NET is a powerful feature that allows programmers to introspect assemblies, modules, and types at runtime. This capability is essential for scenarios where type information is not known at compile time. By using reflection, developers can dynamically create instances of types, invoke methods, and access fields and properties. This flexibility makes reflection a…

  • Understanding Context Switching in the .NET World

    Today, we’re diving into an often overlooked but crucial aspect of our computing world – context switching. While it might seem like a concept buried deep in the realms of operating system theory, it has practical implications for us as .NET developers. Understanding context switching can help us write more efficient and responsive applications. What…

  • Hashing and Encryption: Securing Passwords and Data

    In the digital age, safeguarding sensitive information is super duper important. Two key techniques at the forefront of data security are hashing and encryption. While they both serve to protect data, their applications, especially in the context of password management, are distinct. Let’s see when each should be used and why. Hashing Key Characteristics: Common…

  • Exploring the Actor Pattern with .NET Orleans

    When trying to find efficient ways to handle complex, distributed, and concurrent systems, a great solution is the Actor Model, a paradigm that revolutionizes how we think about processing and state management in large-scale applications. In the realm of .NET, one framework stands out in implementing this model: .NET Orleans. Developed by Microsoft Research and…

  • Avoiding The Anonymous Object Trap

    In the evolving landscape of C# programming, efficiency and readability are key. As developers, we constantly seek ways to write cleaner, more efficient code. One such avenue is the use of value tuples, a feature that, while not new, remains underutilized in many C# projects. This post aims to shed light on value tuples and…

  • Asynchronous Programming in C#

    In the evolving landscape of software development, mastering asynchronous programming is essential. Particularly in C#, it unlocks the ability to create responsive and efficient applications. This post explores the what, why, and how of asynchronous programming in C#. 1. Definition and Core Concept Asynchronous programming is a method used in software development to run tasks…

  • Increase performance by using CompositeFormat

    Since its inception, .NET has provided several methods for string formatting, with string.Format being a primary tool. However, this method had its drawbacks, such as the need for parsing the composite format string on each call and the boxing allocations for value types. This approach, while functional, was not optimized for performance, especially in scenarios…

  • C# 12: Exploring the latest key features

    With the release of .NET 8 comes a new version of C#. Let’s summarize the key new features along with some practical examples. Will keep this post and just highlight the key parts of this release. Primary Constructors We can now use primary constructors to initialize classes and structs. Collection Expressions A lot of enumerables…

  • The Evolution of .NET 8 Performance: Tiering and Dynamic PGO

    Based on the post that Stephen Toub made (Performance Improvements in .NET 8), I wanted to highlight an important part that will make .NET 8 a very interesting release! First, let’s recap some things. What is the JIT? When you write a .NET application, the code you author in languages like C# or F# isn’t…

  • Bitwise Operations in .NET

    Bitwise operations are fundamental operations at the binary level, and they can be blazingly fast because they work directly on the bits of data. They can often be used to perform certain tasks more efficiently than other methods. In the context of .NET, bitwise operations can be particularly useful for tasks such as manipulating individual…

  • Memory Management in .NET

    Memory management is a foundational concept in software development, ensuring optimal performance and resource utilization. In the .NET ecosystem, memory management is automated, courtesy of the Garbage Collector (GC). Why is the Garbage Collector Useful: 1. Automatic Memory Management: Developers don’t need to manually allocate and deallocate memory, reducing the chance of memory leaks and…

  • Func, Predicate and Action Explained in .NET

    Func, Predicate, and Action are built-in delegate types provided by the .NET framework, used mainly with LINQ and asynchronous programming. Understanding them can simplify your code by reducing the need to define custom delegates. A Brief Recap on Delegates At its core, a delegate is a type-safe function pointer, representing references to methods with a…

  • The ServiceResult Pattern

    The Service Result pattern is a popular approach in software design, especially in scenarios where you want to return both the result of an operation and any potential errors or exceptions without throwing exceptions directly. This pattern is particularly useful in layered architectures, such as when building APIs or services. Let’s see how you can…

Archives