[Newbies] Why do Seaside's table tags e.g. td etc.,
live 'outside' of table?
Randal L. Schwartz
merlyn at stonehenge.com
Tue Aug 12 17:27:05 UTC 2008
>>>>> "Andy" == Andy Burnett <andy.burnett at 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:
^self canvas tableCaption
^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.
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
More information about the Beginners