Welcome Guest, Not a member yet? Register   Sign In
CONTROLLERS, single method or different methods for different actions?
#11

(05-11-2016, 02:55 PM)PaulD Wrote: As for the colour removal, I would do the customer form as a normal form, but deleting and adding colours as a javascript function, so when the user deletes a colour it just pops off the screen (with a 'saving changes' pause in the middle - I always love using those animated loading gifs), without the user having to refresh the page for such a minor thing.

Alternatively, make the 'Edit Colours' a seperate form altogether. It is just a matter of user interface design. For the user sometimes doing this in a blocky way can be easier to follow. "How do I change my favourite colours?" "Ah, here is a big button that takes me to a nice clean screen that enable me to do that".

For me, for speed of coding I would do the blocky multi page approach, for quality experience I would do the javascript approach. Personally I try to avoid using 'flags' in hidden form fields as much as possible.

Thanks, I have gone with the "quality" experience where colours can be assigned to a customer (or removed from a customer) using JavaScript / Ajax (colours are a many to one relationship). It works fine and is less clicks and less screens for the user to contend with, but what I am still unsure about is whether to route this to a different method to the one used to change the normal customer details (such as name and email address), or to a master method which then figures out whether the user is trying to change the customers email address, or whether they're trying to add or remove colours.

(05-11-2016, 01:08 PM)cartalot Wrote:
Quote:But if I had separate forms all going to the same controller, using a hidden task field, had I might as well not just have separate forms routing to separate controller methods?

for me - the advantage is that i only have one public method in the controller and the only thing that method is doing is routing to the different private methods depending on which form it is. this keeps the forms simpler - they all go to the same place. and it keeps the controller safer because none of the form methods are public. and a small benefit is being able to look at the public method in the controller and very quickly see what forms are calling on it and which methods they route to.

OK point taken, this makes sense. I did it this way initially and ended up with a big fat controller. Then I modified it slightly so it was a main controller, and I created several private sub controllers.

Then I changed it again into separate public controllers, and pointed the different forms on the page to the relevant controllers (basically the opposite to what you're saying above). Now I'm inclined to go with what you're saying and change it back again!

At some stage I'm going to have to get on with actually building the system, but I am going round in circles at the moment trying to get a feel for what is most appropriate way of doing things.
Reply


Messages In This Thread
RE: CONTROLLERS, single method or different methods for different actions? - by CINewb - 05-11-2016, 04:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB