refactoring large renderContentOn: methods...

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

refactoring large renderContentOn: methods...

Rick Flower
I've got one renderContentOn: method for one of my web-app classes (and
believe that I'll probably have this sort of issue with some of my other
rendering classes as well) and would like to break-apart some of the
content into smaller pieces that can then be directly rendered by the
aforementioned renderContentOn: method.  I tried using perform: but am
not really sure how it works (and I didn't get it to work), but it
looked similar to what I'm looking for (I saw it in some of the Seaside
example test code).  Anyway, just wondering if this is do-able or not
and if so, what's the best method?

Thanks!

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

Re: refactoring large renderContentOn: methods...

Philippe Marschall
2006/7/20, Rick Flower <[hidden email]>:
> I've got one renderContentOn: method for one of my web-app classes (and
> believe that I'll probably have this sort of issue with some of my other
> rendering classes as well) and would like to break-apart some of the
> content into smaller pieces that can then be directly rendered by the
> aforementioned renderContentOn: method.  I tried using perform: but am
> not really sure how it works (and I didn't get it to work), but it
> looked similar to what I'm looking for (I saw it in some of the Seaside
> example test code).  Anyway, just wondering if this is do-able or not
> and if so, what's the best method?

Break it up into several renderXXXOn: methods and send them from
renderContentOn:. If you can live with pretty printing you can use
extract method refactoring (hope it works).

ex

renderContentOn: html
    self renderHeaderOn: html.
    self renderFormOn: html.
    self renderFooterOn: html

if you want it to do with a perform

renderContentOn: html
    #(renderHeaderOn: renderFormOn: renderFooterOn:) do: [ :each |
        self perform: each with: html ]

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

Re: refactoring large renderContentOn: methods...

Damien Cassou-3
In reply to this post by Rick Flower
Rick Flower wrote:
> I've got one renderContentOn: method for one of my web-app classes (and
> believe that I'll probably have this sort of issue with some of my other
> rendering classes as well) and would like to break-apart some of the
> content into smaller pieces that can then be directly rendered by the
> aforementioned renderContentOn: method.  I tried using perform: but am
> not really sure how it works (and I didn't get it to work), but it
> looked similar to what I'm looking for (I saw it in some of the Seaside
> example test code).  Anyway, just wondering if this is do-able or not
> and if so, what's the best method?

Hi,

I'm sure I miss something in your mail but can't find what. Why do you
need #perform: ? This message is used when you have a symbol and want to
call the associated method.

selector := #printString.
value := 13 perform: selector.

value is a string that equals to '13'.


If you want to simplify renderContentOn:, you can always do things like
this:

renderContentOn: html
   self renderTitleOn: html.
   self renderBodyOn: html.
   self renderFooterOn: html


and implement thoose three new methods. But again, I'm quite sure you
already know that. You may want to explain again what you want.


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