The pipes and filters pattern is a powerful tool for breaking down complex data processing tasks into simple, reusable components. It can help you write maintainable and reusable code that is easy to understand and modify. In this blog post, we have seen how to use the pipes and filters pattern to validate incoming data using C#, by implementing the basic building blocks of the pattern, filters, pipes and the pipeline. We defined an interface for filters called IPipeFilter that has a single method called Process that takes in a input of type T and returns output of type T. Then we created two filters, DataValidationFilter and DataTransformationFilter that implement this interface, the first one checks if the input data is valid and throws an exception if it is not, the second one converts the input data to uppercase. Finally, we created a class called DataProcessingPipeline that takes a list of IPipeFilter as a constructor argument, and applies each filter in the list to the input data in the order they are provided.More
Dynamic objects in C#
Dynamic objects in C# are objects that can have properties and methods added to them at runtime, as opposed to traditional objects which have a fixed set of properties and methods defined at compile time. There are a few different ways to create dynamic objects in C#, including the dynamic keyword and the ExpandoObject class.…More
Asynchronous programming in C#
Asynchronous programming is a powerful tool for building responsive, scalable applications in C#. By using asynchronous techniques, you can avoid blocking the main thread of your application and ensure that your code runs efficiently and smoothly, even in the face of long-running or resource-intensive tasks. In this blog post, we’ll take a closer look at…More
How to do polymorphic serialization/deserialization in C# System.Text.Json
In this blog post, you’ll see how to serialize and deserialize a hierarchy of objects polymorphically to have a cleaner json.More
Build Blazor apps with Tailwind CSS
Blazor lets you build web UI components with C# dotnet. These components can be used in browser via web assembly or server side via ASP.NET Core. Tailwind CSS is utility-based CSS framework. Unlike bootstrap Tailwind doesn’t come with its own components, it has thousands of micro-CSS classes which can be used to build our UI…More
How to use Redis as your primary database
Recently, I got chance to work with Redis and realized that redis is not just a cache solution it can serve as your primary database. Traditional databases store their data on disk, even though most databases have an embedded cache on RAM to optimize query performances. Most of the time we end up using some…More
Understanding SOLID Principles: Interface Segregation & Dependency Injection
This blogpost talks about interface segregation and dependency injection in solid principlesMore
Understanding SOLID Principles: Liskov Substitution
Liskov substitution is one of the more complex facets of the SOLID principles. It requires a foundational knowledge of both contracts and variance to build rules that guide you toward more adaptive codeMore
Understanding SOLID Principles: Open/Closed
This is the part 2 of the series of posts that I’m writing on the topic of solid principlesMore
Understanding SOLID Principles: Single Responsibility
If your code is not adaptive enough, You process cannot be agile enough.. To make your code more adaptive learn SOLID PrinciplesMore