From: Catalin Marinas Date: Fri, 06 Jun 2008 08:44:37 GMT Subject: Re: [StGIT PATCH 3/5] Create a git.Branch class as ancestor of stack.Stack Message-ID: In-Reply-To: <20080605130415.GB28995@diana.vm.bytemark.co.uk> 2008/6/5 Karl Hasselström : > On 2008-06-05 13:03:55 +0100, Catalin Marinas wrote: >> 2008/6/5 Karl Hasselström : >> The same goes for the "create" function, the repository shouldn't >> need to know the directory or files structure that a Stack or Branch >> are using. I think we get a clearer separation this way. > > Yes, you're right. Knowledge of internals belong in the class itself. > > We'll have to be watchful against attempts to create objects other > than via the officially designated factories, though. Python doesn't > really have any mechanisms that help us here. Doesn't need to be enforced. The Stack and Branch objects can be initialised by themselves provided that the repository is passed as argument at construction. The factory is more for convenience, passing the repository to the newly created object. If you really want enforcing this, it can probably be done by hacking __new__ and __init__. -- Catalin