Delphi Class References - Complete List by Gunny Mike

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
Delphi Class References - Complete List
Friday, May 1, 2020 - Gunny Mike

My comment: What would become of the future, if there were no active past!
[SHOWTOGROUPS=4,20]
I mistakenly hit "Publish" instead of "Save" last night which wound up making this post go live before it was finished. Oh well... it is what it is.

If you've read some of my earlier posts you know I have been struggling with thinking like a Delphi OOP programmer. I am self-taught. I started with Turbo Pascal 3. And I've been stuck in the top-down, structured mindset for a very long time. Until now.

A few days ago I rediscovered an older (still relevant) book that has been siting on my bookshelf for over twenty years. It's called Delevoping Custom Delphi 3 Components. It was written by Ray Kanopka ( Для просмотра ссылки Войди или Зарегистрируйся).

"This book is the greatest Delphi book ever."

Для просмотра ссылки Войди или Зарегистрируйся

I posted this image to the Для просмотра ссылки Войди или Зарегистрируйся.Warren Postma, who writes the Delphi Code Monkey blog (Для просмотра ссылки Войди или Зарегистрируйся), made this comment about the book. "This book is the greatest Delphi book ever."

I have only read through the first 43 pages. And I agree 100% with Postma. This is probably the greatest Delphi book ever written.

I never heard of Class References before. Maybe I did and just don't remember. But it doesn't matter. Kanopka introduces Delphi's Class References on page 42. He says, "Class references are typically used to treat a number of different classes as a single class." Then he goes on to explain how this works with a short, concise, extremely meaningful example. The Class Reference used is Для просмотра ссылки Войди или Зарегистрируйся.

Click! I get the concept. It's extremely powerful. Do I see an immediate need for implementing the use of a Class Reference? No. That doesn't mean it's not worth knowing about. Just having the knowledge that this is available is valuable.

I used to coach little league baseball when my boys were younger. There were usually twelve or thirteen kids on a team. You can only field nine kids at a time. So, a few of the kids sat on the bench and would get subbed into other positions as the game went on. One would become a right-fielder, one would become the second-baseman. And sometimes I'd do a double swap and replace the pitcher with a kid off the bench and replace the left-fielder with the kid who was pitching.

That's a nice little story Riley, but what does this have to do with Delphi's Class References?

Each position on a baseball team is filled by a baseball-player. Each individual position on the baseball team is slightly different but they all have one thing in common. They are all baseball-players for example;
  • TRightFielder : TBaseballPlayer;
  • TSecondBaseman : TBaseballPlayer;
  • TPitcher : TBaseballPlayer;
  • TLeftFielder : TBaseballPlayer;
There comes a time when you need to substitute a player or two, or three. Because we all know how mad the parents get when their kid doesn't play. So you have a player-substitute. But this player needs to play any position or quite possibly switch positions.
Код:
TBasballPlayerClass = class of TBaseballPlayer;

This lets you do suff like this:
Код:
Sub : TBaseballPlayerClass;
Sub1 : TBaseballPlayer;
Sub2 : TBaseballPlayer;
Sub3 : TBaseballPlayer;

Sub1 := Sub.Create ( Self ); //Sitting on the bench waiting to play
Sub2 := Sub.Create ( Self ); //Sitting on the bench waiting to play
Sub3 := Sub.Create ( Self ); //Sitting on the bench waiting to play

Sub1 := TBaseballPlayerClass ( TRightFielder ); //Play Right Field
Sub2 := TBaseballPlayerClass ( TSecondBaseman ); //Play Second Base
Sub3 := TBaseballPlayerClass ( TPitcher ); //Go Pitch

or if you change your mind at the last minute
Код:
Sub1 := Sub3; //You pitch instead
Sub3 := TBaseballPlayerClass ( TRightFielder ); //You go to Right Field

Once I understood the power and concept of Delphi's Class References I wondered just how many Class References are out there. So I did a search and created this list.

Enjoy
Semper Fi
Gunny Mike

HTML with List of Classes
Для просмотра ссылки Войди или Зарегистрируйся

Developing Custom Delphi 3 Components - Ray Konopka - 1997
[/SHOWTOGROUPS]
 
Последнее редактирование: