I was looking at some Seaside code today and noticed that it said
html tableCaption: 'blah'.
Rather than
html table tableCaption: 'blah'
In other words, as far as Seaside was concerned the tableCaption tag was nothing to do with the table tag. This struck me as slightly odd. Somehow I would have expected the 'child' tags of table to be created through messages to the parent table. However, that clearly isn't the case, and now that I have looked more closely at the Seaside tag structure, that seems to be the case for most of the tags.
I am keen to understand what makes good Smalltalk design, so could someone explain why making the tags independent is a better way of doing it?
Thanks Andy
"Andy" == Andy Burnett andy.burnett@knowinnovation.com writes:
Andy> I was looking at some Seaside code today and noticed that it said Andy> html tableCaption: 'blah'.
Andy> Rather than
Andy> html table tableCaption: 'blah'
Andy> I am keen to understand what makes good Smalltalk design, so could someone Andy> explain why making the tags independent is a better way of doing it?
Probably for the same reason that list-element tags live outside lists, and paragraphs live outside headings and body. All tags are essentially flat, except for the oddballs for options and optiongroups, because they really are aspects of the canvas, not of the "parent" tags. A table tag shouldn't know how to render a tablecaption tag. It's the canvas that knows how to render both. Therefore, you have to ask the canvas for a tag brush each time.
Don't confuse composition with locale of knowledge.
Now, you *could* enhance all of the tags to know about all their possible child tags, but that would just make the code unwieldy, I think, since they would end up looking like this:
WATableBrush>>tableCaption ^self canvas tableCaption
WATableBrus>>tableCaption: aRenderable ^self canvas tableCaption: aRenderable
Now there are clearly some shortcuts that already do this, but to require this enmasse doesn't seem to gain much. The "always ask the canvas for a tagbrush" seems like a very workable rule.
beginners@lists.squeakfoundation.org