Building Your First Clean Architecture Use Case (Vertical Slices, Unit Testing With AI)

preview_player
Показать описание

Clean Architecture can seem daunting at first, but this video breaks it down into bite-sized pieces with a practical example. We'll focus on building a single use case from start to finish using Vertical Slices, keeping our code clean, testable, and maintainable. We'll even explore how AI can help your unit testing.

What you'll learn:

- Clean Architecture Fundamentals: Understand the core principles and layers
- Unit Testing with AI: Leverage AI tools to generate test cases and edge scenarios
- Best Practices: Get tips on DI, separation of concerns, and writing maintainable code

Check out my courses:

Read my Blog here:

Join my weekly .NET newsletter:

Chapters
0:00 Application boilerplate
0:55 Creating the first use case
4:53 Clean Architecture principles
7:03 Maintaining high cohesion (VSA)
11:56 Unit testing with Google Gemini
15:40 Reviewing the Clean Architecture use case
Рекомендации по теме
Комментарии
Автор

Really great! I know that in .NET you usually have a separate project for the tests but I like to put them next to the use case on the vertical slice folder. I think that works really well.

gigantedocil
Автор

agreed w/ leaving out DDD when desired as its not a requirement of CA/VS

BillionaireDegenApeClub
Автор

love your content! Could you make a tutorial on generating presigned URLs and uploading files to an S3 bucket. Thanks for all your great work!"

battomisaadi
Автор

@MilanJovanovicTech Great demo thanks, can you please explain how Modular Monolith is different from Vertical Slices?

To me till now both architecture look similar

ordinaryBrownDad
Автор

Would you generally recommend to create your own JWT implementation rather than using the bearertoken services from identity ?

KristianS
Автор

How will we use the use-case (RegisterUser) in the API? Are all the use-cases supposed to be added to DI container?

Till now, I’ve been more familiar with the service driven architecture where we have a service and every “use-case” is a method. The service is added to DI container. I suppose what you have shown, every use-case as a class, is CQRS. If I’m right, I know the concept but not very familiar with it.

DrGaurangGupta
Автор

Thanks Milan, (topic apart) Do you recommend GUID on large DB’s?? Any video about that topic??

I’m really concerned about DB performance in the future, I appreciate your point of view.

GaloGalvez-hc
Автор

Great Milan, but I did notice that you igonre the Mediator is this the new way when using the vertical slices? there no need for the more complication

Ahmedhosnybarbary
Автор

Great video, I'm going to try this on my next small project. Would you place the implementation of IPasswordHasher and IUserRepository in the Users Folder?

kimandjasoninflorida
Автор

Homework assignment?!

I didn’t know I was enrolled into a course … 😅

Great video!

Also agreeing with use of primary constructors. Nobody will change the input parameters!

ryan-heath
Автор

Thank you for this valuable video.
I want to ask is it a good approach to start with CA when we are developing MVP and we want to get to market very soon, or start with other simple approaches?
Then when we will have time to refactor.

rayan_azzam
Автор

Does this mean that I will have a lot of classes with just a single method in it?

geraldaburto
Автор

Good simple video, simple comment though: You are leaking security info by returning "The email is already in use".
With a datadump of hacked email/password combos, one could hack into the system.
I understand this is a simple tutorial video, and you can't capture all the best practices (like doing this TDD style would make it even better)

rlarno
Автор

i have a quesction witch is : for what type of project we can/should use Vertical Slice Architecture ? for example for Auth service or some business service it's write to user DDD for Auth service and Vertical Slice for business service ?

TahaYasaghi
Автор

Like you mentioned, the userRepository.Exists approach is subject to a race condition. If you went with the database index approach how would you be able to do your second test where you check for a duplicate? It wouldn't be possible, and you would not be able to capture that part of the business logic on the use case. We can already see that there's already a tradeoff between performance and correctness. In order to capture the business logic at the use case level you either have a race condition with the exists approach, or a hit to your concurrency with the lock approach. If you go with the database unique key/index approach you no longer capture that part of the business logic on the use case and can't test. Any suggestions on how to handle this?

gigantedocil
Автор

I personally perfer this pattern it is easily understandable.

BilalKhan-sxeu
Автор

We need a special price for Latin America. the price for 1 course is our salary 😂

dangerosa
Автор

What a shady practice that you highlight incorrect statement under my comment. "wow that’s a bad video with wrong information. " - @ryan-heath you were first with talk is cheap comment and now you doing exactly same. Abstraction brings cost, oop is making gaps in memory allocation which is not cpu friendly. Thats video show exactly that. "Clean code" is at some point a way that it looks like "organized code" but its in cost of perfomance. If you make each request as seperate class, its huge allocation cost in real time systems, in big scale you need to think in different way than just i like this "code visual".

frontalachivment