object.enable() anti-pattern

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed May 8 23:12:09 EDT 2013


On Wed, 08 May 2013 14:27:53 +0000, Duncan Booth wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> 
>> I'm looking for some help in finding a term, it's not Python-specific
>> but does apply to some Python code.
>> 
>> This is an anti-pattern to avoid. The idea is that creating a resource
>> ought to be the same as "turning it on", or enabling it, or similar
> 
> I've come across this under the name 'two-phase construction', but as a
> desirable(!?) pattern rathern than as an anti-pattern.
> 
> In particular Symbian used it throughout as originally their C++
> implementation didn't support exceptions. Instead they had a separate
> cleanup stack and objects that require cleanup were pushed onto that
> stack after being fully constructed but before calling the
> initialisation that required cleanup. See
> http://www.developer.nokia.com/Community/Wiki/Two-phase_construction



Thanks for the link. It's obviously not the blog post I was looking for, 
but it is interesting.



-- 
Steven



More information about the Python-list mailing list