<?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"
	>
<channel>
	<title>Comments on: The Observer Pattern</title>
	<atom:link href="http://blogs.teamb.com/joannacarter/2004/06/30/690/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/joannacarter/2004/06/30/690</link>
	<description></description>
	<pubDate>Tue, 16 Mar 2010 17:48:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Mike S</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-18</link>
		<dc:creator>Mike S</dc:creator>
		<pubDate>Tue, 28 Mar 2006 00:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-18</guid>
		<description>Nice article and thanks for putting it together.&lt;br&gt;&lt;br&gt;Do you have a working example available for download?  It is much easier to start with something that works and I have been completely unsuccessful in splicing &lt;br&gt;together the various snippets.</description>
		<content:encoded><![CDATA[<p>Nice article and thanks for putting it together.</p>
<p>Do you have a working example available for download?  It is much easier to start with something that works and I have been completely unsuccessful in splicing<br />
<br />together the various snippets.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joanna Carter</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-17</link>
		<dc:creator>Joanna Carter</dc:creator>
		<pubDate>Thu, 09 Jun 2005 13:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-17</guid>
		<description>No, using interface references for delegation is just as valid as objects as long as you are aware of the refcounting and QueryInterface implications.</description>
		<content:encoded><![CDATA[<p>No, using interface references for delegation is just as valid as objects as long as you are aware of the refcounting and QueryInterface implications.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilia Frenkel</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-27</link>
		<dc:creator>Ilia Frenkel</dc:creator>
		<pubDate>Thu, 09 Jun 2005 13:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-27</guid>
		<description>Great article!&lt;br&gt;I have some remark, though:&lt;br&gt;  TClockTimer = class(TInterfacedObject, IClockTimer, ISubject)&lt;br&gt;  private&lt;br&gt;    fTimer: TTimer;&lt;br&gt;    fInternalTime: TDateTime;&lt;br&gt;    fSubject: --&#62;ISubject&#60;--;&lt;br&gt;    function GetTime: TDateTime;&lt;br&gt;    procedure Tick(Sender: TObject);&lt;br&gt;    property Subject: --&#62;ISubject&#60;--&lt;br&gt;             read fSubject&lt;br&gt;             implements ISubject;&lt;br&gt;  public&lt;br&gt;    constructor Create;&lt;br&gt;  end;&lt;br&gt;&lt;br&gt;Shouldn't it be TSubject?&lt;br&gt;&lt;br&gt;---&lt;br&gt;Best regards, Ilia Frenkel.</description>
		<content:encoded><![CDATA[<p>Great article!<br />
<br />I have some remark, though:<br />
<br />  TClockTimer = class(TInterfacedObject, IClockTimer, ISubject)<br />
<br />  private<br />
<br />    fTimer: TTimer;<br />
<br />    fInternalTime: TDateTime;<br />
<br />    fSubject: &#8211;&gt;ISubject&lt;&#8211;;<br />
<br />    function GetTime: TDateTime;<br />
<br />    procedure Tick(Sender: TObject);<br />
<br />    property Subject: &#8211;&gt;ISubject&lt;&#8211;<br />
<br />             read fSubject<br />
<br />             implements ISubject;<br />
<br />  public<br />
<br />    constructor Create;<br />
<br />  end;</p>
<p>Shouldn&#8217;t it be TSubject?</p>
<p>&#8212;<br />
<br />Best regards, Ilia Frenkel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joanna Carter</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-25</link>
		<dc:creator>Joanna Carter</dc:creator>
		<pubDate>Wed, 20 Oct 2004 00:18:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-25</guid>
		<description>&#62; Great article! But I think there are some small&lt;br&gt;&#62; problems in it. &lt;br&gt;&#62; 1 just as Lars Christian Svane said, :) &lt;br&gt;&#62; (DigitalClock1 as ISubject).Attach(fClockTimer as&lt;br&gt;&#62; IObserver); &lt;br&gt;&#62; should be: &lt;br&gt;&#62; (fClockTimer as ISubject).Attach(DigitalClock1 as&lt;br&gt;&#62; IObserver); &lt;br&gt;&lt;br&gt;Yes, I should change this :-)&lt;br&gt;&lt;br&gt;&#62; 2 &lt;br&gt;&#62; fController: Pointer; &lt;br&gt;&#62; should be: &lt;br&gt;&#62; fController: IInterface; &lt;br&gt;&#60;snip&#62;&lt;br&gt;&#62; Why? &lt;br&gt;&#62; If fController is defined as a Pointer type, I&lt;br&gt;&#62; think it is a pointer type cast and not a&lt;br&gt;&#62; interface reference in code&lt;br&gt;&#62; &#34;fController := Pointer(Controller)&#34;. you have to&lt;br&gt;&#62; add &#34;Controller._AddRef;&#34; to avoid a access&lt;br&gt;&#62; violation. &lt;br&gt;&lt;br&gt;The use of the Pointer is known as a 'weak reference' and is used to break the circular refcount problem where an outer class holds a reference to an inner class and an inner class holds a reference to the outer class. This then means that neither of the refcounts get to drop to zero thus causing a memory leak. Assigning to a Pointer means that the refcount of the Controller is not incremented from the one that is holding the outer (controller) object; therefore, when that ref falls out of scope it then drops to zero releasing the outer object which, in turn releases the inner object.&lt;br&gt;&lt;br&gt;Try it :-)&lt;br&gt;&lt;br&gt;Joanna</description>
		<content:encoded><![CDATA[<p>&gt; Great article! But I think there are some small<br />
<br />&gt; problems in it.<br />
<br />&gt; 1 just as Lars Christian Svane said, <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<br />&gt; (DigitalClock1 as ISubject).Attach(fClockTimer as<br />
<br />&gt; IObserver);<br />
<br />&gt; should be:<br />
<br />&gt; (fClockTimer as ISubject).Attach(DigitalClock1 as<br />
<br />&gt; IObserver); </p>
<p>Yes, I should change this <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&gt; 2<br />
<br />&gt; fController: Pointer;<br />
<br />&gt; should be:<br />
<br />&gt; fController: IInterface;<br />
<br />&lt;snip&gt;<br />
<br />&gt; Why?<br />
<br />&gt; If fController is defined as a Pointer type, I<br />
<br />&gt; think it is a pointer type cast and not a<br />
<br />&gt; interface reference in code<br />
<br />&gt; &quot;fController := Pointer(Controller)&quot;. you have to<br />
<br />&gt; add &quot;Controller._AddRef;&quot; to avoid a access<br />
<br />&gt; violation. </p>
<p>The use of the Pointer is known as a &#8216;weak reference&#8217; and is used to break the circular refcount problem where an outer class holds a reference to an inner class and an inner class holds a reference to the outer class. This then means that neither of the refcounts get to drop to zero thus causing a memory leak. Assigning to a Pointer means that the refcount of the Controller is not incremented from the one that is holding the outer (controller) object; therefore, when that ref falls out of scope it then drops to zero releasing the outer object which, in turn releases the inner object.</p>
<p>Try it <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Joanna</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wango</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-14</link>
		<dc:creator>wango</dc:creator>
		<pubDate>Tue, 19 Oct 2004 08:27:31 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-14</guid>
		<description>Great article! But I think there are some small  problems in it.&lt;br&gt;1 just as Lars Christian Svane said, :)&lt;br&gt;(DigitalClock1 as ISubject).Attach(fClockTimer as IObserver); &lt;br&gt;should be: &lt;br&gt;(fClockTimer as ISubject).Attach(DigitalClock1 as IObserver); &lt;br&gt;2 &lt;br&gt;fController: Pointer;&lt;br&gt;should be:  &lt;br&gt;fController: IInterface;&lt;br&gt;&lt;br&gt;constructor TSubject.Create(const Controller: IInterface);&lt;br&gt;begin&lt;br&gt;  inherited Create;&lt;br&gt;  fController := Pointer(Controller);&lt;br&gt;should be:&lt;br&gt;  fController := Controller;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure TSubject.Notify;&lt;br&gt;var&lt;br&gt;  i: Integer;&lt;br&gt;begin&lt;br&gt;  if fObservers &#60;&#62; nil then&lt;br&gt;    for i := 0 to Pred(fObservers.Count) do&lt;br&gt;      (fObservers[i]. as IObserver).Update(IInterface (fController));&lt;br&gt;should be:&lt;br&gt;      (fObservers[i] as IObserver).Update(fController);&lt;br&gt;end;&lt;br&gt;&lt;br&gt;Why?&lt;br&gt;If fController is defined as a Pointer type, I think it is a pointer type cast and not a interface reference in code &#34;fController := Pointer(Controller)&#34;. you have to add &#34;Controller._AddRef;&#34; to avoid a access violation. &lt;br&gt;</description>
		<content:encoded><![CDATA[<p>Great article! But I think there are some small  problems in it.<br />
<br />1 just as Lars Christian Svane said, <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />(DigitalClock1 as ISubject).Attach(fClockTimer as IObserver);<br />
<br />should be:<br />
<br />(fClockTimer as ISubject).Attach(DigitalClock1 as IObserver);<br />
<br />2<br />
<br />fController: Pointer;<br />
<br />should be:<br />
<br />fController: IInterface;</p>
<p>constructor TSubject.Create(const Controller: IInterface);<br />
<br />begin<br />
<br />  inherited Create;<br />
<br />  fController := Pointer(Controller);<br />
<br />should be:<br />
<br />  fController := Controller;<br />
<br />end;</p>
<p>procedure TSubject.Notify;<br />
<br />var<br />
<br />  i: Integer;<br />
<br />begin<br />
<br />  if fObservers &lt;&gt; nil then<br />
<br />    for i := 0 to Pred(fObservers.Count) do<br />
<br />      (fObservers[i]. as IObserver).Update(IInterface (fController));<br />
<br />should be:<br />
<br />      (fObservers[i] as IObserver).Update(fController);<br />
<br />end;</p>
<p>Why?<br />
<br />If fController is defined as a Pointer type, I think it is a pointer type cast and not a interface reference in code &quot;fController := Pointer(Controller)&quot;. you have to add &quot;Controller._AddRef;&quot; to avoid a access violation.<br />
</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomas</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-11</link>
		<dc:creator>thomas</dc:creator>
		<pubDate>Mon, 13 Sep 2004 17:50:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-11</guid>
		<description>thx 4 ur article, as a php developer i really needed this :o&lt;br&gt;&lt;br&gt;thx again, like 2c more btw ;)</description>
		<content:encoded><![CDATA[<p>thx 4 ur article, as a php developer i really needed this <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
<p>thx again, like 2c more btw <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-24</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 25 Aug 2004 14:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-24</guid>
		<description>Good article!&lt;br&gt;&lt;br&gt;But, look, if you can provide some more sofisticated examples it will be great.&lt;br&gt;Patterns is great stuff, but Delphi itself imply a lot of limitations. Just assume that your Observer must work in threading environment and you will see what i mean.&lt;br&gt;Some stuff in VCL might turn our life in nightmare :-(&lt;br&gt;I know it's not about patterns, but as far as we are talking about Delphi implementation it would be nice to see.</description>
		<content:encoded><![CDATA[<p>Good article!</p>
<p>But, look, if you can provide some more sofisticated examples it will be great.<br />
<br />Patterns is great stuff, but Delphi itself imply a lot of limitations. Just assume that your Observer must work in threading environment and you will see what i mean.<br />
<br />Some stuff in VCL might turn our life in nightmare <img src='http://blogs.teamb.com/joannacarter/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> <br />I know it&#8217;s not about patterns, but as far as we are talking about Delphi implementation it would be nice to see.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars Christian Svane</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-23</link>
		<dc:creator>Lars Christian Svane</dc:creator>
		<pubDate>Sat, 14 Aug 2004 02:14:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-23</guid>
		<description>Sorry to disturb you again. But something I don't understand is happening:&lt;br&gt;&lt;br&gt;I changed the code as in my last comment. Then my test application compiled and run fine - with ONE Digital Clock on the form.&lt;br&gt;&lt;br&gt;Then I added three more. And then I get an access violation when I close the application. With up to three Digital Clocks it works fine. On four - BUM!&lt;br&gt;&lt;br&gt;It happens at a place after the Interfacelist starts to be cleared. After the &#34;finally&#34; in Classes file.&lt;br&gt;&lt;br&gt;Can you explaine this?&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Lars</description>
		<content:encoded><![CDATA[<p>Sorry to disturb you again. But something I don&#8217;t understand is happening:</p>
<p>I changed the code as in my last comment. Then my test application compiled and run fine - with ONE Digital Clock on the form.</p>
<p>Then I added three more. And then I get an access violation when I close the application. With up to three Digital Clocks it works fine. On four - BUM!</p>
<p>It happens at a place after the Interfacelist starts to be cleared. After the &quot;finally&quot; in Classes file.</p>
<p>Can you explaine this?</p>
<p>Regards,<br />
<br />Lars</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars Christian Svane</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-22</link>
		<dc:creator>Lars Christian Svane</dc:creator>
		<pubDate>Sat, 14 Aug 2004 01:55:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-22</guid>
		<description>Great article - even a beginner in OOP and patterns can understand!&lt;br&gt;&lt;br&gt;I have been waiting for your book to learn more about OOP, design patterns and MVP. Don't hesitate to continue your work on this page. I can hardly wait.&lt;br&gt;&lt;br&gt;As far as I can see, there is a small error:&lt;br&gt;&lt;br&gt;(DigitalClock1 as ISubject).Attach(fClockTimer as IObserver);&lt;br&gt;&lt;br&gt;should be:&lt;br&gt;&lt;br&gt;(fClockTimer as ISubject).Attach(DigitalClock1 as IObserver);&lt;br&gt;&lt;br&gt;Your text is correct - but the code seems wrong (compiling gives an error).&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Lars</description>
		<content:encoded><![CDATA[<p>Great article - even a beginner in OOP and patterns can understand!</p>
<p>I have been waiting for your book to learn more about OOP, design patterns and MVP. Don&#8217;t hesitate to continue your work on this page. I can hardly wait.</p>
<p>As far as I can see, there is a small error:</p>
<p>(DigitalClock1 as ISubject).Attach(fClockTimer as IObserver);</p>
<p>should be:</p>
<p>(fClockTimer as ISubject).Attach(DigitalClock1 as IObserver);</p>
<p>Your text is correct - but the code seems wrong (compiling gives an error).</p>
<p>Regards,<br />
<br />Lars</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malte Persike</title>
		<link>http://blogs.teamb.com/joannacarter/2004/06/30/690#comment-3</link>
		<dc:creator>Malte Persike</dc:creator>
		<pubDate>Wed, 14 Jul 2004 04:02:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/joannacarter/2004/06/30/1/#comment-3</guid>
		<description>Great article. Detailing into the alternatives of composition and interfaces gives the reader the ability to choose what suits her/him best.&lt;br&gt;&lt;br&gt;Potential future revisions could take the chance to include the idea of Message parameters to the Notify/Update-methods.</description>
		<content:encoded><![CDATA[<p>Great article. Detailing into the alternatives of composition and interfaces gives the reader the ability to choose what suits her/him best.</p>
<p>Potential future revisions could take the chance to include the idea of Message parameters to the Notify/Update-methods.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
