From: Robert Klemme Date: 2004-08-22T07:25:48+09:00 Subject: Separation of Web Request and Response (was: Re: Idea: Webshare) "Patrick May" schrieb im Newsbeitrag news:B73EE02E-F3B7-11D8-BFFE-000A95848050@hexane.org... > P.S. About the only cgi design suggestion I see on ruby-talk > that I outright disagree with is Request / Response. > > I experimented with this in Narf, and I think it is a mistake. You end > up with two objects, with alot of shared implementation code, that > always go together, split apart for no practical reason. I don't mind > having Request / Response separated in the documentation, but splitting > it in the code just adds typing. When will you ever want a request > without the response? Martin Fowler has a name for this refactoring, > but I don't have his book. > > The Java Servlet API is not one to imitate. It's a design which solved > the problem that Java was too slow to run as a CGI. Given that ruby > doesn't have that limitation, I'd rather design the API that makes > building web apps easy and fun. > > Why bother with the API that made it possible to run web apps on a > bloated os / programming language / platform / all around lemon? There are in fact good reasons in favor of the request / response split. First of all request and response are in fact two different things, so from that point of view it's not a bad idea to separate them. The interface of a combined request response instance is likely to get too bloated. There are use cases where you only need the response (say, a page that displays the current time) and there might be others where you don't need the response (can't think of any at the moment though, some kind of upload maybe :-)). Another reason why I liked the separation (in Java) is that you can easily wrap only one of them (common with filters in Java, but similar things can be done with Ruby, too); examples are filtering of whitespace from the response and adding default values for request parameters. If request and response are encapsulated in a single instance this becomes much more difficult to do - and the fun goes away. :-) That are my 0.02 on the matter... Kind regards robert