[rfc] MethodObject or CommandObject pattern and reconfigure.py

Robert Collins robertc at robertcollins.net
Wed Aug 5 01:08:06 BST 2009


On Wed, 2009-08-05 at 09:37 +1000, Martin Pool wrote:
> 2009/8/5 Robert Collins <robert.collins at canonical.com>:
> > On Fri, 2009-07-24 at 15:37 +1000, Martin Pool wrote:
> >>
> >>
> >>  * If the only interface you want to present is "do this action" and
> >> there's no obvious object identity that callers would be interested
> >> in, make it a function not an object.  The function can always become
> >> a factory for objects later, whether or not that's disclosed.
> >
> > Objects often make unit testing easier, even in the case where the
> > client API is going to be very narrow. I think its worth saying that
> > these are factors to consider, but I would hesitate to make them rules.
> 
> That could possibly still be a reason to have the public interface
> just be a function that constructs and uses the object; you could then
> construct the object directly for unit testing.
> 
> "Make it an object because that makes testing easier" as a guideline
> seems barely helpful.  One needs to have some specific need to factor
> it that way, or at least a reasonable suspicion there will be one.

Sure. I'm simply saying its not as cut and dried to me as 'narrow
interface -> use a function'.

-Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090805/c2cafe26/attachment.pgp 


More information about the bazaar mailing list