Welcome Guest, Not a member yet? Register   Sign In
Controller code.. your opinion?

[quote author="xwero" date="1224297790"]Joe you have to use routing with method A you have nice urls with method B[/quote]

Aren't we always? Doesn't the routing begin with the index.php examining our uri segments?

With B you don't have to route to use the user/add segments, for A you have to use the route
$route['(user)/(add|edit|delete)'] = 'users/$2_$1';
I'm using the code from the starter topic.

Thanks guys

just a note: I use add and edit often in the same function call (often it is also the same view with the same form). If an id has been transfered, I would need to mutate a DB-record, otherwise I do an insert.


from my point of view, if you think about CI and MVC style, the controller class is the "topic" (who), the controller method is the "action" (what), and the other segments are the arguments.
That's why I'll go for option A.

@dready This works perfectly for relatively small controllers (<100 functions) but for larger controllers I find method B to be preffered. Of course, this is just how I like to work.

One can also split controllers but then the theory/practice of topic-method-arguments is busted.

So for small controllers I go for method A, Large controllers I go for method B, extremely large controllers I go for method C :-)

Theme © iAndrew 2016 - Forum software by © MyBB