Which part of object-oriented design is the hardest to get right?
A viable candidate for this infamous title is that delicate dance between abstract and concrete types we must go through in every single model we make.
C# has recently been enriched with an important feature that will help us balance abstract and concrete types: the covariant return types. But what is that feature?
In this video, you will learn how method overrides and interface implementations can return a more derived type than their base type specifies. This feature, almost trivial in its form, has a tremendous impact on the overall design. Once impossible, at least without a risky downcast, operating at the level of concrete classes where required and at the level of abstract types where allowed has become a reality.
Become a sponsor to access source code ► / zoranhorvat
Join Discord server with topics on C# ► https://codinghelmet.com/go/discord
Enroll course Beginning Object-Oriented Programming with C# ► https://codinghelmet.com/go/beginning...
Subscribe ► / @zoran-horvat
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⚡️RIGHT NOTICE:
The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorized to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.
#csharp #dotnet #objectorientedprogramming