[MERGE] Patience diff

Martin Pool mbp at canonical.com
Sat May 27 11:25:16 BST 2006

On 25 May 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> > Point for discussion: when we have a name that's used as a callable
> > factory, how should it be named?  One way is to name it like a class, as
> > you have here, which makes it clear that you're meant to treat it like a
> > constructor.   On the other hand it may be a bit surprising that it
> > doesn't generate instances of SequenceMatcher.  It might be better to
> > call it, say, sequencematcher_class, or sequencematcher_factory.  (This
> > is a bit theoretical; don't let it block your merge but I wondered what
> > people thought.)
> > 
> Well, technically SequenceMatcher is still a class. It just happens to
> generate children of the real SequenceMatcher.
> I primarily did this, because I didn't want to change it everywhere else
> within the code. merge3 isn't really my territory.

Fair enough, it makes sense in this context.

> If we have a real factory, I probably prefer 'foo_factory', if we have a
> member which expects to be a class, I prefer 'foo_class'. So something like:
> class Diff(object):
> 	sequence_matcher_class = SequenceMatcher
> 	def __init__(self):
> 		self.sm = Diff.sequence_matcher_class()
> Which lets you set the default class to be used.

That looks reasonable to me - though it also does touch on the slightly
odd prototype-like nature of Python class variables, but I won't get
into that kettle of fish now.


More information about the bazaar mailing list