Welcome Guest, Not a member yet? Register   Sign In
Where should logic go [edited]
#6

the controller issues commands - anything 'specific' about those commands belongs in a model (or a library or config or...)

plump controllers that get refactored to thin controllers
fat models that get refactored to models with specific tasks inside a directory folder

thin controllers with declarative method names:
displayAllBlogPosts() or searchForBlogPostBy($id)

fat models that get refactored to their own folders
with bigger applications, its much faster to open the model folder
and then see a nice clean directory structure with relevantly named folders
then you can quickly dig into the appropriate part of the project to work on the appropriate models

refactor so there are no validation methods in the controller
again the controller issues commands - the method in the controller asks - did this form validate or not?
is this user logged in or not? its not concerned with the names of a form field or what kind of validation is being done.
then you can update your form validation - and very importantly - your controller code does not change at all.
the change is constrained to a specific part of the application that is just concerned with validating the form.
Reply


Messages In This Thread
Where should logic go [edited] - by marksman - 02-19-2017, 06:41 AM
RE: CodeIgniter 3.1.3+ - by albertleao - 02-19-2017, 09:39 AM
RE: CodeIgniter 3.1.3+ - by marksman - 02-19-2017, 02:05 PM
RE: Where should logic go [edited] - by cartalot - 02-20-2017, 12:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB