On 19 April 2012 09:52, <[email protected]> wrote: > > The Hack says it all.
The "Hack" part is just a name. I could very well have named that TCustomEditFriend. > Here you are working outside regular OOP rules. Saying that, then how does the new Delphi/FPC "friend class" language feature fit into that statement of yours. Or how does Delphi's new RTTI which can access private and protected class data fit into this. Delphi is not the only language with that "RTTI" feature. C# in .NET and Java etc all have support for what is now know as Reflection. They have full access to everything defined in a class. If there wasn't a need for sometimes "breaking the class visibility rules", the RTTI or Reflection would never have been implemented in the various programming languages. > The correct way would have been an implementation for each descendent of > TCustomEdit. Have you got any idea how many TCustomEdit descendants there are? Delphi supplied ones and 3rd party ones? All I can say is, there are a lot, and having to modify the tiOPF framework for every new 3rd party or delphi component is nuts. There goes the rule of OOP code reuse. And my example applies to all standard components and their descendants, not just TCustomEdit. As you might know, I am a big proponent of OOP, but I would be lying to myself if I said OOP is perfect. There are valid cases where OOP rules need to be bent ever so slightly. Reflection, the new Delphi RTTI and the concept of "friend classes" are all proof of this. Also, as I mentioned, this is one example. There are many other cases too. Maybe they will make even better arguments, but we would never know. -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
