dotnet core, micorservices

A Guide to Microservices using .Net 5

Microservices is a great architecture for modern applications that need to be scalable and resilient to failures in order to be able to support millions of transactions.

In order to understand why the microservice architecture can be better than monolithic, it is needed to understand the drawbacks of monolithic applications.

Continue reading
Sin categoría

Factory and Strategy pattern in real case scenario with .Net core 5

Some time ago I got a new requirement. When analyzing the requirement I realized that I would need some design patterns.

When I was first introduced to design patterns I got some trouble understanding them because of the lack of real-life scenarios.

This post contains the usage of the Factory and Strategy pattern in a real-life scenario to create a clean and maintainable code by following the SOLID principles in a real-life scenario.

As a note, it is important to denote that the application follows the CQRS architectural pattern. (You will see the usage of Mediatr library along with some Commands, Queries, and Handlers)

This post is under construction. To read the complete post go to my LinkedIn article
https://www.linkedin.com/pulse/factory-strategy-pattern-real-case-scenario-net-core-5-mata-viejo/

Sin categoría

How to handle Validations on CQRS implementation with MediatR .Net core 5

When implementing CQRS using MediatR it is possible to implement pipelines behaviors.

These pipelines allow to catch all commands and queries and gives the ability to execute some logic before and after the Commands and Queries Handlers are executed.

The Validation pipeline behavior

One of the many pipelines that can be added is the validation pipeline behavior which adds logic to validate the properties in the Commands and Queries, resulting in that only valid requests will be passed to the Commands and Queries Handlers.




How to implement Validation Pipeline Behaviour?

The easiest approach is to use FluentValidation. Fluent validation is a library that allows writing easy and complex validations for the Queries and Commands.
The next example shows how to create a Validator.
1.- Implementes AbstractValidator from FluentValidation and add the object to be validated as the parameter.
2.- Write the rules for each one of the parameters of the command or query object.
Continue reading