Why do Seaside's table tags e.g. td etc., live 'outside' of table?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Why do Seaside's table tags e.g. td etc., live 'outside' of table?

Andy Burnett
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

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Why do Seaside's table tags e.g. td etc., live 'outside' of table?

Randal L. Schwartz
>>>>> "Andy" == Andy Burnett <[hidden email]> 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.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <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
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners