Re: Re: [Anygui-checkins] CVS: /anygui TODO.txt,1.57,1.58

Alex Martelli <[email protected]> Mon, 4 Nov 2002 00:40:49 +0200
Newsgroups gmane.comp.python.anygui.devel
Organization None in Sight
Message-ID <[email protected]>
On Sunday 03 November 2002 11:33 pm, Greg Ewing wrote:
> Alex Martelli <[email protected]>:
> > If the Application class has methods that the user may
> > want to override, and which need to be called back from .run or
> > the like (but I can't think of any right now), then a bit of care is
> > needed to make sure the right subclass of Application is used
>
> I think that trying to make this work magically somehow
> would be too confusing. If Application is a class, then
> the programmer is entitled to expect that Application()
> will return an instance of that class, and not an
> instance of some other class that was created previously.

If MyApp subclasses Application, then any instance of MyApp IS an instance 
of Application (check with isinstance if you don't believe me...:-).

Therefore, the invariant you mention, i.e.:

    assert isinstance(Application(), Application)

DOES hold -- even if Application() always returns the same instance
(or, as is the case for Borg, if all instances share state even though
they may have different id's), and even if that instance belongs to
any subclass of Application.

However, as I mentioned, Borg (or SIngleton) DOES need to be used
with care (specifically, well documented) if subclassing and appropriate
callbacks (Template Method design-pattern) are necessary.  I'm not
sure they're necessary here (still can't think of any use case).


Alex


-------------------------------------------------------
This SF.net email is sponsored by: ApacheCon, November 18-21 in
Las Vegas (supported by COMDEX), the only Apache event to be
fully supported by the ASF. http://www.apachecon.com