Hi
A question about OO design:
Class WADialog gives you basic Dialog behaviour. It seems to me that I might like to subclass this in two orthogonal directions: either (1) to give different look'n'feels, ie by overriding #renderContentOn, or (2) to give extra behaviour on top of the standard Dialog (ie build something more complex, that also IS-A Dialog).
I have the feeling that (2) is the 'real' inheritance tree here. Which suggests to me that perhaps the variation allowed by (1), which is also necessary, should be modelled by delegation rather than inheritance.
But what would this look like? It might look like a separate View class per Controller. But I seem to remember reading somewhere on this list that you deliberately decided to merge the V and C of MVC into seaside's 'Component' concept.
Does this chime with anyone else? Or am I just missing something. I'm still getting my head around how the framework hangs together (too little CopiousSpareTime :)!)
thanks! pmg
_____________________________ Paul Mitchell-Gears www.digitalbrain.com
-- Some men are born mediocre, some achieve mediocrity, and some have mediocrity thrust upon them.
On Mon, 16 Jun 2003, Paul Mitchell-Gears wrote:
Class WADialog gives you basic Dialog behaviour. It seems to me that I might like to subclass this in two orthogonal directions: either (1) to give different look'n'feels, ie by overriding #renderContentOn, or (2) to give extra behaviour on top of the standard Dialog (ie build something more complex, that also IS-A Dialog).
I have the feeling that (2) is the 'real' inheritance tree here. Which suggests to me that perhaps the variation allowed by (1), which is also necessary, should be modelled by delegation rather than inheritance.
But what would this look like? It might look like a separate View class per Controller. But I seem to remember reading somewhere on this list that you deliberately decided to merge the V and C of MVC into seaside's 'Component' concept.
Paul,
These are interesting issues, and certainly ones that I don't feel I have a firm grasp on, so it's great to be discussing them. A few comments:
- The general model I've been trying to advocate is that look+feel changes happen through CSS, not through HTML generation. To that end, I've been writing components with minimal markup and lots of css class/id info. They can then be used in lots of different applications, each of which provides its own stylesheet to customize their look.
It's quite surprising how much can be achieved with CSS; I was recently shown http://csszengarden.com/, which includes tens of wildly different looks for the exact same HTML.
- Depending on how you want to extend the behavior of Dialog, embedding may be an option. In general, I lean towards composing lots of small components, rather than subclassing large ones. That would leave inheritance open for points on the look+feel axis that can't be covered by CSS (for example, if you wanted to use links instead of form buttons).
- There's nothing stopping you from having a separate view object that the component delegates to. Just have, say,
renderContentOn: html html render: (self viewClass new controller: self)
viewClass: aClass viewClass := aClass
viewClass ^ viewClass ifNil: [MyDefaultViewClass]
I would strongly encourage people to experiment with designs like this; if we find that a more explicit view/controller separation works out well, maybe we'll want to move the framework formally in that direction in a later version. I think things are flexible enough right now that nothing should get in the way of trying this. (If you were going to set something like this up, you might want to look at subclassing from Controller directly, instead of Component, since the various rendering methods that Component adds wouldn't be used).
Anyone else have thoughts here?
Avi
On Mon, 16 Jun 2003, Paul Mitchell-Gears wrote:
Class WADialog gives you basic Dialog behaviour. It seems to me that I might like to subclass this in two orthogonal directions: either (1) to give different look'n'feels, ie by overriding #renderContentOn, or (2) to give extra behaviour on top of the standard Dialog (ie build something more complex, that also IS-A Dialog).
I have the feeling that (2) is the 'real' inheritance tree here. Which suggests to me that perhaps the variation allowed by (1), which is also necessary, should be modelled by delegation rather than inheritance.
But what would this look like? It might look like a separate View class per Controller. But I seem to remember reading somewhere on this list that you deliberately decided to merge the V and C of MVC into seaside's 'Component' concept.
Avi has been focusing on CSS, and asked:
Anyone else have thoughts here?
<sigh> I just can't sit on this any longer.
Another option is templates, of course. I've been working on a template system for Seaside 2, with an emphasis on testable components. I'll be giving a talk about it at Smalltalk Solutions in July and hope to have a first release done before then.
Templates essentially re-separate Components into Controllers and Views, so that the controller hierarchy satisfies your need for (2) above. You can, of course, write new views if you like, but if I've done it right, you should be able to vary the look and feel just by changing the template.
At this point, the basics are in place, and I'm trying to build a reasonably complex interface with it so as to work the kinks out. I'll keep you all posted.
Cheers,
Colin
On Mon, 2003-06-16 at 22:12, Avi Bryant wrote:
Anyone else have thoughts here?
I'm quite succesful in our own web framework (older than Seaside, but we're slowly refactoring towards Seaside so one of the things that's almost the same is HTML generation) by plugging HTMLLookPolicy classes into the HTML generator.
Most of the 'hard' work is delegated to the current look policy by the generator class. For example, our default look policy generates tab controls by using tables and borders; but if you go to http://webmail.444.net/ you see the same tab controls generated using another policy (sorry, don't have a ready-to-click link for the 'default' look).
Exactly what the generator delegates to the look policy is determined by thinking up more look policies and refactoring ;-)
We are very pleased with the end result. Most of the look is moved into a single place, and we're not constrained by CSS (esp. CSS+browser compatibility concerns me).
seaside@lists.squeakfoundation.org