Welcome Guest, Not a member yet? Register   Sign In
View-centric design philosophy with CI
#4

[eluser]Colin Williams[/eluser]
Well, sure, users can do a lot of things, but only the things a user can do with users should go in the User controller. Users can add pages, add categories, but pages and categories are their own objects. Hrm.. objects... Makes a lot of sense to have one controller per object, at least as a start. Then you just restrict the scope of each controller to its own object as much as possible.

I'm not sure I would get too concerned with the amount of methods any given controller contains, so long as you aren't repeating code when it makes more sense not too. I do agree that each method should remain fairly slender, putting a good amount of heavy lifting on the model, but again, only when it makes sense. Sometimes a controller method has a lot to, well, to control. Imagine a cart/checkout controller method:

1. Read the cart items
2. Build the order
3. Validate checkout form
4. Possibly add new customer data
5. Send order to payment gateway
6. Save order to database
7. Email store admin
8. Build invoice
9. Email customer the invoice
10. Show success screen

And that example doesn't even show exception handling, since any step along the way could fail. Size doesn't always equal bloat


Messages In This Thread
View-centric design philosophy with CI - by El Forum - 08-24-2008, 08:15 PM
View-centric design philosophy with CI - by El Forum - 08-24-2008, 09:17 PM
View-centric design philosophy with CI - by El Forum - 08-24-2008, 09:52 PM
View-centric design philosophy with CI - by El Forum - 08-24-2008, 11:27 PM
View-centric design philosophy with CI - by El Forum - 08-25-2008, 08:02 AM
View-centric design philosophy with CI - by El Forum - 08-25-2008, 12:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB