From 96cf57339d2c707232ac348cf24fd90481b52cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Balc=C3=A1rek?= Date: Sat, 16 Mar 2024 18:13:44 +0100 Subject: [PATCH] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 393e96d..e61a626 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Clean Architecture - [Pull Request](https://github.com/Gramli/WeatherApi/pull/2) Vertical Slice Architecture (VSA) - [Pull Request](https://github.com/Gramli/WeatherApi-VSA/pull/1) -Both [Clean Architecture Weather Api (CA)](https://github.com/Gramli/WeatherApi) and [Vertical Slice Architecture Weather Api (VSA)](https://github.com/Gramli/WeatherApi-VSA) are just small APIs, but there is clearly one big difference. CA has almost twice more touched files, which could result in bugs. Therefore, it is crucial for CA to follow **SOLID principles** and have **good code coverage**. +Both [Clean Architecture Weather Api (CA)](https://github.com/Gramli/WeatherApi) and [Vertical Slice Architecture Weather Api (VSA)](https://github.com/Gramli/WeatherApi-VSA) are just small APIs, but there is clearly one big difference. CA has almost twice more touched files, which could result in bugs. Therefore, it is crucial for CA to follow SOLID principles and have good code coverage. In VSA, I add files to my new feature folder, except when editing other features due to the return type (which is the same as in CA). However, in large-scale projects, code duplication can become a significant issue. One way to resolve this issue is by moving the code to the domain. However, this can cause the domain to become excessively large. Based on the PR comparison, we can also see that VSA is well-suited for small or CRUD APIs due to its simplicity and minimal use of abstractions. When we adhere to the same folder structure, it can result in a clean and clear solution. @@ -64,7 +64,9 @@ Based on the PR comparison, we can also see that VSA is well-suited for small or In CA, unit testing is easy thanks to the high level of abstractions. However, as the project grows, it can result in a lot of repetitive work. Fortunately, with the support of AI, this issue can be alleviated. In VSA, it depends. When we look at this example, everything is within the handler (business logic, access to the database). Therefore, for a large-scale project, this is not a good approach because writing and maintaining unit tests can become increasingly difficult even for the AI. But for this simple example, it fits well. ### Conclusion -In Progress.. +In comparison, VSA resolves the issue of CA with touching all layers for just one feature. However, on the other hand, there is a risk of code duplication which CA doesn't have, thanks to splitting the code into handlers, services, etc. Unit testing is easier and cleaner in CA, but it results in repetition. The solution for these issues can be to create a hybrid of both architectures. In the base, use VSA with a feature folder structure and follow the rule that features do not reference each other. From CA, use a good level of abstractions in features where needed; we don't have to create abstractions in simple CRUD operations. + +As I have a lot of experience with CA in middle-sized and large-scale projects and I am satisfied with CA, but there must be emphasis on maintaining the structure. It means following SOLID principles and patterns like CQRS, Repository, Factory, etc. Then the project is well maintainable and testable. I am new to VSA, but I am enthusiastic about it. I will definitely use it in small projects. ## Technologies * [ASP.NET Core 8](https://learn.microsoft.com/en-us/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-8.0)