Exceptions in C# are definitely a great facility but we need to use them wisely. We should leave the least possible probabilities of throwing an exception since exceptions come with a cost. Exceptions simply signal that something has gone wrong in your code. The purpose of an exception is to allow your program to understand and respond unexpected problems like cleaning up resources or notifying the user. However making decisions about the program’s logic is not among the primary purposes of exceptions. Even though I am talking through C#, this is true for all programming languages having exceptions. So, using…
-
-
In C#, understanding the difference between value types and reference types is a fundamental topic when writing efficient and performant code. The choice between using a value type (like a struct) or a reference type (like a class) can have significant implications on both memory usage and performance. The technical reasoning behind preferring value types over reference types lies in how they are managed in memory. Reference types are stored on the managed heap and come with an overhead of garbage collection. It can affect performance especially if there are many allocations and deallocations. Additionally, accessing data through a reference…
-
In the world of software engineering, there is a constant change. Anything we learn has a potential to get redundant just in a matter of years. A lot of languages, methodologies, techniques, tools, frameworks, libraries came in with a huge noise and went away silently. Very few things manage to live for a decade. However, there is one thing which has been there for more than half a century, and remained unchanged. It is the core of all operating systems, and also all compilers and interpreters of unexceptionally all programming languages, and it is also the father of almost all…
-
Before diving into topic, I want to begin with clarifying the terminology. Immutable data refers to data whose state cannot be modified after it has been created. Once an immutable object is created, its internal state remains constant throughout its lifetime. Any attempt to modify the object’s state results in the creation of a new object with the updated state, leaving the original object unchanged. In C#, you can define your data using either classes or structs. The choice between a class and a struct can influence the behaviour and performance of your application. Classes are reference types and structs…
-
In C#, the in parameter modifier is relatively a recent addition. It added in C# 7.2. The main point of in keyword is to pass a large value type to a method without copying the entire structure. Value types in C# are typically passed by value. This means that the entire thing is duplicated and handed off to the method. This may not be a big deal for small value types like int or bool. However, for larger value types, it can be quite expensive in terms of performance because it takes time and memory to take care of these…
-
The title could have also been “Don’t use unsafe code at all!” You will come to the same conclusion after reading this post, but still I gave a room for its usage. In C#, the usage of unsafe code is a topic of debate. On one side, it offers the potential for performance gains in specific scenarios. Yet the risks and complexities it introduces often outweigh its benefits. What is unsafe Unsafe code in C# refers to a block of code that uses pointers and allows direct memory manipulation, bypassing the .NET runtime’s type safety and security checks. This capability…
-
Containerization became one of the recent trends in software development technology, because of its advantages with deployment and scalability and it is not for the first time I am writing about dockerizing an app. No doubt, Docker practically is the only platform for containerization, and it provides developers a convenient method to bundle applications and their prerequisites into efficient containers. It also guarantees uniformity across very different environments. In this post, I will explore the steps involved in containerizing a React application using Docker, starting from the creation of a fundamental React component and concluding with its execution within a…
-
We often hear the terms “stateful” and “stateless”. Understanding these concepts has a critical importance since it is one of the most essential questions when designing and architecting software applications. In today’s blog post, I wanted to talk about these two very basic concepts. As the simplest definition, stateful application means an application which remembers the past, similarly, stateless application means an application which doesn’t remember the past. The state we have been talking about might be saved in a database, a file on the disk, a cookie in a browser etc. As an example, consider an e-commerce website. When…
-
Keeping things secure is the important part of any application. As entire internet going to cloud, Azure Active Directory (AD) is one of the best possible among one of two popular options. It helps manage who can use your app and what they can do. Let’s see how to set up Azure AD for a C# and Java Spring Boot backend, and a React frontend to make sure only the right people get in. First, go to the Azure portal and make a new Azure AD tenant if you don’t have one yet. Then, register your app in Azure AD.…
-
In software development, performance optimization is a crucial topic and one of the most effective ways to improve the performance is caching. However, caching is a double edged sword we need to very careful about when and how to use caching. So, we need to use right strategy in right place. Caching can be implemented at different levels, including memory, network, and CDN (Content Delivery Network) levels. Each level has a unique purpose and is suitable for different use cases. In this post, we will focus on memory-level caching which is simply storing the data in the memory of the…
-
Docker is a powerful tool that allows developers to package applications into containers. These containers can run on any system that has Docker installed, making it easier to deploy and run applications consistently across different environments. Containers are like lightweight, portable packages for your application, including everything it needs to run: code, runtime, libraries, and settings. I assume that you have already know what Docker is and also you have .NET and Docker installed on your machine. Don’t worry, just download and then next + next. For more details and official documentation, you can visit Docker’s official website and for…
-
D is an interesting language. For some reason, I have an emotional connection with this language and I believe that it is the subject of the biggest unfairness story in the history of software development. To me, it is the best programming language in the market for the reasons I am going to state below. However, this language is underestimated, underrated, and despised in the programming circles because it doesn’t have a strong backer. In this article I want to talk about, and give some credit to D, an underrated sibling of C++, Java and C#. The D programming language…
-
When designing systems, especially distributed systems, the flow of data and service requests must remain continuous. This brings us to an architectural design pattern called the Circuit Breaker. It comes from electronics. Simply, it is designed to stop the flow when something goes wrong. This prevents potential cascading failures in a system. Understanding the Circuit Breaker Pattern Imagine a scenario where a service relies heavily on another third-party service. However, that third-party service becomes slow or starts to fail at some point. Without any preventive measures, our service will keep making requests, waiting for timeouts, even getting stuck. This is…
-
Whenever a major improvement happens in web technology, whenever a new framework or a language is introduced in the web development market, PHP’s death is declared immediately. I have been witnessing a recent popular belief that PHP is nearing its end due to NodeJS becoming the new “darling” of the developer community. To me, this belief is a naive statement comes from lack of knowledge on the history of programming languages since the story of PHP is the greatest survival story of the entire computer science history. Over the years, many people have declared the death of PHP against a…
-
“Angular or React?” has been one of the most important questions in software development for the last decade. As a developer who had worked in full-stack fashion for a long time myself, my story of frontend started with Angular but had slightly moved towards React. Since I have actively participated projects in both, I wanted to write a comprehensive comparison between these two. Let’s explore the key aspects of each framework to help you make a decision, if you need to. Brief Overview: Developed and maintained by Facebook, React is a component-based library that deals mainly with the view layer…
-
A few weeks ago, we were discussing a problem with my team mates and a colleague raised a question about a very basic distributed remote caching problem which was about an application scaled out across multiple instances, managing how data is cached can become a significant challenge. Let me take the shortcut and directly jump into the problem. Consider a scenario where you have multiple instances doing the same job and you need to cache the result of a function which takes about 30 seconds. This function’s result needs to be cached to avoid redundant executions across different instances. The…