Bo, in response to my last post, had a few interesting things to say:
I've never met any piece of 'content' in the real world that could render itself as HTML. This doesn't even make sense for the majority of content (images, sounds). I can't think of a single reason why a 'Content' object would have a 'asHTML' object. Such a conversion method should certainly depend only on the public state of the object and not any of its private state or capabilities. I find the entire idea of a 'Content' class pretty strange. What methods does it have? getId() and getTitle()? Since these aren't behavioral methods at all, at best you should only have a Content interface.
Please, gentle readers of this weblog. Offer me the simple courtesy of assuming I am not completely stupid. If you don't feel able to offer me this courtesy, then why are you wasting your time reading the feeble scratchings of an idiot?
I don't feel it should be necessary for me to have to explain in excruciating detail that in the context I was writing, there are perfectly good reasons for having a Content object, and perfectly good reasons for it to behave the way it does, and even perfectly good reasons that any translation to a format other than HTML must actually be done via HTML.
The task of 'Given a Content object find me a Renderer object that can render it' depends on a million different things--are we operating in headless mode, what medium are we rendering to, what format are we rendering to, are we rendering to a remote or local client, what level of detail are we rendering, etc etc.
Would it come as a shock to discover that not one -- not a single one of these "million different things" applies to the case I was describing? Would it come as more of a shock to discover that if any of them did, I might in fact have mentioned them?
If I were in an uncharitable mood, I might suggest that this is a perfect example of why so many otherwise intelligent people write baroque, unuseable code: the feeling that you have to cater for a million possible conditions that in actuality will never happen, just so you can say your code is architecturally pure.
However, when I was studying Philosophy, I was introduced to the Principle of Charity:
If a participant's argument is reformulated by an opponent, it should be expressed in the strongest possible version that is consistent with the original intention of the arguer. If there is any question about that intention or about implicit parts of the argument, the arguer should be given the benefit of any doubt in the reformulation.
Simply put, there's no point going into a discussion unless you assume that the person you are disagreeing with has a clue. If you don't debate the strongest possible form of your opponent's position, all that's going to happen is that it will be reformulated the next day, invalidating any objections you based on those uncharitable assumptions, and wasting both your and their time.