1

For example,

if I have 3 database tables that have similar columns/attributes: cats, dogs, bunnies

Each table has a view that consists of an html table listing all records in the table, and a form to add new records.

If I have an action to display the base page, an action to add new records into the table, an action to edit records in the table, and an action to delete records from the table, and all of this per table, it seems like a lot of actions in my controller.

Is it ever appropriate to instead of have 3 actions like actionAddDog(), actionAddCat(), actionAddBunny() have a single action actionAddPet() and then use some kind of flag to determine which type of pet it is, and add to the specific table? Or is it always better to have separate actions for the sake of clarity?

  • Your example would be a better one if it was related to an actual, real-life programming problem and not dogs, cats and bunnies. – Robert Harvey May 17 '18 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.