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... - วิทยาศาสตร์และเทคโนโลยี
Become a patron and get access to source code and exclusive live streams: www.patreon.com/posts/c-records-are-81380375
Zoran - very illuminating, as usual. Love your approach using records to implement functional style programming.
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
I never understood the disregard for ternary operators. They are so much better than if-else statements.
Excellent! I am eagerly waiting for your course.
Great video!
kudos Zoran. learned so much from you.
gracias por la explicación, muy clara
Have you already published your video on functional programming in PL? I don't see it yet. Thanks!
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.
Mr Zoran do you have a place where you put the videos you're in on other youtube channels?
This is the playlist with conference and other talks published in other channels: th-cam.com/play/PLSDYwLgFqaX7ceTlvJ8MVjOh3C9PTfpki.html
@@zoran-horvat thank you
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.
Recode is a value. It cannot tell which invariants are in effect in the context where it is used.
Muito bom
Would be nice to have the course about functional programming on Udemy. I am not member of Pluralsight and it is expencive.
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.
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 };
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.
Looking to take your coding to the next level? Follow Zoran Horvat! I can't wait for the course.
Is oop going to die?
Nope.