<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Understanding Object Cleanup</title>
	<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Mon, 23 Nov 2009 00:43:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Kieran Parsons</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-30496</link>
		<dc:creator>Kieran Parsons</dc:creator>
		<pubDate>Thu, 30 Jul 2009 12:17:31 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-30496</guid>
		<description>The very helpful Mathworks technical support team were able to help me out with #6. Their solution is posted at http://www.mathworks.com/support/solutions/en/data/1-ABQ59D/index.html if anyone is interested. An interesting use of strings in callbacks instead of anonymous functions.</description>
		<content:encoded><![CDATA[<p>The very helpful Mathworks technical support team were able to help me out with #6. Their solution is posted at <a href="http://www.mathworks.com/support/solutions/en/data/1-ABQ59D/index.html" rel="nofollow">http://www.mathworks.com/support/solutions/en/data/1-ABQ59D/index.html</a> if anyone is interested. An interesting use of strings in callbacks instead of anonymous functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kieran Parsons</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-30475</link>
		<dc:creator>Kieran Parsons</dc:creator>
		<pubDate>Fri, 17 Jul 2009 18:10:57 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-30475</guid>
		<description>I am trying to clean up a singleton GUI object (using a persistent variable as suggested in 2 and http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_oop/bru6n2g.html.) 

When the object is created I create a GUI figure window, and I want them to always exist as a pair. I have added a 'CloseRequestFcn' callback that closes the figure and deletes the object if a user hits the close button. This works fine. However, I cannot figure out how to get the GUI figure to close if I clear the singleton object. I tried overloading the 'delete' method(which normally works) but in the case of the clearing of a persistent object it seems that the 'delete' method is not called.

Any ideas?

Thanks,
Kieran</description>
		<content:encoded><![CDATA[<p>I am trying to clean up a singleton GUI object (using a persistent variable as suggested in 2 and <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_oop/bru6n2g.html." rel="nofollow">http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_oop/bru6n2g.html.</a>) </p>
<p>When the object is created I create a GUI figure window, and I want them to always exist as a pair. I have added a &#8216;CloseRequestFcn&#8217; callback that closes the figure and deletes the object if a user hits the close button. This works fine. However, I cannot figure out how to get the GUI figure to close if I clear the singleton object. I tried overloading the &#8216;delete&#8217; method(which normally works) but in the case of the clearing of a persistent object it seems that the &#8216;delete&#8217; method is not called.</p>
<p>Any ideas?</p>
<p>Thanks,<br />
Kieran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StephenLL</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29635</link>
		<dc:creator>StephenLL</dc:creator>
		<pubDate>Wed, 30 Jul 2008 19:32:32 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29635</guid>
		<description>Nick, Loren, Gautam:

Thank you for replying and your ideas.  I have a lot to learn and experiment with now.

I don't plan to make wide spread use of this technique for the obvious pitfalls like hidden dependence, but there is some functionality well served by it.

Thanks again.

Stephen</description>
		<content:encoded><![CDATA[<p>Nick, Loren, Gautam:</p>
<p>Thank you for replying and your ideas.  I have a lot to learn and experiment with now.</p>
<p>I don&#8217;t plan to make wide spread use of this technique for the obvious pitfalls like hidden dependence, but there is some functionality well served by it.</p>
<p>Thanks again.</p>
<p>Stephen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gautam Vallabha</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29633</link>
		<dc:creator>Gautam Vallabha</dc:creator>
		<pubDate>Wed, 30 Jul 2008 16:41:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29633</guid>
		<description>Another example of user-managed objects are graphics objects (FIGURE, AXES, PATCH, LINE, etc.). Nick's guidelines work for these as well:
1) There is a DELETE function for the graphics objects
2) There is a FINDALL function that can be used to catch all the HG objects, including those with visibility set to 'off'.


With regard to Stephen's question: one guideline for building user-managed objects is to allow the user to assign a unique name to the object. This makes it easy to find them later. For example:

-----------
timer('period',0.25, 'name', 'myTimer');

% much later ... in some other function
h = timerfind('name', 'myTimer');
stop(h);
delete(h);
-----------

This strategy works with pretty much all user-managed objects in MATLAB.</description>
		<content:encoded><![CDATA[<p>Another example of user-managed objects are graphics objects (FIGURE, AXES, PATCH, LINE, etc.). Nick&#8217;s guidelines work for these as well:<br />
1) There is a DELETE function for the graphics objects<br />
2) There is a FINDALL function that can be used to catch all the HG objects, including those with visibility set to &#8216;off&#8217;.</p>
<p>With regard to Stephen&#8217;s question: one guideline for building user-managed objects is to allow the user to assign a unique name to the object. This makes it easy to find them later. For example:</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
timer(&#8217;period&#8217;,0.25, &#8216;name&#8217;, &#8216;myTimer&#8217;);</p>
<p>% much later &#8230; in some other function<br />
h = timerfind(&#8217;name&#8217;, &#8216;myTimer&#8217;);<br />
stop(h);<br />
delete(h);<br />
&#8212;&#8212;&#8212;&#8211;</p>
<p>This strategy works with pretty much all user-managed objects in MATLAB.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29631</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 29 Jul 2008 17:27:03 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29631</guid>
		<description>Stephen-

If you do use persistent variables, you have to be careful about how multiple instances of the class work.  Today you have 2 more choices that don't limit you to a singleton pattern, nested functions or the object system introduced in R2008a.  There will be a blog on the latter coming soon.  In the meantime, check out the documentation on the class system.  

--Loren</description>
		<content:encoded><![CDATA[<p>Stephen-</p>
<p>If you do use persistent variables, you have to be careful about how multiple instances of the class work.  Today you have 2 more choices that don&#8217;t limit you to a singleton pattern, nested functions or the object system introduced in R2008a.  There will be a blog on the latter coming soon.  In the meantime, check out the documentation on the class system.  </p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Haddad</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29630</link>
		<dc:creator>Nick Haddad</dc:creator>
		<pubDate>Tue, 29 Jul 2008 17:18:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29630</guid>
		<description>There aren't any guidelines per say, but persistent variables would be a great way of keeping some data around if one of your object's variables goes out of scope.  

You could also create a MATLAB class that implements the Singleton design pattern using static methods and a persistent variable.  This would give you a nice interface to some data that stays around in memory, but doesn't require an object variable at all.

For more info on singleton see Wikipedia:
http://en.wikipedia.org/wiki/Singleton_pattern</description>
		<content:encoded><![CDATA[<p>There aren&#8217;t any guidelines per say, but persistent variables would be a great way of keeping some data around if one of your object&#8217;s variables goes out of scope.  </p>
<p>You could also create a MATLAB class that implements the Singleton design pattern using static methods and a persistent variable.  This would give you a nice interface to some data that stays around in memory, but doesn&#8217;t require an object variable at all.</p>
<p>For more info on singleton see Wikipedia:<br />
<a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">http://en.wikipedia.org/wiki/Singleton_pattern</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StephenLL</title>
		<link>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29628</link>
		<dc:creator>StephenLL</dc:creator>
		<pubDate>Tue, 29 Jul 2008 14:01:11 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/07/29/understanding-object-cleanup/#comment-29628</guid>
		<description>Great article.

Is there any documentation or guidelines for building "User-Managed Objects"?

The only way I can think of building a function like this is using persistent variables.

Other then GUIs, I can see other situations where these will be convenient such as utilities. a logging utility comes to mind, also an enumerator class.

Thanks again.
Stephen</description>
		<content:encoded><![CDATA[<p>Great article.</p>
<p>Is there any documentation or guidelines for building &#8220;User-Managed Objects&#8221;?</p>
<p>The only way I can think of building a function like this is using persistent variables.</p>
<p>Other then GUIs, I can see other situations where these will be convenient such as utilities. a logging utility comes to mind, also an enumerator class.</p>
<p>Thanks again.<br />
Stephen</p>
]]></content:encoded>
	</item>
</channel>
</rss>
