<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Respect Your Ancestors</title>
	<atom:link href="http://www.deltics.co.nz/blog/?feed=rss2&#038;p=833" rel="self" type="application/rss+xml" />
	<link>http://www.deltics.co.nz/blog/?p=833</link>
	<description>Keeping Pascal afloat in Aotearoa</description>
	<lastBuildDate>Tue, 18 Jun 2013 21:24:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Todd</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10817</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Mon, 23 Jan 2012 22:11:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10817</guid>
		<description><![CDATA[I agree, a compiler hint would be helpful. Perhaps a specific hint, which can be turned off.

Also agree with the need for AfterConstruction()/BeforeDestruction() in some circumstances.]]></description>
		<content:encoded><![CDATA[<p>I agree, a compiler hint would be helpful. Perhaps a specific hint, which can be turned off.</p>
<p>Also agree with the need for AfterConstruction()/BeforeDestruction() in some circumstances.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deltics</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10786</link>
		<dc:creator>Deltics</dc:creator>
		<pubDate>Tue, 13 Dec 2011 19:47:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10786</guid>
		<description><![CDATA[Eric: &quot;The only initialization that should happen post-construction in a good design is one that is context-dependent &quot;

The arrogance of such unilateral statements of &quot;rightness&quot; is staggering.  It denies the possibility that there may be requirements beyond what you consider able to be met by your notion of a &quot;pure&quot; design.

In the case of a (domain specific) framework I am currently working on I have a base class which is a container for a variety of objects.  However, that base class itself has further classes derived from it.  It is the derived classes that are responsible for populating the container.  Once the container class is populated - and only after that has taken place - there are processes in the base class that must then take place, and these processes themselves may be extended by the derived container classes.

&quot;Strongly disagree&quot; all you like, but if you would just take your constructor/AfterConstruction blinkers off for a moment (that process I just described is NOT part of the constructor process), you will see that that specific bone that you cannot let go of is just one example of the general case of an extension point in a class that is designed in the base class to be reliably and predictably followed by the execution of a further extension point.

The argument over whether or not designing such behaviour into a constructor (with AfterConstruction providing the follow-on extension point) is completely and utterly irrelevant to the general question of whether the compiler should provide hints/warnings if you fail to invoke the inherited behaviour of an overridden, virtual method.

Those occasions when you consider those warning wouldn&#039;t make sense would be FAR less than &quot;half the time&quot;.  On those relatively rare occasions that the warning would be undesirable there would be a partner mechanism for indicating this IN THE CODE, so that you could see the deliberate intent in NOT calling inherited.  If you are simply ideologically opposed to the idea of such a warning you would of course be able to just disable that warning in your project settings, like all the other warnings that may or may not be relevant to your project (or offend your purist sensibilities ;)).



Having said that, given that you cannot change the COM-style reference counting behaviour required to be supported in Delphi, I would love to see your solution to the potential constructor suiciding interfaced object that completely avoids the need for AfterConstruction or any other similar (but equally reliable, predictable and dependable) mechanism.  Think outside the box all you like, but your solution must still fit *inside* the box you already have:  Invention of time machines, reliance on arbitrary rules imposed on developers using your base class which cannot be enforced by the compiler or framework constraints, disregarding inconveniences such as the original requirements and purpose of the reference counting mechanism and it&#039;s COM origins are all of course not allowed.  ;)]]></description>
		<content:encoded><![CDATA[<p>Eric: &#8220;The only initialization that should happen post-construction in a good design is one that is context-dependent &#8221;</p>
<p>The arrogance of such unilateral statements of &#8220;rightness&#8221; is staggering.  It denies the possibility that there may be requirements beyond what you consider able to be met by your notion of a &#8220;pure&#8221; design.</p>
<p>In the case of a (domain specific) framework I am currently working on I have a base class which is a container for a variety of objects.  However, that base class itself has further classes derived from it.  It is the derived classes that are responsible for populating the container.  Once the container class is populated &#8211; and only after that has taken place &#8211; there are processes in the base class that must then take place, and these processes themselves may be extended by the derived container classes.</p>
<p>&#8220;Strongly disagree&#8221; all you like, but if you would just take your constructor/AfterConstruction blinkers off for a moment (that process I just described is NOT part of the constructor process), you will see that that specific bone that you cannot let go of is just one example of the general case of an extension point in a class that is designed in the base class to be reliably and predictably followed by the execution of a further extension point.</p>
<p>The argument over whether or not designing such behaviour into a constructor (with AfterConstruction providing the follow-on extension point) is completely and utterly irrelevant to the general question of whether the compiler should provide hints/warnings if you fail to invoke the inherited behaviour of an overridden, virtual method.</p>
<p>Those occasions when you consider those warning wouldn&#8217;t make sense would be FAR less than &#8220;half the time&#8221;.  On those relatively rare occasions that the warning would be undesirable there would be a partner mechanism for indicating this IN THE CODE, so that you could see the deliberate intent in NOT calling inherited.  If you are simply ideologically opposed to the idea of such a warning you would of course be able to just disable that warning in your project settings, like all the other warnings that may or may not be relevant to your project (or offend your purist sensibilities <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<p>Having said that, given that you cannot change the COM-style reference counting behaviour required to be supported in Delphi, I would love to see your solution to the potential constructor suiciding interfaced object that completely avoids the need for AfterConstruction or any other similar (but equally reliable, predictable and dependable) mechanism.  Think outside the box all you like, but your solution must still fit *inside* the box you already have:  Invention of time machines, reliance on arbitrary rules imposed on developers using your base class which cannot be enforced by the compiler or framework constraints, disregarding inconveniences such as the original requirements and purpose of the reference counting mechanism and it&#8217;s COM origins are all of course not allowed.  <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10785</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 13 Dec 2011 07:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10785</guid>
		<description><![CDATA[&quot;If you implement a base class that requires post-constructor initialisation&quot;

The only initialization that should happen post-construction in a good design is one that is context-dependent (ie. requires passing context-related parameters, references, etc.), and for those AfterConstruction is not appropriate (doesn&#039;t accept context).

So you will never see a good design that &quot;requires&quot; such a context-independent post-constructor initialization...

&quot;but have nothing what-so-ever to do with the original problem&quot;

I strongly disagree here.

There are two cases in which calling the inherited constructor warrants a warning in a consistent fashion, that&#039;s in a constructor/destructor. Delphi lacks that, sure, but even if it had one, it wouldn&#039;t have helped you since you were using AfterConstruction, which being a kludge/hack is the last place where you would went it (whenever you&#039;re using it, you know you&#039;re doing something dirty in the first place).

Now, if you had complained that Delphi should warn about missing inherited calls (or multiple inherited calls btw) in the constructor or destructor, I would have agreed, but in AfterConstruction? No, that thing is a place for dirty hacks, it&#039;s worth a warning on its own.

And I don&#039;t agree about warning about inherited calls on overridden methods in general, because it wouldn&#039;t make any sense half the time (think Paint, Walk, Quack, etc. actually it only makes sense if the subclass implements only a slight variation or adds to an already implemenetd behavior, but doesn&#039;t define the behavior)]]></description>
		<content:encoded><![CDATA[<p>&#8220;If you implement a base class that requires post-constructor initialisation&#8221;</p>
<p>The only initialization that should happen post-construction in a good design is one that is context-dependent (ie. requires passing context-related parameters, references, etc.), and for those AfterConstruction is not appropriate (doesn&#8217;t accept context).</p>
<p>So you will never see a good design that &#8220;requires&#8221; such a context-independent post-constructor initialization&#8230;</p>
<p>&#8220;but have nothing what-so-ever to do with the original problem&#8221;</p>
<p>I strongly disagree here.</p>
<p>There are two cases in which calling the inherited constructor warrants a warning in a consistent fashion, that&#8217;s in a constructor/destructor. Delphi lacks that, sure, but even if it had one, it wouldn&#8217;t have helped you since you were using AfterConstruction, which being a kludge/hack is the last place where you would went it (whenever you&#8217;re using it, you know you&#8217;re doing something dirty in the first place).</p>
<p>Now, if you had complained that Delphi should warn about missing inherited calls (or multiple inherited calls btw) in the constructor or destructor, I would have agreed, but in AfterConstruction? No, that thing is a place for dirty hacks, it&#8217;s worth a warning on its own.</p>
<p>And I don&#8217;t agree about warning about inherited calls on overridden methods in general, because it wouldn&#8217;t make any sense half the time (think Paint, Walk, Quack, etc. actually it only makes sense if the subclass implements only a slight variation or adds to an already implemenetd behavior, but doesn&#8217;t define the behavior)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deltics</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10784</link>
		<dc:creator>Deltics</dc:creator>
		<pubDate>Mon, 12 Dec 2011 19:47:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10784</guid>
		<description><![CDATA[LDS, yes I know there are sometimes valid reasons for not calling inherited (and in older versions of Delphi doing so could actually be a mistake - remember when calling inherited on the first override of an inherited abstract method used to raise an EAbstract error ?), but these are very few and far between.

Maybe a hint would be a better idea than a warning and maybe some new, specific compiler directive that could be declared in the method body to suppress that hint/warning would be better than having to disable hints/warnings entirely in or around the entire method or it&#039;s body.

I am not hung up on the particular solution to the problem, but I do think it is a problem worth giving a little time to thinking about .

This isn&#039;t the first time it has caught me out - perhaps the 2nd or 3rd, I don&#039;t recall precisely - but this occasion was the most expensive in terms of red herrings and wild geese I ended up chasing as a result of the symptoms of the bug being so easily confused with an error in my framework relationships.]]></description>
		<content:encoded><![CDATA[<p>LDS, yes I know there are sometimes valid reasons for not calling inherited (and in older versions of Delphi doing so could actually be a mistake &#8211; remember when calling inherited on the first override of an inherited abstract method used to raise an EAbstract error ?), but these are very few and far between.</p>
<p>Maybe a hint would be a better idea than a warning and maybe some new, specific compiler directive that could be declared in the method body to suppress that hint/warning would be better than having to disable hints/warnings entirely in or around the entire method or it&#8217;s body.</p>
<p>I am not hung up on the particular solution to the problem, but I do think it is a problem worth giving a little time to thinking about .</p>
<p>This isn&#8217;t the first time it has caught me out &#8211; perhaps the 2nd or 3rd, I don&#8217;t recall precisely &#8211; but this occasion was the most expensive in terms of red herrings and wild geese I ended up chasing as a result of the symptoms of the bug being so easily confused with an error in my framework relationships.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deltics</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10783</link>
		<dc:creator>Deltics</dc:creator>
		<pubDate>Mon, 12 Dec 2011 19:38:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10783</guid>
		<description><![CDATA[Eric, it&#039;s all well and good &quot;thinking out of the box&quot;, but in reality you still have to work *IN* the box you are given.

Delphi has custom, virtual constructors.  If you implement a base class that requires post-constructor initialisation then it is no good coding your base class sanitarily when people can derive from your class and not follow your own ideal model.  Sure, you can say &quot;it&#039;s their own fault&quot; when it doesn&#039;t work, but in practice you know that isn&#039;t how people think.

Similarly, and specifically, the way reference counting is implemented in Delphi is *IN THE BOX*.  Think outside the box all you like, you cannot change what the compiler is producing, you simply have to work with it.

To get the Delphi you appear to want, you must first invent a time machine.  :)

But all of that pipe dreaming is completely irrelevant anyway.  Your objections to using AfterConstruction may have intellectual value and purity on their side, but have nothing what-so-ever to do with the original problem (I perhaps should have left it simply at that in the first place rather than appearing to engage in a debate on that precise subject :().

The original problem is far more general:  simply an accidentally omitted call to the inherited implementation of an overridden virtual method.  It just so happened that the specific method in this case was AfterConstruction, but the [no doubt interesting] debate over that is a side-show to the fundamental problem I was posting about.  :)]]></description>
		<content:encoded><![CDATA[<p>Eric, it&#8217;s all well and good &#8220;thinking out of the box&#8221;, but in reality you still have to work *IN* the box you are given.</p>
<p>Delphi has custom, virtual constructors.  If you implement a base class that requires post-constructor initialisation then it is no good coding your base class sanitarily when people can derive from your class and not follow your own ideal model.  Sure, you can say &#8220;it&#8217;s their own fault&#8221; when it doesn&#8217;t work, but in practice you know that isn&#8217;t how people think.</p>
<p>Similarly, and specifically, the way reference counting is implemented in Delphi is *IN THE BOX*.  Think outside the box all you like, you cannot change what the compiler is producing, you simply have to work with it.</p>
<p>To get the Delphi you appear to want, you must first invent a time machine.  <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But all of that pipe dreaming is completely irrelevant anyway.  Your objections to using AfterConstruction may have intellectual value and purity on their side, but have nothing what-so-ever to do with the original problem (I perhaps should have left it simply at that in the first place rather than appearing to engage in a debate on that precise subject <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ).</p>
<p>The original problem is far more general:  simply an accidentally omitted call to the inherited implementation of an overridden virtual method.  It just so happened that the specific method in this case was AfterConstruction, but the [no doubt interesting] debate over that is a side-show to the fundamental problem I was posting about.  <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LDS</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10782</link>
		<dc:creator>LDS</dc:creator>
		<pubDate>Mon, 12 Dec 2011 10:55:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10782</guid>
		<description><![CDATA[The problem is that calling the inherited implementation is not mandatory in OOP. Although often it makes sense, there are implementations where a derived object may implement a very different behaviour that does not require a call to the parent one.  Or for some reason the parent method may just raise an exception when called.
A warning could be &quot;too much&quot;, maybe an &quot;hint&quot; could be better, but there is not really nothing wrong &quot;per se&quot; avoiding an &quot;inherited&quot; call.
I got the habit of always starting an overridden method adding the proper &quot;inherited&quot; call, but that&#039;s just a best practice.]]></description>
		<content:encoded><![CDATA[<p>The problem is that calling the inherited implementation is not mandatory in OOP. Although often it makes sense, there are implementations where a derived object may implement a very different behaviour that does not require a call to the parent one.  Or for some reason the parent method may just raise an exception when called.<br />
A warning could be &#8220;too much&#8221;, maybe an &#8220;hint&#8221; could be better, but there is not really nothing wrong &#8220;per se&#8221; avoiding an &#8220;inherited&#8221; call.<br />
I got the habit of always starting an overridden method adding the proper &#8220;inherited&#8221; call, but that&#8217;s just a best practice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.deltics.co.nz/blog/?p=833&#038;cpage=1#comment-10781</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Mon, 12 Dec 2011 09:22:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=833#comment-10781</guid>
		<description><![CDATA[Actually, no you really don&#039;t need them, think out of the box here.

The VCL uses them to manage state f.i., which is then &quot;if&quot;-checked to prevent events getting potentially triggered during the destruction... if you needed a big signpost that screams &quot;design issue&quot;, look no further.

There are two different concepts really that are mishmashed and AfterConstruction/BeforeDestruction kludge their way to re-separate them: clean up the design by separating construction (memory management really) from initialization (putting values), and do similarly for destruction.
Here is your &quot;equivalent mechanism&quot;, except it&#039;s NOT equivalent, as it cleaned up your design, and rather than working around a design issue of mishmashed concepts, you now have a design feature, that eliminates the need for magic state-dependent switches, grants your classes safe and simple pooling/streaming capability, facilitates DI &amp; AOP, etc.

The refcounting use of AfterConstruction is a hack to plug reference-counted memory management at a non-root object level of the class hierarchy, while making way for reference-counted classes that are not reference-counted... And that last kludge is the root of the &quot;need&quot;: without it, the refcounting could simply have taken place at the call site (as usual). And you &quot;need&quot; refcounted classes that aren&#039;t refcounted in Delphi if you want to use interfaces on VCL classes, because interfaces are hard-tied to refcounting... another mishmash between an OO abstraction concept and a memory management technique.

Last use of AfterConstruction is a dubious convenience use for TThread, when CreateSuspend is false... not exactly and earth shattering use scenario either, first because it encourages mixing construction &amp; initialization, second because at most, it saves one explicit &quot;Start&quot; at the expense of having an implicit boolean passed... doesn&#039;t really make for more explicit code, does it?

So all in all, there just isn&#039;t one non-kludgy reason to have those methods in Delphi.]]></description>
		<content:encoded><![CDATA[<p>Actually, no you really don&#8217;t need them, think out of the box here.</p>
<p>The VCL uses them to manage state f.i., which is then &#8220;if&#8221;-checked to prevent events getting potentially triggered during the destruction&#8230; if you needed a big signpost that screams &#8220;design issue&#8221;, look no further.</p>
<p>There are two different concepts really that are mishmashed and AfterConstruction/BeforeDestruction kludge their way to re-separate them: clean up the design by separating construction (memory management really) from initialization (putting values), and do similarly for destruction.<br />
Here is your &#8220;equivalent mechanism&#8221;, except it&#8217;s NOT equivalent, as it cleaned up your design, and rather than working around a design issue of mishmashed concepts, you now have a design feature, that eliminates the need for magic state-dependent switches, grants your classes safe and simple pooling/streaming capability, facilitates DI &amp; AOP, etc.</p>
<p>The refcounting use of AfterConstruction is a hack to plug reference-counted memory management at a non-root object level of the class hierarchy, while making way for reference-counted classes that are not reference-counted&#8230; And that last kludge is the root of the &#8220;need&#8221;: without it, the refcounting could simply have taken place at the call site (as usual). And you &#8220;need&#8221; refcounted classes that aren&#8217;t refcounted in Delphi if you want to use interfaces on VCL classes, because interfaces are hard-tied to refcounting&#8230; another mishmash between an OO abstraction concept and a memory management technique.</p>
<p>Last use of AfterConstruction is a dubious convenience use for TThread, when CreateSuspend is false&#8230; not exactly and earth shattering use scenario either, first because it encourages mixing construction &amp; initialization, second because at most, it saves one explicit &#8220;Start&#8221; at the expense of having an implicit boolean passed&#8230; doesn&#8217;t really make for more explicit code, does it?</p>
<p>So all in all, there just isn&#8217;t one non-kludgy reason to have those methods in Delphi.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
