<?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: Class member access control: enforcement vs. convention</title>
	<atom:link href="http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention</link>
	<description>by Gustavo Niemeyer</description>
	<lastBuildDate>Wed, 10 Mar 2010 15:15:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: holger krekel</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-69024</link>
		<dc:creator>holger krekel</dc:creator>
		<pubDate>Tue, 25 Aug 2009 07:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-69024</guid>
		<description>Just this morning i thought of &quot;how can i keep these methods private&quot; ... and realized i just apply this pattern: 

class MyClass:
   def mymethod(self, ...):
       some_func_defined_in_module(self, ...) 

and to someone having only an instance he has no easy way to call that function which has the same abilities as a method defined in the class body, of course.  To access that function one from the caller side one needs to perform an import of the module and fish the function. This is probably something that you don&#039;t consider sufficient. But still wanted to mention it - for my purposes it works well because there really is no convenient way to import the module, in fact :)</description>
		<content:encoded><![CDATA[<p>Just this morning i thought of &#8220;how can i keep these methods private&#8221; &#8230; and realized i just apply this pattern: </p>
<p>class MyClass:<br />
   def mymethod(self, &#8230;):<br />
       some_func_defined_in_module(self, &#8230;) </p>
<p>and to someone having only an instance he has no easy way to call that function which has the same abilities as a method defined in the class body, of course.  To access that function one from the caller side one needs to perform an import of the module and fish the function. This is probably something that you don&#8217;t consider sufficient. But still wanted to mention it &#8211; for my purposes it works well because there really is no convenient way to import the module, in fact <img src='http://blog.labix.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo Niemeyer</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65679</link>
		<dc:creator>Gustavo Niemeyer</dc:creator>
		<pubDate>Thu, 21 May 2009 11:23:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65679</guid>
		<description>&lt;blockquote&gt;So let’s presume we have a private keyword and i would not be able to get at the attribute i want. I’d file an issue with the developer (if i find out how) and then what?&lt;/blockquote&gt;

As I said earlier, if the public API of the library does not satisfy you, either copy the library and adapt to your needs, or work with the maintainer to improve it as wanted.  In both cases, both the maintainer of the library and your users will be happier, since your software won&#039;t break when the next stable version of the library comes out.

&lt;blockquote&gt;I need to get my job done and being confronted with private/public distinctions doesn’t make my job easier.&lt;/blockquote&gt;

I never said it would make &lt;i&gt;that&lt;/i&gt; job easier.  In fact, I&#039;ve explicitly stated that the problem is exactly that the &quot;job&quot; of accessing private attributes is &lt;i&gt;too easy&lt;/i&gt; right now.  What I suggest in this post is that stricter member access control makes the job easier when you have to maintain nicely working software for thousands/millions of users and hundreds/thousands of developers in an evolving environment.</description>
		<content:encoded><![CDATA[<blockquote><p>So let’s presume we have a private keyword and i would not be able to get at the attribute i want. I’d file an issue with the developer (if i find out how) and then what?</p></blockquote>
<p>As I said earlier, if the public API of the library does not satisfy you, either copy the library and adapt to your needs, or work with the maintainer to improve it as wanted.  In both cases, both the maintainer of the library and your users will be happier, since your software won&#8217;t break when the next stable version of the library comes out.</p>
<blockquote><p>I need to get my job done and being confronted with private/public distinctions doesn’t make my job easier.</p></blockquote>
<p>I never said it would make <i>that</i> job easier.  In fact, I&#8217;ve explicitly stated that the problem is exactly that the &#8220;job&#8221; of accessing private attributes is <i>too easy</i> right now.  What I suggest in this post is that stricter member access control makes the job easier when you have to maintain nicely working software for thousands/millions of users and hundreds/thousands of developers in an evolving environment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: holger krekel</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65676</link>
		<dc:creator>holger krekel</dc:creator>
		<pubDate>Thu, 21 May 2009 09:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65676</guid>
		<description>Hey Gustavo,

you wrote in your original post: 

    &quot;It’s way easier to simply read the code and get to the
    private guts of a library than to try to get agreement
    over the right way to do something, or sending a patch 
    with a suggested change which was carefully architected.&quot;

This is a valid observation and there is what i&#039;d call &quot;cost of communication&quot; here. It can be high even in controlled team environments even, but often is very high between very loosely or not-at-all coupled developers.  And we all know, developers are lazy.

You say in your comment: 

&quot;Having tons of software in the wild which use the private API vs. having tons of software in the wild which use the private API and two more lines of comment doesn’t really change the picture presented in the post and detailed in the comments above.&quot;. 

So let&#039;s presume we have a private keyword and i would not be able to get at the attribute i want.  I&#039;d file an issue with the developer (if i find out how) and then what?  Would he be more likely to fix the issue because there is a &quot;private&quot; keyword?  Would he rush to remove my blocking issue?  Here is what i think is likely: while waiting i&#039;d hack around in *even weirder ways* to get at what i need, maybe duplicating code, copy-pasting his class or whatever. I need to get my job done and being confronted with private/public distinctions doesn&#039;t make my job easier. 

Concluding, I see more value in easing code-centered communication between developers then shifting Python programming paradigms to use private/protected methods. 

cheers, 
holger (wonders how formatting works on the blog here)</description>
		<content:encoded><![CDATA[<p>Hey Gustavo,</p>
<p>you wrote in your original post: </p>
<p>    &#8220;It’s way easier to simply read the code and get to the<br />
    private guts of a library than to try to get agreement<br />
    over the right way to do something, or sending a patch<br />
    with a suggested change which was carefully architected.&#8221;</p>
<p>This is a valid observation and there is what i&#8217;d call &#8220;cost of communication&#8221; here. It can be high even in controlled team environments even, but often is very high between very loosely or not-at-all coupled developers.  And we all know, developers are lazy.</p>
<p>You say in your comment: </p>
<p>&#8220;Having tons of software in the wild which use the private API vs. having tons of software in the wild which use the private API and two more lines of comment doesn’t really change the picture presented in the post and detailed in the comments above.&#8221;. </p>
<p>So let&#8217;s presume we have a private keyword and i would not be able to get at the attribute i want.  I&#8217;d file an issue with the developer (if i find out how) and then what?  Would he be more likely to fix the issue because there is a &#8220;private&#8221; keyword?  Would he rush to remove my blocking issue?  Here is what i think is likely: while waiting i&#8217;d hack around in *even weirder ways* to get at what i need, maybe duplicating code, copy-pasting his class or whatever. I need to get my job done and being confronted with private/public distinctions doesn&#8217;t make my job easier. </p>
<p>Concluding, I see more value in easing code-centered communication between developers then shifting Python programming paradigms to use private/protected methods. </p>
<p>cheers,<br />
holger (wonders how formatting works on the blog here)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo Niemeyer</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65659</link>
		<dc:creator>Gustavo Niemeyer</dc:creator>
		<pubDate>Wed, 20 May 2009 22:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65659</guid>
		<description>Hey Holger,

&lt;blockquote&gt;Rather would like to see better tools for communicating around code, see http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/ for some more discussion on this.&lt;/blockquote&gt;

The problem isn&#039;t means of communication.  There are plenty of ways people can already communicate with maintainers.  We&#039;re talking about mass behavior here, not coding under a controlled team environment. If people quite frequently do not respect the private member convention, adding an entirely new convention on top of it which goes beyond any kind of known coding practices and expecting people to follow it in the large would be futile.

Also, even if we assume that we&#039;d be able to cause such a major shift in behavior across the board, sending a couple of lines from a comment to the code maintainer doesn&#039;t fix the issue &lt;i&gt;by itself&lt;/i&gt;.  Having tons of software in the wild which use the private API vs. having tons of software in the wild which use the private API and two more lines of comment doesn&#039;t really change the picture presented in the post and detailed in the comments above.</description>
		<content:encoded><![CDATA[<p>Hey Holger,</p>
<blockquote><p>Rather would like to see better tools for communicating around code, see <a href="http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/" rel="nofollow">http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/</a> for some more discussion on this.</p></blockquote>
<p>The problem isn&#8217;t means of communication.  There are plenty of ways people can already communicate with maintainers.  We&#8217;re talking about mass behavior here, not coding under a controlled team environment. If people quite frequently do not respect the private member convention, adding an entirely new convention on top of it which goes beyond any kind of known coding practices and expecting people to follow it in the large would be futile.</p>
<p>Also, even if we assume that we&#8217;d be able to cause such a major shift in behavior across the board, sending a couple of lines from a comment to the code maintainer doesn&#8217;t fix the issue <i>by itself</i>.  Having tons of software in the wild which use the private API vs. having tons of software in the wild which use the private API and two more lines of comment doesn&#8217;t really change the picture presented in the post and detailed in the comments above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: holger krekel</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65547</link>
		<dc:creator>holger krekel</dc:creator>
		<pubDate>Mon, 18 May 2009 11:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65547</guid>
		<description>Hey Gustavo, i think your observations are clear but i disagree on the conclusion of introducing protected syntax.  Rather would like to see better tools for communicating around code, see http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/ for some more discussion on this. cheers, holger</description>
		<content:encoded><![CDATA[<p>Hey Gustavo, i think your observations are clear but i disagree on the conclusion of introducing protected syntax.  Rather would like to see better tools for communicating around code, see <a href="http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/" rel="nofollow">http://tetamap.wordpress.com/2009/05/18/code-centered-issue-tracking/</a> for some more discussion on this. cheers, holger</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo Niemeyer</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65509</link>
		<dc:creator>Gustavo Niemeyer</dc:creator>
		<pubDate>Sun, 17 May 2009 15:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65509</guid>
		<description>Hey Elvis,

&lt;blockquote&gt;I prefer not to have private/protected members and methods in Python, because those things assume that libraries are perfect and library users are jerks that like to kludge.&lt;/blockquote&gt;

Quite simply and without trying to judge people&#039;s personal characteristics, access control assumes that there&#039;s value in being able to separate the public interface from the implementation.  It&#039;s a contract between the library maintainer and users of the library.  In open source, you can very easily break these kinds of contracts by forking the library and doing whatever you please with it.  As I mentioned in the post, this will provide you with what you want, and will reduce problems for the real maintainer since &lt;i&gt;you&lt;/i&gt; are the maintainer of the fork.

&lt;blockquote&gt;The opposite is often the true in practice; libraries are buggy and
library users like me have been forced to patch them to meet deadlines and
deliverables. (And don&#039; tell me that &quot;you should report the bug, fix the
library and/or wait for next version&quot; thing.)

Not having protected/private members in Python is one problem less when you need to handle buggy libraries. If such things are added to Python, libraries will still be buggy and still will have to be patched in user code -- it will just be more complicated to do, like C++.&lt;/blockquote&gt;

You&#039;re helping to prove my point.  Convention doesn&#039;t work because there&#039;s a ton of people like you out there, which hop over it for pretty much anything, and feel that interacting with the maintainer is too much work.

The fact that you should report the bug, fix the library and/or wait for the next version is certainly a fantastic advice for someone that plans to work nicely in an open source environment, but being a good player or not is really up to you.

The fact that you&#039;re spreading software which depends on private APIs of libraries in the wild is not &lt;i&gt;just&lt;/i&gt; your problem, though, as I tried to explain in the post.

Just for a moment, put yourself into the position of a maintainer which has to maintain a library for tens of thousands of users.  If everyone jumps over what is described as the public interface of the library, suddenly the maintainer of the library can&#039;t offer any kind of stability guarantee anymore to users of software which depend on such a library.  As a follow up consequence, distributors that bundle the library and dependent software (e.g. Linux distributions) will have trouble to assert that upgrades which feel safe to the maintainer are not actually breaking dependent software (security upgrades be damd).  Of course, the fact that a lot of software has poor or no test coverage at all, and that Python is a dynamically typed language, only helps to make matters worse in this scenario.</description>
		<content:encoded><![CDATA[<p>Hey Elvis,</p>
<blockquote><p>I prefer not to have private/protected members and methods in Python, because those things assume that libraries are perfect and library users are jerks that like to kludge.</p></blockquote>
<p>Quite simply and without trying to judge people&#8217;s personal characteristics, access control assumes that there&#8217;s value in being able to separate the public interface from the implementation.  It&#8217;s a contract between the library maintainer and users of the library.  In open source, you can very easily break these kinds of contracts by forking the library and doing whatever you please with it.  As I mentioned in the post, this will provide you with what you want, and will reduce problems for the real maintainer since <i>you</i> are the maintainer of the fork.</p>
<blockquote><p>The opposite is often the true in practice; libraries are buggy and<br />
library users like me have been forced to patch them to meet deadlines and<br />
deliverables. (And don&#8217; tell me that &#8220;you should report the bug, fix the<br />
library and/or wait for next version&#8221; thing.)</p>
<p>Not having protected/private members in Python is one problem less when you need to handle buggy libraries. If such things are added to Python, libraries will still be buggy and still will have to be patched in user code &#8212; it will just be more complicated to do, like C++.</p></blockquote>
<p>You&#8217;re helping to prove my point.  Convention doesn&#8217;t work because there&#8217;s a ton of people like you out there, which hop over it for pretty much anything, and feel that interacting with the maintainer is too much work.</p>
<p>The fact that you should report the bug, fix the library and/or wait for the next version is certainly a fantastic advice for someone that plans to work nicely in an open source environment, but being a good player or not is really up to you.</p>
<p>The fact that you&#8217;re spreading software which depends on private APIs of libraries in the wild is not <i>just</i> your problem, though, as I tried to explain in the post.</p>
<p>Just for a moment, put yourself into the position of a maintainer which has to maintain a library for tens of thousands of users.  If everyone jumps over what is described as the public interface of the library, suddenly the maintainer of the library can&#8217;t offer any kind of stability guarantee anymore to users of software which depend on such a library.  As a follow up consequence, distributors that bundle the library and dependent software (e.g. Linux distributions) will have trouble to assert that upgrades which feel safe to the maintainer are not actually breaking dependent software (security upgrades be damd).  Of course, the fact that a lot of software has poor or no test coverage at all, and that Python is a dynamically typed language, only helps to make matters worse in this scenario.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elvis Pfutzenreuter</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65479</link>
		<dc:creator>Elvis Pfutzenreuter</dc:creator>
		<pubDate>Sun, 17 May 2009 03:04:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65479</guid>
		<description>I prefer not to have private/protected members and methods in Python, because those things assume that libraries are perfect and library users are jerks that like to kludge.

The opposite is often the true in practice; libraries are buggy and library users like me have been forced to patch them to meet deadlines and deliverables. (And don&#039; tell me that &quot;you should report the bug, fix the library and/or wait for next version&quot; thing.)

Not having protected/private members in Python is one problem less when you need to handle buggy libraries. If such things are added to Python, libraries will still be buggy and still will have to be patched in user code -- it will just be more complicated to do, like C++.</description>
		<content:encoded><![CDATA[<p>I prefer not to have private/protected members and methods in Python, because those things assume that libraries are perfect and library users are jerks that like to kludge.</p>
<p>The opposite is often the true in practice; libraries are buggy and library users like me have been forced to patch them to meet deadlines and deliverables. (And don&#8217; tell me that &#8220;you should report the bug, fix the library and/or wait for next version&#8221; thing.)</p>
<p>Not having protected/private members in Python is one problem less when you need to handle buggy libraries. If such things are added to Python, libraries will still be buggy and still will have to be patched in user code &#8212; it will just be more complicated to do, like C++.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo Niemeyer</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65438</link>
		<dc:creator>Gustavo Niemeyer</dc:creator>
		<pubDate>Sat, 16 May 2009 13:14:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65438</guid>
		<description>&lt;blockquote&gt;I wonder when the rule is important enough to change the people though. For instance of you development process is oriented to TDD and people don’t write the tests or do the job poorly will you change them then ?&lt;/blockquote&gt;

Tim, that&#039;s an interesting question.  I&#039;ve posted a new entry to better explain what I meant, and used your questioning as an example.

&lt;blockquote&gt;It’s possible in python to enforce the rule via an external tool (like pylint) that you can launch on you code in you quality assurance checks.&lt;/blockquote&gt;

Guillaume, I totally agree with your point.  Note, though, that this case falls into what I describe in the post: &lt;i&gt;This methodology may work quite well in situations where the code scope is within a very controlled environment, with one or more teams which follow strictly a single development guideline, and have the power to refactor the affected code base somewhat easily when the original decisions are too limiting.&lt;/i&gt;

Your English is pretty good, by the way.</description>
		<content:encoded><![CDATA[<blockquote><p>I wonder when the rule is important enough to change the people though. For instance of you development process is oriented to TDD and people don’t write the tests or do the job poorly will you change them then ?</p></blockquote>
<p>Tim, that&#8217;s an interesting question.  I&#8217;ve posted a new entry to better explain what I meant, and used your questioning as an example.</p>
<blockquote><p>It’s possible in python to enforce the rule via an external tool (like pylint) that you can launch on you code in you quality assurance checks.</p></blockquote>
<p>Guillaume, I totally agree with your point.  Note, though, that this case falls into what I describe in the post: <i>This methodology may work quite well in situations where the code scope is within a very controlled environment, with one or more teams which follow strictly a single development guideline, and have the power to refactor the affected code base somewhat easily when the original decisions are too limiting.</i></p>
<p>Your English is pretty good, by the way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Hoffman</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65408</link>
		<dc:creator>Tim Hoffman</dc:creator>
		<pubDate>Sat, 16 May 2009 00:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65408</guid>
		<description>Hi Gustavo

You said that  &quot;I’m also a believer that when the rules don’t work for people, the rules should be changed, not the people.&quot;

I wonder when the rule is important enough to change the people though. For instance of you development process is oriented to TDD and people don&#039;t write the tests or do the job poorly will you change them then ?

Rgds

Tim</description>
		<content:encoded><![CDATA[<p>Hi Gustavo</p>
<p>You said that  &#8220;I’m also a believer that when the rules don’t work for people, the rules should be changed, not the people.&#8221;</p>
<p>I wonder when the rule is important enough to change the people though. For instance of you development process is oriented to TDD and people don&#8217;t write the tests or do the job poorly will you change them then ?</p>
<p>Rgds</p>
<p>Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gustavo Niemeyer</title>
		<link>http://blog.labix.org/2009/05/15/class-member-access-control-enforcement-vs-convention/comment-page-1#comment-65399</link>
		<dc:creator>Gustavo Niemeyer</dc:creator>
		<pubDate>Fri, 15 May 2009 21:16:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.labix.org/?p=99#comment-65399</guid>
		<description>Wyatt,

Yes, in general it is allowed to improve a programming language over time. :-)  This argument makes even less sense if we take into consideration how much Python 3 changed in the name of improving things up.</description>
		<content:encoded><![CDATA[<p>Wyatt,</p>
<p>Yes, in general it is allowed to improve a programming language over time. <img src='http://blog.labix.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   This argument makes even less sense if we take into consideration how much Python 3 changed in the name of improving things up.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
