On Mon, Nov 26, 2012 at 12:23 PM, Eric Firing <email@example.com> wrote:
On 2012/11/26 7:12 AM, Michael Droettboom wrote:I think we should be rather conservative about this sort of thing.
> The problem is that I don't think we can do this for all artists. Some
> may need to create groupings, or push and pop state even if they are
> "invisible". For instance, this is used in the SVG backend to create
> provide interactivity. I think I'd rather keep this to the contained
> solution in the PR and not try to generalize it beyond that.
> If we did want to generalize, this would only apply to "leaf node"
> artists, and not artists that simply exist to contain other artists --
> and conceivably we could implement that using either a decorator or
> explicit chaining to a base class, but in any event it would have to be
> a manual process to determine which artists this would apply to. We
> could insert a class in the heirarchy of "ConcreteArtist" (or somesuch)
> to handle this.
Sometimes it is better to just explicitly put the two lines in each
method than to come up with machinery to do it for you. Each level of
depth in an inheritance hierarchy or "meta" chain is an additional level
of complexity for someone reading the code. And if someone forgets to
put in those lines, the penalty is typically from small to nil; but if
they are put in automatically by fancy methods, and they are not really
wanted or something else goes wrong, it can make debugging painful.