[Nitro] param handling

James Britt james.britt at gmail.com
Tue Oct 24 11:53:56 EDT 2006

George Moschovitis wrote:
>>George Moschovitis wrote:
>>>you propose to skip params altogether?
> But, this would be inconsistent if you have only a template and no action.
> Remember, nitro supports php style coding (ie no controller-view separation)

Well, I'm mainly tossing it out here for discussion.  I've not thought 
through all the implications.  Perhaps action-free templates could get a 
implicit controller/action that automagically handles params.

One thing I find interesting about Nitro is that plain Ruby class can be 
controllers; methods are passed the arguments as deduced from the 
calling environment.

Having params may be like having a console app that takes the 
command-line arguments and puts them into a global hash, but when 
invoking the application code it does not pass those arguments to 
methods.  Instead, methods then have to look in params.  It's as if 
every method has this (or a similar) signature:

def m( params={})


(I realize that params is a method, but when nearly every action has to 
use it to get data required for processing, the end effect is about the 
same as passing a hash to the method.  Except you don't have argument 

So I'm wondering if forcing explicit argument passing makes for code 
that is easier to read, test, and maintain.

When people write console apps, how common is it to use a global hash of 
values to inform methods?

To turn it around: outside of a Web app, where would one want to use a 
params object, and with what expectations or constraints?

Another view is to accept that controllers *are* special, and need to be 
so, and that they should not be treated as anything other than 
delegators that hook the operating environment to the business objects. 
  Controllers then would be easy to follow and not need much testing 
because they shouldn't do much besides call into business objects and 
populate variables for the views.

In that case, if you have a console app and want to move it to the Web, 
you would then add the controllers, rather than trying use the existing 
classes as controllers.

James Britt

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.rubyaz.org         - Hacking in the Desert

More information about the Nitro-general mailing list