Class Constructors, Sometimes Not What You Expect - Delphi 215

  Рет қаралды 2,525

Alister Christie

Alister Christie

Күн бұрын

Пікірлер: 12
@Graham_Wideman
@Graham_Wideman Жыл бұрын
So the tricky point appears to be that for TDog.Create to get invoked, the compiler has to detect that the main body of code uses TDog. But not just _any_ use of TDog; the code has to use some method (or maybe field) that is specific to TDog. So even though at 4:00 the main code includes Writeln(TDog.MyClassName), that is not enough to prompt the compiler to run TDog.Create during unit initialization. Whereas at 4:55 Alister adds TDog.ClassName; and evidently that prompts the compiler to include code to run TDog.Create. It's not clear to me why the compiler would do that, since surely TDog.ClassName is known statically at compile time. Maybe the rules are written down somewhere :-). (This is all setting aside the odd idea of having a descendant class override the value in the ancestor class's "MyClassName", but OK I guess, just for testing the call sequence. It would be interesting to know what clever thing Alister was originally hoping to accomplish.)
@codegearguru
@codegearguru Жыл бұрын
Nice summary. I've been working with a project that has a DataSnap server with a TDataModule with about 300 TDSServerClass components on it. I was wanting some automated way of every ServerClass registering itself into a list. Then I could do away with about 2500 lines of code in the DataModule. I'll probably end up using RTTI, but I'll need a simple way to stop the TDSServerClasses being optimised out by the compiler. Basically, I want to change as little code as possible while eliminating lots of repeated code..
@thierrybo6304
@thierrybo6304 Жыл бұрын
interesting, with Lazarus at 04:04 I get TDog TDog
@codegearguru
@codegearguru Жыл бұрын
I haven't tried this, but it might be that the optimizer in Lazarus is not as aggressive as Delphi's.
@schobihh2703
@schobihh2703 11 ай бұрын
I am not sure if this programming pattern should be applied at all.
@epiblitik05
@epiblitik05 Жыл бұрын
Thanks for the video. insightful
@АлексейТашлинцев-м4ю
@АлексейТашлинцев-м4ю Жыл бұрын
Спасибо, очень интересно!
@kennethmark6868
@kennethmark6868 Жыл бұрын
Thanks for sharing, it is really confusion that the subclass class constructor not behaving as it should.
@codegearguru
@codegearguru Жыл бұрын
It's behaving as it should, just may not be as expected.
@jensknaack9016
@jensknaack9016 Жыл бұрын
Very interesting video. Thank you very much.
@Corsa15DT
@Corsa15DT 8 ай бұрын
rad optimization standards, interesting
@EmileVerhijden
@EmileVerhijden Жыл бұрын
As always... good video!
Using Interposer Classes - Delphi 223
11:57
Alister Christie
Рет қаралды 2,3 М.
What are Classes, Objects, and Constructors?
4:22
Web Dev Simplified
Рет қаралды 150 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Build Notepad.exe in Delphi - Delphi 231
34:29
Alister Christie
Рет қаралды 2,8 М.
Object Oriented Programming | Mutator, Accessor, Auxiliary and Constructor methods
14:57
Mr Long Education - IT & CAT
Рет қаралды 32 М.
Ways to Improve VCL Rendering Times - Delphi 236
10:37
Alister Christie
Рет қаралды 1,5 М.
SQLModel + FastAPI: Say Goodbye to Repetitive Database Code
19:50
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 159 М.
5 OOP Tips for Grade 12 IT
9:31
Mr Long Education - IT & CAT
Рет қаралды 6 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 572 М.
the TRUTH about C++ (is it worth your time?)
3:17
Low Level
Рет қаралды 794 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН