CodeIgniter Forums
Controller code.. your opinion? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Controller code.. your opinion? (/showthread.php?tid=12366)

Pages: 1 2


Controller code.. your opinion? - El Forum - 10-17-2008

[eluser]SitesByJoe[/eluser]
[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?


Controller code.. your opinion? - El Forum - 10-17-2008

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


Controller code.. your opinion? - El Forum - 10-21-2008

[eluser]ok3x[/eluser]
Thanks guys


Controller code.. your opinion? - El Forum - 10-21-2008

[eluser]sl3dg3hamm3r[/eluser]
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.


Controller code.. your opinion? - El Forum - 10-21-2008

[eluser]Dready[/eluser]
Hello,

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.


Controller code.. your opinion? - El Forum - 10-21-2008

[eluser]rogierb[/eluser]
@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 :-)