<?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: Don&#8217;t overuse classes in Python</title>
	<atom:link href="http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/</link>
	<description>Random scribbling about programming, translation, and Japan</description>
	<lastBuildDate>Fri, 03 Feb 2012 09:05:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mounir Errami</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-347</link>
		<dc:creator>Mounir Errami</dc:creator>
		<pubDate>Wed, 15 Oct 2008 17:48:38 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-347</guid>
		<description>I agree with the main point. A lot of coders uses a Java way of coding with Python.
However, in some circumstances, although a class may not be needed, I sometimes decide to use a class whenever one or more variables need be shared by different functions that are related. This avoids the trouble of defining global variables or passing numerous arguments.
Besides, and although I have little to substantiate this claim, I find it easier to work with classes when building event driven (graphic) applications, it helps (at least for me) in respect of the Model-View-Controller. But this is not very related to the original post.</description>
		<content:encoded><![CDATA[<p>I agree with the main point. A lot of coders uses a Java way of coding with Python.<br />
However, in some circumstances, although a class may not be needed, I sometimes decide to use a class whenever one or more variables need be shared by different functions that are related. This avoids the trouble of defining global variables or passing numerous arguments.<br />
Besides, and although I have little to substantiate this claim, I find it easier to work with classes when building event driven (graphic) applications, it helps (at least for me) in respect of the Model-View-Controller. But this is not very related to the original post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ginstrom</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-353</link>
		<dc:creator>Ryan Ginstrom</dc:creator>
		<pubDate>Tue, 07 Oct 2008 08:34:24 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-353</guid>
		<description>@Junius

Thanks for the comment. You make some good points. I especially like the advice about using generators.

Certainly, my code could have been made better, and I&#039;d have written it differently if going about it from scratch. But that wasn&#039;t my point; my point was to argue against overuse of classes. I prefer making a narrow point (don&#039;t overuse classes; do this instead) than a broad one (here&#039;s some bad code; this is better). But that&#039;s probably because I&#039;m a bit simple minded.

I also think exploring code in a script is a fine alternative to the interpreter, especially if you know you want to end up with a module, but you&#039;re just not sure yet what it should do. :) And especially if you&#039;re writing unit tests in tandem.</description>
		<content:encoded><![CDATA[<p>@Junius</p>
<p>Thanks for the comment. You make some good points. I especially like the advice about using generators.</p>
<p>Certainly, my code could have been made better, and I&#8217;d have written it differently if going about it from scratch. But that wasn&#8217;t my point; my point was to argue against overuse of classes. I prefer making a narrow point (don&#8217;t overuse classes; do this instead) than a broad one (here&#8217;s some bad code; this is better). But that&#8217;s probably because I&#8217;m a bit simple minded.</p>
<p>I also think exploring code in a script is a fine alternative to the interpreter, especially if you know you want to end up with a module, but you&#8217;re just not sure yet what it should do. <img src='http://ginstrom.com/scribbles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  And especially if you&#8217;re writing unit tests in tandem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Junius</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-350</link>
		<dc:creator>Junius</dc:creator>
		<pubDate>Tue, 07 Oct 2008 06:59:26 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-350</guid>
		<description>For exploratory programming, you might as well take advantage of the interpreter.

Open your editor, and make like you were going to do everything with module level code, no functions or anything, and paste back and forth with the interpreter to see what you are dealing with.

You should end up with a file full of notes and python snippets that you can arrange it a reasonable structure to get your final code.

But you haven&#039;t been nearly snooty enough. You should have gone all the way and written it using generators.

Generators are a convenient way to avoid deeply nested call graphs like main -&gt; process_files -&gt; process_file -&gt; examine_workbook -&gt; examine_sheet.

Rather, make each function a generator that yields the next stage&#039;s arguments to its caller, and then and link the stages together in main.

For example, in process_file, there&#039;s no need to configure examine_member. Rather, make process_file a generator that yields the file&#039;s members to its caller, and the caller decides what function to use to process them.

This way, all the functions are independent of each other and can be understood and tested in isolation.</description>
		<content:encoded><![CDATA[<p>For exploratory programming, you might as well take advantage of the interpreter.</p>
<p>Open your editor, and make like you were going to do everything with module level code, no functions or anything, and paste back and forth with the interpreter to see what you are dealing with.</p>
<p>You should end up with a file full of notes and python snippets that you can arrange it a reasonable structure to get your final code.</p>
<p>But you haven&#8217;t been nearly snooty enough. You should have gone all the way and written it using generators.</p>
<p>Generators are a convenient way to avoid deeply nested call graphs like main -&gt; process_files -&gt; process_file -&gt; examine_workbook -&gt; examine_sheet.</p>
<p>Rather, make each function a generator that yields the next stage&#8217;s arguments to its caller, and then and link the stages together in main.</p>
<p>For example, in process_file, there&#8217;s no need to configure examine_member. Rather, make process_file a generator that yields the file&#8217;s members to its caller, and the caller decides what function to use to process them.</p>
<p>This way, all the functions are independent of each other and can be understood and tested in isolation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ginstrom</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-348</link>
		<dc:creator>Ryan Ginstrom</dc:creator>
		<pubDate>Tue, 07 Oct 2008 00:16:17 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-348</guid>
		<description>@Russell

You&#039;ve got a point about passing in the &lt;code&gt;examine_member&lt;/code&gt; function as a parameter. I was assuming that being exploratory, the code would be evolving as it developed, so I made this as lightweight as possible. By the time I was ready to put this into a module, that would be one of the first refactorings I made.</description>
		<content:encoded><![CDATA[<p>@Russell</p>
<p>You&#8217;ve got a point about passing in the <code>examine_member</code> function as a parameter. I was assuming that being exploratory, the code would be evolving as it developed, so I made this as lightweight as possible. By the time I was ready to put this into a module, that would be one of the first refactorings I made.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-349</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Mon, 06 Oct 2008 19:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-349</guid>
		<description>Agree on your basic point.  Using a class hierarchy seems  complicated in a goofy way.

BtW, I&#039;d &quot;configure&quot; examine_member by having it be a parameter to process_file rather than being a global variable.  But that&#039;s probably a detail.</description>
		<content:encoded><![CDATA[<p>Agree on your basic point.  Using a class hierarchy seems  complicated in a goofy way.</p>
<p>BtW, I&#8217;d &#8220;configure&#8221; examine_member by having it be a parameter to process_file rather than being a global variable.  But that&#8217;s probably a detail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeroen Ruigrok van der Werven</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-352</link>
		<dc:creator>Jeroen Ruigrok van der Werven</dc:creator>
		<pubDate>Mon, 06 Oct 2008 13:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-352</guid>
		<description>I fully concur. Both classes and functions (methods) have their function. You need to pick the ones as the situation demands. Just using a class for class sakes is silly.</description>
		<content:encoded><![CDATA[<p>I fully concur. Both classes and functions (methods) have their function. You need to pick the ones as the situation demands. Just using a class for class sakes is silly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felix</title>
		<link>http://ginstrom.com/scribbles/2008/10/06/dont-overuse-classes-in-python/comment-page-1/#comment-351</link>
		<dc:creator>felix</dc:creator>
		<pubDate>Mon, 06 Oct 2008 13:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://ginstrom.com/scribbles/?p=386#comment-351</guid>
		<description>my term for this is &quot;object chauvinism&quot;</description>
		<content:encoded><![CDATA[<p>my term for this is &#8220;object chauvinism&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

