Become a patron and get access to source code and exclusive live streams: / calling-virtual-81380300
In this video, we are investigating the issues that can exist in a class where its constructor is making a call to a virtual method - specifically, the method that is overridden in the derived class.
After discovering a bug, and even making a couple of half-baked attempts to solve it, we are moving to a general solution to the problem. By the means of object-oriented design, and accepting that the constructor cannot use object's state for its purpose (it is the constructor the one to construct that state!), you will learn the coding technique where data are passed safely between constructors, removing any need for calling virtual methods at that stage.
Learn more from video courses:
Beginning Object-oriented Programming with C# ► https://codinghelmet.com/go/beginning...
Collections and Generics in C# ► https://codinghelmet.com/go/collectio...
Making Your C# Code More Object-oriented ► https://codinghelmet.com/go/making-yo...
Other courses at Pluralsight ► https://codinghelmet.com/go/pluralsight
Other courses at Udemy ► https://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 to Write Complex...
Coding with GitHub Copilot - Beginner to Master | VS Code Demo ► • A Comprehensive Guide to GitHub Copil...
What is Covariance and Contravariance in C# ► • What is Covariance and Contravariance...
How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ► • How to Initialize a Clean ASP.NET Cor...
The Null Conundrum: A Guide to Optional Objects in C# ► • How to Avoid Null Reference Exception...