What are Guard Clauses?
HTML-код
- Опубликовано: 13 сен 2024
- What are Guard Clauses?
Hey everyone, I'm Steve Smith aka ardalis!
In this video we're going to introduce the pattern known as Guard Clauses. You'll learn why the pattern exists and when to use it. We'll look at more advanced scenarios in a future video.
Links
deviq.com/desi...
www.nuget.org/...
github.com/ard...
ardalis.com/gu...
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
Great explanation. Thanks just learning this pattern
You are welcome!
Wow, Your way of explanation is soo good. It's super simple to understand by your videos. I watched around 4-5 before yours and didn't understand this topic but you're the man♥️
Glad it helped!
Great video for basic refactoring of badly written code. Love this new video format. Short, concise and easy to extravt 100% of its value.
Glad you liked it!
Great explanation and example, thank you.
You are welcome!
Nice video. I like the new hairstyle!
Thanks! Been growing it out for about 15 months. It's still in that annoying stage where it wants to keep getting in my face, so you'll see me wearing hats a lot, too :)
i would never use guard clauses for validation. that said, if i'm guarding my class from invalid coding then i prefer Debug.Assert so i can catch it during my test phase. throwing exceptions should only be for exceptions, otherwise there are better solutions.
Also reasonable approaches. I prefer exceptions because they will definitely stop invalid code paths from executing. But you're correct this should not be used for (first line) validation.
tired of the pretty people errors getting thru 🙄
totally...