Object Model in Seaside

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

Object Model in Seaside

Oleg Richards
Hello!

First of all i would like to say thank you to everybody, who helped  
me with
evaluation expression suggestions.

My next question is model - view separation. This night i have found  
one solution, but
i would like to know your opinion, guys. So here is it:

I have a reporting application. So i have model Report Template. This  
report template consists of
different rows. Every row is defined by each own class, inherited  
from BaseRow for example.

Now i need to render template. In my TemplateComponent i should go  
through each row and render it, but
every type of row looks different. If i will add a big if - it will  
be procedure code. I dont want it and i don't want
to write code to this if, if i need to add more rows. Another way is  
to add rendering code to row model itself. But this
will break model - view separation. So what do you recommend to me?

I found this solution: Create one more class (Should it be inherited  
from WAComponent ?) - RowComponent or RowVisual.
And create a subclasses for it, which will represent every type of my  
row. Then i just should go through every row in my
TemplateComponent and look up at dictionary which will find a proper  
Component renderer for me. With such way i can also
make additional functionality. I can create subclass of  
SpecificRowComponent for different application modes - for example  
Editing, Viewing, e.t.c.

So what do you think about it? Is there a better way to accomplish it?

Cheers, Oleg
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Object Model in Seaside

Conrad Taylor
Hi, you can easily seperate the two.  Your view can be derived from WAComponent and your model can easily be derived from Object or any non-WAComponnent class.  It seems that you might be mixing the View and Model.  For example, if you're talking about how it's presented to the user, then we're talking about a view.  On the other hand, if you're talking the data that gets rendered, then you're talking about the view.  Next, the name of a class should convey its intention.  If you have a reporting application, you can use the Report as your model and ReportComponent as the associated view.  It's really up to you but you get the idea.  Now, a ReportComponent may have several actions:

list
edit
update
download
and so on

Furthertmore. these actions may invoke other components ( i.e. views) for managing the underlying model (i.e. Report).  Well, this is one way of structuring your code and I wish that it helps.

Good luck,

-Conrad

On 8/23/07, Oleg Richards <[hidden email]> wrote:
Hello!

First of all i would like to say thank you to everybody, who helped
me with
evaluation expression suggestions.

My next question is model - view separation. This night i have found
one solution, but
i would like to know your opinion, guys. So here is it:

I have a reporting application. So i have model Report Template. This
report template consists of
different rows. Every row is defined by each own class, inherited
from BaseRow for example.

Now i need to render template. In my TemplateComponent i should go
through each row and render it, but
every type of row looks different. If i will add a big if - it will
be procedure code. I dont want it and i don't want
to write code to this if, if i need to add more rows. Another way is
to add rendering code to row model itself. But this
will break model - view separation. So what do you recommend to me?

I found this solution: Create one more class (Should it be inherited
from WAComponent ?) - RowComponent or RowVisual.
And create a subclasses for it, which will represent every type of my
row. Then i just should go through every row in my
TemplateComponent and look up at dictionary which will find a proper
Component renderer for me. With such way i can also
make additional functionality. I can create subclass of
SpecificRowComponent for different application modes - for example
Editing, Viewing, e.t.c.

So what do you think about it? Is there a better way to accomplish it?

Cheers, Oleg
_______________________________________________
Seaside mailing list
[hidden email].org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside