On Feb 24, 2011, at 8:28 AM, Markus Roberts wrote: > L -- > >> I thought this design point would be interesting, assuming I can make it >> sufficiently clearly. >> >> I just did a refactor of my Interfaces work - previously, I had a base class >> of Puppet::Interface, and all interfaces were subclasses of that class. >> >> However, once Dan Bode asked for a separation between interfaces that used >> the Indirector and those that didn't, I suddently had the base class, a new >> Puppet::Interface::Indirector class, and then subclasses of each. Then the >> code smell showed up. > > If I'm understanding you correctly, would it be safe to say that the > problem really arose from having interfaces be subclasses of a base > class, rather than instances of it? In other words, if we had > SevenClass as a subclass on Integer (along with OneClass and > NinteenClass, and so on) that would be the same smell, even if we > never inserted anything (say, Cardinal) between them?
Something like that, yes. In this case (and in other cases in Puppet), the class wasn't actually useful, either - you still had to create an instance to do anything of value. > I think the only place this sort of sub-class-singleton pattern is > used with any frequency in the outside world is things like TrueClass > / FalseClass which some in the Smalltalk world (which is where we got > the pattern) have subsequently repudiated. It's very tempting when > the proper is-a items are 1) a small fixed/limited set, 2) share > little or no behavior. Yeah, it's easy to see why you'd do it this way, and it took me a long time to see the error of my ways in doing this with Puppet::Type. I am hoping we can not repeat this in other places. :) BTW this is discussed a bit in Analysis Patterns by Martin Fowler as the operational layer and knowledge layer (where the classes are at the operational layer and the instances are the knowledge layer). -- Humphrey's Law of the Efficacy of Prayer: In a dangerous world there will always be more people around whose prayers for their own safety have been answered than those whose prayers have not. --------------------------------------------------------------------- Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
