No video

Calling a Virtual Function From a Constructor? Bad Idea!

  Рет қаралды 1,419

Zoran Horvat

Zoran Horvat

Күн бұрын

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# ► codinghelmet.c...
Collections and Generics in C# ► codinghelmet.c...
Making Your C# Code More Object-oriented ► codinghelmet.c...
Other courses at Pluralsight ► codinghelmet.c...
Other courses at Udemy ► codinghelmet.c...
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...

Пікірлер: 4
@zoran-horvat
@zoran-horvat Жыл бұрын
Become a patron and get access to source code and exclusive live streams: www.patreon.com/posts/calling-virtual-81380300
@adamnorman85
@adamnorman85 2 жыл бұрын
Deserve all the appreciation, Thanks
@branislavpetrovic7486
@branislavpetrovic7486 2 жыл бұрын
Great video! Neat trick with factory method.
@RoshanTV3
@RoshanTV3 2 жыл бұрын
Good idea!)
Here Is When HashSet & Dictionary Call GetHashCode and Equals
7:32
Zoran Horvat
Рет қаралды 1,3 М.
5 Sure Signs You're No Longer Junior Programmer
13:21
Zoran Horvat
Рет қаралды 58 М.
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 79 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 25 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 6 МЛН
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 172 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Zero Allocations And Benchmarking In Golang
17:09
Anthony GG
Рет қаралды 8 М.
Bjarne Stroustrup: C++ | Lex Fridman Podcast #48
1:47:13
Lex Fridman
Рет қаралды 1 МЛН
Boolean Is Not Your Friend
12:45
Zoran Horvat
Рет қаралды 34 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Master the Design of Classes
11:56
Zoran Horvat
Рет қаралды 28 М.
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 79 МЛН