On 3/22/10 3:57 PM, Jordi Boggiano wrote:
On 22.03.2010 13:52, ever.zet wrote:

First, I want to thank you all for taking the time to comment the first RFC. 
After the discussions that took place, I have created a version 2 of the RFC:

http://symfony-reloaded.org/rfc/controllers

Now i like "Approach 4". It's universal&  good enough for all.

I would also favor 4 since it empowers users with a choice (and nobody
seems to really agree on one best way). As I already pointed out though,
and I don't know why it was left out of the second RFC, service
variables in actions really should be pre-fixed, post-fixed, or anything
that differentiates them from route variables, and route variables
should be prevented to have a name that will conflict with that defined
pre/post-fix, so as to avoid any problems (WTFs) when refactoring code.

It is in the new version of the RFC:

"To avoid naming conflicts and simplify the rules a bit, we can probably introduce some naming conventions (like adding a prefix for services)."


This approach btw allows Fabian to still only inject the container in
the constructor and then fetch all services by hand when needed.

As for using the pre/post-fix in the constructor variables, I don't see
why. The typical use cases I see are those :

  - Give me the container and I will fetch everything:
    function __construct($container)
    function list($id)
    function read($id)
    function comment($id, $mailerService)
    =>  clean

  - Give me most of my services in constructor, and every now and then an
extra one in the action:

    function __construct($request, $user, $db)
    function list($id)
    function read($id)
    function comment($id, $mailerService)
    =>  there you bloat it a bit in one call, but it's for the sake of
performance and should happen rarely

  - I like long signatures, give me all in every function:

    function __construct()
    function list($requestService, $userService, $dbService, $id)
    function read($requestService, $userService, $dbService, $id)
    function comment($requestService, $userService, $dbService,
$mailerService, $id)
    =>  bloated but at least you don't have conflicts

If you force the prefix in the constructor you penalize everyone for the
rare use case of the (i.e.) mailer. I don't think it's necessary.

Point taken.

If there is a consensus about the Service suffix, I will have update the RFC accordingly.

Fabien


The way I see it, it's not uncommon to use 5-6 services minimum in every
request, be it in the action itself or in some helper you call, so I
don't think people will really want to declare them all every time in
their actions, then forward them to their helper methods etc.. So the
added verbosity sounds alright in that place.

Cheers,
Jordi


--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

To unsubscribe from this group, send email to symfony-devs+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to