From: Patrick May Date: 2004-08-24T08:44:28+09:00 Subject: Re: Idea: Webshare On Monday, August 23, 2004, at 06:45 AM, Andreas Schwarz wrote: > Can you give an example of what advantage a combination of request and > response would bring in practice? Every web app I've written depends on a combination of request and response. I think that combining the two simplifies makes for cleaner, simpler code. Splitting up request / response you have to pass the objects around: def delegate( request, response ) case request["param"] when "submit" do_submit( request, response ) else show_form( request, response ) end end request, response = cgi.create delegate( request, response ) It seemed simpler to use a single object: def delegate( cgi ) case cgi["param"] when "submit" do_submit( cgi ) else show_form( cgi ) end end delegate( CGI.new ) Now, I think the best API is to let a global manage a singleton: def delegate case Web["param"] when "submit" do_submit else show_form end end delegate Passing around all those objects felt like useless typing to me. And given that it made it easier to implement the library, that's how I've arrived at my opinion. Splitting request / response up just didn't seem to be justified, while merging them created visibly simpler code in my apps and the library. (I think caching is a side issue. None of these designs supports caching by default because they all have a connection to the client in there. Any of these designs can be made to support caching with some effort.) Cheers, Patrick p.s. another thread sprung up out of this conversation; see [ruby-talk 110096]