tag:blogger.com,1999:blog-2428374771421713311.post1486115990026064284..comments2024-03-10T12:04:17.661-07:00Comments on The Oracle at Delphi: Better smart-linking through class constructionAnonymoushttp://www.blogger.com/profile/10119008505905401707noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-2428374771421713311.post-14593258303453354942009-05-29T02:28:56.000-07:002009-05-29T02:28:56.000-07:00Really nice Allen!. Just one thing comes to my min...Really nice Allen!. Just one thing comes to my mind, in my apps y frecuently use Dlls as plugins, with singleton objects shared between the main app and the plugins, for example the database connection object. Now I wonder how the memory manager will handle this if I change my singleton objects by this new singleton classes?, if the application.handle is shared, then the singletons classes will point to the same memory address?.<br><br>Leonardo.Leonardo M. Raméhttp://leonardorame.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-8513961237427605052009-06-01T15:29:25.000-07:002009-06-01T15:29:25.000-07:00I recently bumped into this issue. I'm writing...I recently bumped into this issue. I'm writing a program I want to keep as small as possible, as it will run permanently. There was a 'nice to have' feature, requiring clipboard support. But I ditched this feature, as soon as I saw the impact of adding the Clipbrd unit to the project, that's several 100 K. <br><br>Only I'm not sure if your class constructors would easily solve this issue. Because I do want to use the clipboard singleton object, but only to put a bitmap on the Windows clipboard. It seems to me the required code size can't be more then a couple of KB. I guess the Clipbrd unit drags in a lot of unrelated code, but to prevent this, we would probably need more in the line of 'smart method pruning'.Victornoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-71421946134724523712011-04-30T13:41:26.000-07:002011-04-30T13:41:26.000-07:00[...] T0 use extended RTTI, you need a TRttiContex...[...] T0 use extended RTTI, you need a TRttiContext. It’s an interface to a global RTTI object pool, and you only need one of them. So it makes sense to attach it at the class level instead of to each individual object. So as long as we’re doing this the Delphi 2010 way, let’s put it in a class constructor. [...]TURBU Tech » Blog Archive » Abusing extended RTTI for fun and profithttp://tech.turbu-rpg.com/79/abusing-extended-rtti-for-fun-and-profitnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-60639261698993336552009-07-02T02:17:10.000-07:002009-07-02T02:17:10.000-07:00You say "beware of cycles". Do you have...You say "beware of cycles". Do you have any safeguards in place to keep circular dependencies from screwing things up? If you go and introduce the static initialization order fiasco into Delphi, I'll never forgive you, Allen...Mason Wheelerhttp://www.turbu-rpg.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-72972188138353828902009-07-07T16:17:40.000-07:002009-07-07T16:17:40.000-07:00>I can’t think of a case where you’d need "...>I can’t think of a case where you’d need "class const" or "class type".<br><br>class const:<br>I know lots of "global constants" that actually belong to a certain class. Declaring them globally just clutters the name space but doesn't offer any additional functionality. It's also a good practice to hide this stuff (private, protected) if it's not really required outside of the class.<br><br>class type:<br>This is less common, but I think everybody knows some types that internally store data in a record/object. This data object is not used outside of the class, but you need to declare it globally as you reference to it (Yes, you can declare it loacally and use Pointer/TObject in the interface. Good bye type safety and Happy Casting is all I say...).<br>Class Types are a much cleaner way to ensure that this type is available at declaration level but still hidden from the rest of the world. (You can even declare it protected and allow descendents of your class to use it as well...)Daniel Bernhardnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-75235634783571532282009-05-29T03:48:43.000-07:002009-05-29T03:48:43.000-07:00Interesting, classes seem much more complete now t...Interesting, classes seem much more complete now than they did a few versions ago, with every member that needs it now having a "class" equivalent.<br><br>TMyClass = class<br> const a = 10;<br> type TMyEnum = (e1, e2, e3);<br> {class} var<br> Var1: Integer;<br> Var2: Integer;<br> {class} constructor Create;<br> {class} destructor Destroy;<br> {class} procedure Proc; {static;}<br> {class} function Func: Integer; {static;}<br> {class} property Prop: Integer read Var1;<br>end;<br><br>I can't think of a case where you'd need "class const" or "class type".Dan Bartlettnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-82853796824091200842009-08-27T03:41:36.000-07:002009-08-27T03:41:36.000-07:00[...] constructors. I know Alan mentioned them aft...[...] constructors. I know Alan mentioned them after Delphi Live but I didn’t see any mention about them in the recent flurry of information. These are really [...]Better than you’ve been told… « Source Code Adventureshttp://sourcecodeadventures.wordpress.com/2009/08/27/better-than-youve-been-told/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-66245401394355793752009-05-29T04:10:08.000-07:002009-05-29T04:10:08.000-07:00Really nice!Love it if you remove the need to avoi...Really nice!<br>Love it if you remove the need to avoid most Delphi librarys to not take the bloat hit when i just need something small from that unit.<br><br>Keep that route of improving things and become open...<br>Loved the lab videos.<br><br>We need more infos/videos of the things youre "toying" around :)Peter Meiernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-49790876880339228212009-05-29T06:33:31.000-07:002009-05-29T06:33:31.000-07:00@Clinton Johnson.Not everyone is sitting in a lazy...@Clinton Johnson.<br>Not everyone is sitting in a lazy old company that only develops Intranet/DVD stuff for goverment agencys, that are happy when the thing works somehow...<br><br>The world is moving and also introducing new distribution channels, technologies and massive userbases...<br><br>Don't look at your needs and say none is going to profit from a solution to codesize explosions.<br><br>One aspect is true... the solution should not tamper with all code like many solutions they implemented to make Delphi more compatible with C++ Builder or include some multithreading locks and stuff.<br><br>They should do it but implement it in a clean way and make a commandline switch for it.Peter Meiernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-60164510462944653112009-08-29T21:34:47.000-07:002009-08-29T21:34:47.000-07:00TSingleton's instance constructor have to be a...TSingleton's instance constructor have to be a private member too. The only problem is that Delphi compiler is not able to hide the instance constructor, therefore you can create an instance like this:<br><br>var<br> S: TSingleton;<br>begin<br> S := TSingleton.Create;<br> ... <br><br>Unfortunately, this is an incorrect behavior.Janos Jankahttp://janosjanka.spaces.live.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-16927945119048564182009-08-29T23:42:12.000-07:002009-08-29T23:42:12.000-07:00TSingleton's instance constructor has to be a ...TSingleton's instance constructor has to be a private member too. The only problem is that Delphi compiler is not able to hide instance constructors, therefore this singleton behavior is avoidable in the above code.Janos Jankahttp://janosjanka.spaces.live.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-78370169585281224132009-05-31T14:40:03.000-07:002009-05-31T14:40:03.000-07:00I really really like new language features that wo...I really really like new language features that would make my code cleaner, faster and smaller. <br>But what would make my code even smaller and cleaner would be a more extensive VCL that would standardize common algorithms. For example in the current project I work on there are 3 different implementations of CRC32 and 2 different implementations of Blowfish encryption… <br><br>Now regarding “class constructor”. What I think would be great addition is a compiler switch that adds automatic logging for each constructor/destructor/initialization/finalization call. The programmer can decide if the logging is done to a log file or whatever it attached to the IDE for online inspecting (There is a side benefit for Embarcadero – the log files could be used for unit testing in future version to see they have not changed the behavior of the initialization order). <br><br>Thanks, <br>Yoni.Yoninoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-40868282549649188632009-05-31T15:55:32.000-07:002009-05-31T15:55:32.000-07:00Love it!@Clinton Johnson> I suspect the actuall...Love it!<br><br>@Clinton Johnson<br>> I suspect the actually real world size benefits will be negligable for 99.9% of cases for 99.9% of people.<br>Agreed. But you could say that of a lot of features and yet I don't want them removed. For example - how many projects replace the default callback functions that determine which exception classes are raised for external exceptions? Yet, when I needed it, I could replace those functions and get back meaningful error messages from non-Delphi code we use. So a seldom-used feature has become invaluable to us.<br><br>Oh, and it saves you some time at startup too. That will likely be significant on a lot of large projects.Cobus Krugernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-2959377261990864692009-06-01T19:09:49.000-07:002009-06-01T19:09:49.000-07:00Delphi Prism has something similar to this:TStatic...Delphi Prism has something similar to this:<br><br>TStatic = static class<br>private<br>FField: Integer;<br>public<br>constructor Create;<br>destructor Destroy;<br>end;<br><br>Which translates to this:<br><br>TStatic = class<br>private<br>class var FField: Integer;<br>public<br>class constructor Create;<br>class destructor Destroy;<br>end;<br><br>Could we have this shortcut in Delphi for Win32, too? <br><br>It makes implementing the Singleton pattern so much easier ... you don't even need to make an instance of the class which safes the additional bytes needed for Self. ;)Jens Mühlenhoffnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-58194423474650972772009-07-02T04:58:37.000-07:002009-07-02T04:58:37.000-07:00@Dan Bartlett: >I can’t think of a case where y...@Dan Bartlett: <br>>I can’t think of a case where you’d need "class const" or "class type".<br><br>I can. I can think of plenty of uses for them, actually. Well, for class consts at least. More specifically, for virtual class consts.<br><br>For example, if you have a large hierarchy of classes descended from one base class, and you want to put a unique tag on each class, (very useful as a sanity check for serialization purposes,) right now you need to write that as a virtual function that returns a hard-coded literal value. It would be a lot nicer to just put that literal value directly into the VMT as a virtual class constant.Mason Wheelerhttp://www.turbu-rpg.comnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-68348882639708896932009-06-02T16:21:20.000-07:002009-06-02T16:21:20.000-07:00An already existing way of avoiding unwanted linki...An already existing way of avoiding unwanted linking in spite of a (singleton) class initialization:<br><br>"divide and conquer" :)<br><br>Using 2 units (and optionally the project explorer convenience "directory ruled treview" to group those 2 units under a specific path) allows one to include the class unit at no cost. The Initiator unit have to be consciously included to let the "singleton magic" operate.<br><br>unit MySingletonClass; // may be included everywhere<br><br>Type<br> TMySingletonClas = ... ;<br><br>unit MySingletonClass_Initiator; // should be included only if required<br><br>uses<br> MySingletonClass;<br><br>initialization<br> // do initialize the singleton class here<br>finalization<br> // do free the singleton class hereLoïs Béguéhttp://www.arpoon.denoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-22688454494090792832011-12-05T17:21:48.000-08:002011-12-05T17:21:48.000-08:00Then you have winter coats that are greater for in...Then you have winter coats that are greater for individuals snowy windy days at the hockey rink. And then you have ski jackets which are complete other sub-genre of winter season coats. Do not even get me commenced on womens coats. <a href="http://www.monclerjacketswomen-sale.com/" title="moncler jackets women sale" rel="nofollow"><b>moncler jackets women sale</b></a> And then there’s the numerous assortment of winter coat manufacturers There’s MEC, Canada Goose, North Confront, Sierra Patterns, Columbia, Spy, Couloir, Keely, and a lot of several more.So you want to be warm this winter… and you have heard parkas are very hot even in arctic temperatures… but what’s a parka? Initially, parkas had been worn by the Inuit and other Arctic peoples.<a href="http://www.monclerdownjacketsmall.com/" title="Moncler Down Jackets" rel="nofollow"><b>Moncler Down Jackets</b></a> The regular parka layout is truly “a pullover product outer garment created from caribou skin having a fur lining close to the hood”. The idea getting that if animals could stay warm, individuals could put on their skins and remain sizzling also, even in most likely the most inhospitable situations.chuangccchttp://www.canadagooseparkasjackets.com/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-68948789955990978882014-01-11T00:44:47.000-08:002014-01-11T00:44:47.000-08:00Actually, in Delphi XE, using class destructor for...Actually, in Delphi XE, using class destructor for TGestureManager causes an access violation in TGestureManager.Destroy, as FInstanceList is freed in Class Destructor, which is called before component destructor. <br><br>Refer to GestureMgr.pas, line 651.Ronaldnoreply@blogger.com