[LRUG] [NOOB] On fat controllers
Nieve
nievegoor at gmail.com
Wed Sep 26 01:38:44 PDT 2012
Hello all,
A few sessions ago someone discussed the issue of fat come controllers and
how to move move away from them in rails. Now, recently I have started
working on railstutorial.org as a way to get some exposure to the framework
and though my controllers didn't get to a monstrous situation yet, I can
already see that SRP isn't being applied thoroughly in the tutorial
(probably srp is outside the scope) and being the impatient student that I
am, I thought I could try my luck here.
Ok, so I've got this little controller here (
https://github.com/nieve/Nivter/blob/master/app/controllers/users_controller.rb),
nothing too complex. However, I can already see that all sorts of different
concerns are leaking into this controller (authentication & authorization
namely) and that's without even talking of the too many actions one
controller is responsible for.
Googling around, I eventually stumbled upon a solution to one of the issues
that looks quite cool (https://github.com/jonleighton/focused_controller)
and I was wondering if this is something people tend to use or do you turn
to other means to address this issue? Also, I was wondering regarding the
separation of concern, in the .net world we tend to use AOP in order to
achieve a nicer SoC; however, recently a few guys have written this new
front controller framework that uses what they call Behaviours (
http://fubumvc.readthedocs.org/en/latest/topics/behaviors/index.html),
which manages to capture really nicely the idea of a request pipeline-
something that makes more and more sense to me: in order to handle a
request we usually tend to go through a few steps before (and sometimes
after) the action is executed; in some cases, ending the request if a
certain condition isn't met. It seems to me rather natural to use something
like behaviours or a pipeline or a russian dolls pattern to convey just
this, so that every step in the chain is responsible to either continue the
chain or end it. Is there anything similar to that in rails? Would it even
make sense at all in rails?
Would appreciate your thoughts
Nieve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20120926/490e9a6f/attachment.html>
More information about the Chat
mailing list