C# Records are Functional - Try Them Out That Way!

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ค. 2024
  • Become a patron and get access to source code and exclusive live streams: / c-records-are-81380375
    In this video, we are demonstrating use of a record as part of a functional domain model. You will see common functional separation of types and functions, where a specialized function applies to the record as an extension method. We are contrasting this modeling style to traditional object-oriented modeling, emphasizing the benefits of functional design - namely, simplicity, isolation of dependencies, and simplicity of the underlying type system.
    Learn more from video courses:
    Beginning Object-oriented Programming with C# ► codinghelmet.com/go/beginning...
    Collections and Generics in C# ► codinghelmet.com/go/collectio...
    Making Your C# Code More Object-oriented ► codinghelmet.com/go/making-yo...
    Other courses at Pluralsight ► codinghelmet.com/go/pluralsight
    Other courses at Udemy ► codinghelmet.com/go/udemy
    Other videos on this channel you may be interested in watching:
    Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ► • Using GitHub Copilot t...
    Coding with GitHub Copilot - Beginner to Master | VS Code Demo ► • A Comprehensive Guide ...
    What is Covariance and Contravariance in C# ► • What is Covariance and...
    How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ► • How to Initialize a Cl...
    The Null Conundrum: A Guide to Optional Objects in C# ► • How to Avoid Null Refe...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 23

  • @zoran-horvat
    @zoran-horvat  ปีที่แล้ว

    Become a patron and get access to source code and exclusive live streams: www.patreon.com/posts/c-records-are-81380375

  • @StevenJAckerman
    @StevenJAckerman ปีที่แล้ว +3

    Zoran - very illuminating, as usual. Love your approach using records to implement functional style programming.

  • @wojciechwilimowski985
    @wojciechwilimowski985 ปีที่แล้ว +2

    I like the formatting on the chained ternary operator. It's surprisingly readable, reads like a flowchart. I would even move 'video with...' to a new line

    • @heinzriemann3213
      @heinzriemann3213 หลายเดือนก่อน

      I never understood the disregard for ternary operators. They are so much better than if-else statements.

  • @kostasgkoutis8534
    @kostasgkoutis8534 ปีที่แล้ว +1

    Excellent! I am eagerly waiting for your course.

  • @muhamedkarajic
    @muhamedkarajic ปีที่แล้ว +2

    Great video!

  • @tuberklz
    @tuberklz ปีที่แล้ว +1

    kudos Zoran. learned so much from you.

  • @Darebit2k1
    @Darebit2k1 ปีที่แล้ว +2

    gracias por la explicación, muy clara

  • @kristianaranda
    @kristianaranda ปีที่แล้ว

    Have you already published your video on functional programming in PL? I don't see it yet. Thanks!

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว +1

      It is in the publishing queue right now. I don't have any info how long it will take until published, but it shouldn't be more than a few days.

  • @anarhistul7257
    @anarhistul7257 ปีที่แล้ว

    Mr Zoran do you have a place where you put the videos you're in on other youtube channels?

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว

      This is the playlist with conference and other talks published in other channels: th-cam.com/play/PLSDYwLgFqaX7ceTlvJ8MVjOh3C9PTfpki.html

    • @anarhistul7257
      @anarhistul7257 ปีที่แล้ว

      @@zoran-horvat thank you

  • @francoismouchati8189
    @francoismouchati8189 ปีที่แล้ว

    The public ctor with no invariant check is an issue. This is while, although it's more verbose, I'd still do the exact same functional approach with a class with a private ctor and immutable properties.

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว

      Recode is a value. It cannot tell which invariants are in effect in the context where it is used.

  • @andreoliveirasantos9727
    @andreoliveirasantos9727 ปีที่แล้ว +1

    Muito bom

  • @a-s733
    @a-s733 ปีที่แล้ว

    Would be nice to have the course about functional programming on Udemy. I am not member of Pluralsight and it is expencive.

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว

      That will not be possible any time soon, because of my contractual obligations. For the same reason, I am taking care not to repeat themes from the course on TH-cam.

  • @alexlo2621
    @alexlo2621 ปีที่แล้ว

    What about the validation? I see I can create a video with a bad title and nothing prevent me from doing this
    var badVideo = video with { Title = "Some Bad title" };
    var nullVideo = video with { Title = null };

    • @zoran-horvat
      @zoran-horvat  ปีที่แล้ว +2

      That is a good question, and I plan to make a video only on that topic.
      The short answer is that records are modeling values, and hence they do not know what valid means - it depends on the context in which the object is used. For instance, a video with null title could be valid after deserialization, though not valid in a later processing stage.
      As a comparison, imagine the same question regarding an int. An integer value cannot validate itself. It can only be validated by the outer entity which controls it.

  • @marklord7614
    @marklord7614 ปีที่แล้ว +1

    Looking to take your coding to the next level? Follow Zoran Horvat! I can't wait for the course.

  • @ahmedameen2
    @ahmedameen2 8 หลายเดือนก่อน

    Is oop going to die?