[LRUG] Proffer and introducing constraints to Rails

Viktor Tron viktor.tron at gmail.com
Wed Apr 4 11:59:22 PDT 2012


On Wed, 04 Apr 2012 19:47:02 +0100, Daniel Barlow <dan at telent.net> wrote:

>  On Mon, Apr 2, 2012 at 4:17 PM, Tom Stuart <tom at therye.org> wrote:
>> Also, I can't think of many situations in which one sets an instance  
>> variable in a Rails controller (with the exception of setting up an  
>> object in a before_filter for use in an action - see conversations  
>> passim) for any reason other than exposing it to the >>view. I'm not  
>> convinced that changing "@post = foo" to some explicit means of passing  
>> the data to the view is a huge inconvenience.
>
> I agree that from the controller's point of view it's just syntax and  
> "@foo=1" is just as good syntax as "proffer :foo".    But now pretend  
> you're the *view*: there's no way on that side of the interface to for  
> it to specify the data it needs. I think it'd >catch a non-zero quantity  
> of bugs[*] if  views could explicitly declare the parameters they depend  
> on and bail out (instead of assuming nil) unless all are supplied.  I've  
> used Erector a fair bit and it does have the right idea here, imo

I elaborated on this idea in my earlier response. Would love to hear more  
reactions to it.

>
> And though I agree that the complexity of this interface rarely reaches  
> levels where it actually *matters* that much, perhaps that in itself is  
> an artefact of the less-than-optimal convention we have here: the  
> subconscious cognitive burden of having to >remember which variable  
> names are important is preventing us from designing cleaner, more  
> expressive, more general programs.  (Or on the other hand, perhaps the  
> same cognitive burden is preventing up from ballsing it up completely -  
> who >knows?).  There's an analogy to be made here with lexical vs  
> dynamic scope, and history came down squarely on the lexical side of  
> that debate the first time around.
>
> Except for emacs lisp programmers, obviously.  But they're a special case
>
>
> -dan
>
> [*] my bugs, at least.  Your buggage may vary.
>
> --dan at telent.nethttp://ww.telent.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20120404/276263bc/attachment.html>


More information about the Chat mailing list