qiang, on 12 August 2010 - 09:14 AM, said:
Why not develop an action class instead of a behavior?
Using action classes is fine (and I've done so a number of times) when it's about one/the occasional action, but if you are making for example an extension that provides a number of actions actions (possibly in combination with other stuff like a widget needing to call home to the actions you want to provide here), then it's way cleaner for the user of the extension to add one little behavior instead of a list of action classes, to the controller. That is the main reason I want actions in behaviors, for extensions (base controller classes are not a good option here, for obvious reasons).
When a request comes in, the controller checks for an action method on itself. If none is found it uses the action class map to find an action. Adding to that a third check for action methods in the controller's behaviors, that runs after the two aforementioned checks, shouldn't add a notable overhead except for when the behavior *should* actually be used to handle the request (in which case it should be fine). Right, or am I missing something obvious in that reasoning?
Apart from that I guess there's a slight overhead when the behavior is added to the controller, but seriously that cannot be much, can it? In worst case, if someone has such *extreme* performance requirements that they cannot afford adding a behavior to a controller with the overhead of having it initialized, then they can simply use action classes instead.
Thanks for listening!