A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20140315/ffdbae72/attachment.html below:

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Mar 15, 2014 at 2:44 PM, Nikolaus Rath <span dir="ltr"><<a href="mailto:Nikolaus@rath.org" target="_blank">Nikolaus@rath.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> writes:<br>


> This downside of using subclassing as an API should be well known by now<br>
> and widely warned against.<br>
<br>
</div>It wasn't known to me until now. Are these downsides described in some<br>
more detail somewhere?<br>
<br>
So far I have always thought that, as long as I avoid using private<br>
attributes, subclassing was supported like any other use of the API.<br></blockquote></div><br></div><div class="gmail_extra">Googling for things like "containment vs. inheritance" finds a wealth of articles explaining the issues. Apparently even the classic GoF patterns book prefers containment.<br>

<br>The problem with subclassing is that it tends to create tighter coupling between provider and consumer of an API. I believe this is due to the addition of "protected" APIs that are supposedly okay to use for subclasses but not for other users. If you can completely avoid those I suppose you'd be okay, but note that my remark was sparked by a proposal to create just such a protected API (_poller).<br>

<br></div><div class="gmail_extra">Additionally, a subclass and its base class share the same namespace, so a method or attribute defined by a subclass may get in the way of something with the same name added in a new version of the base class.<br>

<br></div><div class="gmail_extra">The main area where I think subclassing is fine is when base class and subclasses are all part of the same package/module, so their evolution is controlled by the same team. I suppose there are also some good uses for abstract base classes that avoid the above issues.<br clear="all">

</div><div class="gmail_extra"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)


</div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4