What are Guard Clauses?

Поделиться
HTML-код
  • Опубликовано: 17 окт 2023
  • 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/design-patterns/gua...
    www.nuget.org/packages/Ardali...
    github.com/ardalis/GuardClauses
    ardalis.com/guard-clauses-and...
    Check out my courses:
    ardalis.com/training-classes/
    www.pluralsight.com/authors/s...
    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/ardalis
    / stevenandrewsmith
    bsky.app/profile/ardalis.com
    #dotnet #deviq #ardalis #nimblepros #visualstudio #csharp #designpatterns #guard #guards #guardclause #guardclauses
  • НаукаНаука

Комментарии • 12

  • @bloopers2967
    @bloopers2967 6 месяцев назад +3

    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♥️

    • @Ardalis
      @Ardalis  6 месяцев назад +1

      Glad it helped!

  • @Chapali9a
    @Chapali9a 7 месяцев назад +1

    Great video for basic refactoring of badly written code. Love this new video format. Short, concise and easy to extravt 100% of its value.

    • @Ardalis
      @Ardalis  7 месяцев назад

      Glad you liked it!

  • @thomasroustio8608
    @thomasroustio8608 7 месяцев назад +1

    Great explanation and example, thank you.

    • @Ardalis
      @Ardalis  7 месяцев назад

      You are welcome!

  • @erhanalankus
    @erhanalankus 7 месяцев назад +2

    Nice video. I like the new hairstyle!

    • @Ardalis
      @Ardalis  7 месяцев назад

      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 :)

  • @allannielsen4752
    @allannielsen4752 7 месяцев назад +2

    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.

    • @Ardalis
      @Ardalis  7 месяцев назад

      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.

  • @path_selector
    @path_selector 7 месяцев назад

    tired of the pretty people errors getting thru 🙄

    • @Ardalis
      @Ardalis  7 месяцев назад

      totally...