[FRPythoneers] Class factory

Rob Riggs rob at pangalactic.org
Thu Mar 28 16:04:43 MST 2002

Matt Gushee wrote:

>On Thu, Mar 28, 2002 at 11:21:25AM -0700, Evelyn Mitchell wrote:
>>A Factory pattern describes a way of creating new objects.
>The Python DB API also uses the Factory pattern, I think, though I
>haven't studied the code in depth.

It does indeed. A database connection object can create numerous cursor 
objects using the cursor factory method.

Matt's implementation abstraction example is a great use of factory 
methods.  Access to emote objects is another. In the case of the 
database, the cursor is a remote object (or rather a proxy to a remote 
object) on the database server. It's also common to use object factories 
when creating distributed applications with CORBA for instance. 
(Actually, it's quite common in all component programming.) The reason 
is that one can't just instantiate a remote object without the help of 
another remote object.

myObj = ObjectClass() just doesn't work when dealing with remote 
objects. But myObj = remoteServant.createObjectClass() will work. That's 
because you need a reference to a remote process space in which to 
create the remote object.


More information about the FRPythoneers mailing list