The .NET World - Mixin

In object-oriented programming, a mixin is a type that contains methods for use by other classes without having to be the parent class of those other classes. C# does not natively support mixins, but developers have devised various ways to mimic this functionality.

Pros:

  1. Code Reusability: Mixins can encapsulate behaviour that can be reused across different classes. It promotes the DRY (Don’t Repeat Yourself) principle.

  2. Code Organization: Mixins allow us to separate different functionalities into different classes, making the code easier to read and maintain.

  3. Flexibility: Unlike inheritance, where a class can only inherit from a single class, a class can mix in multiple other classes, providing more flexibility.

  4. Avoiding Class Explosion: In languages or scenarios where multiple inheritances are not allowed or lead to complexity, mixins can add class functionality without creating new subclasses for every possible combination of behaviours.

Read more

A Professional ASP.NET Core API - RabbitMQ

RabbitMQ is an open-source message-broker software that originally implemented the Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol, MQ Telemetry Transport, and other protocols.

A message broker acts as a middleman for various services (e.g. a web application, as in this example). They can be used to reduce loads and delivery times of web application servers by delegating tasks that would normally take up a lot of time or resources to a third party that has no other job.

Read more

A Professional ASP.NET Core - Middleware

Middleware is software that’s assembled into an app pipeline to handle requests and responses. Each component:

  • Chooses whether to pass the request to the next component in the pipeline.
  • Can perform work before and after the next component in the pipeline.

Request delegates are used to build the request pipeline. The request delegates handle each HTTP request.

Request delegates are configured using Run, Map, and Use extension methods. An individual request delegate can be specified in-line as an anonymous method (called in-line middleware), or it can be defined in a reusable class. These reusable classes and in-line anonymous methods are middleware, also called middleware components. Each middleware component in the request pipeline is responsible for invoking the next component in the pipeline or short-circuiting the pipeline. When a middleware short-circuits, it’s called a terminal middleware because it prevents further middleware from processing the request.

Read more

A Professional ASP.NET Core - Model Binding

Controllers and Razor pages work with data that comes from HTTP requests. For example, route data may provide a record key, and posted form fields may provide values for the properties of the model. Writing code to retrieve each of these values and convert them from strings to .NET types would be tedious and error-prone. Model binding automates this process. The model binding system:

  • Retrieves data from various sources such as route data, form fields, and query strings.
  • Provides the data to controllers and Razor pages in method parameters and public properties.
  • Converts string data to .NET types.
  • Updates properties of complex types.
Read more

A Professional ASP.NET Core API - Caching

Caching is a technique of storing the frequently accessed/used data so that the future requests for those sets of data can be served much faster to the client.

In other terms, you take the most frequently used data, which is also least-modified, and copy it temporary storage so that it can be accessed much faster for the future calls from the client. This awesome technique can boost the performance of your application drastically by removing unnecessary and frequent requests to the data source.

It is important to note that applications should be designed in a way that they never depend directly on the cached memory. The Application should use the cache data only if it is available. If the cache data has expired or not available, the application would ideally request the original data source.

Read more

A Professional ASP.NET Core API - Feature Management

The .NET Core Feature Management libraries provide idiomatic support for implementing feature flags in a .NET or ASP.NET Core application. These libraries allow you to declaratively add feature flags to your code so that you don’t have to write all the if statements for them manually.

Read more