[ZODB-Dev] SecureServerStorage and SecureClientStorage

Guido van Rossum guido@python.org
Sat, 05 Oct 2002 03:55:01 -0400


> > Hm, maybe we should adopt as general principle that whenever a class
> > instantiates another class (and we think it might be useful to
> > subclass that class to provide additional functionality), it doesn't
> > use that other class directly, but uses a reference to that class
> > stored on the current class.
> 
> Over the last few months I have been refactoring one of our internal
> projects that used to use this idiom. One problem is that you often
> have to create more derived classes than you might think is
> necessary; the purpose of the extra classes is solely to change the
> type of the classes it creates.

That's true.  Does this mean you no longer like this idiom?  Do you
have an alternative?  Passing all the classes (better: factories) in
to the constructor isn't a great solution either, although perhaps
with keyword arguments this can be made relatively painless.  But this
depends on how many classes you want to replace, and whether those
classes are conveniently available at the abstraction level where the
constructor is called.

--Guido van Rossum (home page: http://www.python.org/~guido/)