Тёмный

Improve Your Code with Ardalis GuardClauses 

Ardalis
Подписаться 13 тыс.
Просмотров 3,4 тыс.
50% 1

Improve Your Code with Ardalis.GuardClauses
Hey everyone, I'm Steve Smith aka ardalis!
Let's learn about the Ardalis.GuardClauses nuget package! Using this package will help you write cleaner code that's more foolproof and takes better advantage of encapsulation!
Links
github.com/ard...
ardalis.com/gu...
• What are Guard Clauses? (What are Guard Clauses?)
deviq.com/desi...
www.nuget.org/...
Check out my courses:
ardalis.com/tr...
www.pluralsigh...
Consulting and Training: NimblePros.com and @nimblepros
Developer Group Mentoring: devBetter.com
Free Weekly Email Tips:
ardalis.com/tips/
If you read this far, I hope you liked the video and consider subscribing to my channel!
Find me:
ardalis.com
/ ardalis
github.com/ard...
/ stevenandrewsmith
bsky.app/profi...
#dotnet #deviq #ardalis #nimblepros #visualstudio #csharp #designpatterns #guard #guards #guardclause #guardclauses #nuget #cleancode

Опубликовано:

 

15 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@ManSV14
@ManSV14 10 месяцев назад
I firstly want to say I enjoyed your talk at Techorama about Software Design Patterns! I was wondering, using Guards or FluentValidation, or maybe another way of validating your data, how to handle localized responses for custom exceptions? Should you firstly return localized messages or not? If yes, you have to let your backend know which localization it should use via the requestheader, and pass that value to the used validator, or should you return a specific enum/code to the client and handle the localization message there? or is there a better way? Maybe a bit offtopic, but I was not sure what is the best approach in this case
@Ardalis
@Ardalis 10 месяцев назад
You can certainly localize your validation errors, and I would definitely encourage that. However for exceptions I typically don’t recommend localizing as these should never be exposed to users. Exceptions are for your developers, who hopefully are all using a standard language for communication about the project.
@JustCode512
@JustCode512 9 месяцев назад
10/10 thank you ardalis!
@Ardalis
@Ardalis 7 месяцев назад
❤️
@lucasvogel2178
@lucasvogel2178 10 месяцев назад
Outstanding
@Ardalis
@Ardalis 7 месяцев назад
Thanks!
@grimmersnee
@grimmersnee 9 месяцев назад
really nice and awesome explanation
@Ardalis
@Ardalis 7 месяцев назад
Glad it was helpful!
@nalux
@nalux 7 месяцев назад
Great video, really appreciate the work you're doing, even though I haven't used this library yet. However, in this context, wouldn't it be better to make the Appointment type be immutable and rather create a new instance upon changing? I.e, a record type? I guess I'm coming more from a FP point of view though.
@Ardalis
@Ardalis 7 месяцев назад
Great suggestion! You could do that but since I'm modeling it as an entity, if I want to change *that* appointment (and for instance make sure anyone tracking *that* appointment are notified) I think it's easier if it retains the same ID and its properties change. That said, your suggestion can still be achieved (and is often worthwhile) by taking the specifics of the appointment and creating a new Value Object class (e.g. AppointmentDetails or something) and then making that (one of) the main properties on Appointment. And Value Objects *are* immutable so you'd get the benefits you're describing/alluding to.
@bloopers2967
@bloopers2967 10 месяцев назад
Can you make guard clauses for different types of exception inside your nuget? Like for handle 204 etc
@Ardalis
@Ardalis 10 месяцев назад
A 204 isn't an exception, it's an HTTP return code. If you check out my Ardalis.Result nuget package, it supports different kinds of results that can be mapped (in most cases) to HTTP response codes. There's a separate package that will automatically translate to ASP.NET Core action results using extension methods or filters, too.
@bloopers2967
@bloopers2967 10 месяцев назад
@@Ardalis oh okay thank you I'll use that package
@bmassioui
@bmassioui 10 месяцев назад
Thanks Ardalis, I like your coding style
Далее
When To Validate and When To Throw Exceptions?
11:00
5 Rules For DTOs
17:56
Просмотров 43 тыс.
Using Ardalis Specifications with EF Core 8
13:06
Просмотров 7 тыс.
Interfaces: WHAT - Implementations: HOW
5:35
Просмотров 1,4 тыс.
C# Primary Constructor Tips
17:03
Просмотров 4,5 тыс.
What's New in Clean Architecture Template 9.1
11:27
Просмотров 15 тыс.
STOP Debugging and Start Running in Visual Studio
8:06