Welcome Guest, Not a member yet? Register   Sign In
best practice separating business logic from controller and model

(12-06-2020, 11:40 AM)captain-sensible Wrote: its been 6 hours no answer so let me kick it off : i have a feelig that Lonnie new book might answer this:


also depends on complexity. The most basic pattern is :

view : presentation and what web surfer sees. Can be made more compact. Instead of a "header" view , "content" view and "footer" view, that make up web page just use "layout". 
model: connects to and models data
controller : basic logic

so for instance i use PHPMailer in a controller the lines are not excessive so i could user a "manager class" which controller will use but from a birds eye view , it probably won't reduce code.Then Lonnie talks about dependency injection, entities and so on. I think what you find works best for you is the way; tidying up code and reducing stuff will flow naturally , at least it does in my case .

Business logic should be in model, separated from DB model. Business logic should be omitted from view and controller. For CI4 structure probably the best place for business logic is Domain folder under app folder.
I'm not expert at that field but worked in a company that was trying to develop using Domain Driven Design (DDD) approach.


Messages In This Thread
RE: best practice separating business logic from controller and model - by blagi - 12-07-2020, 07:37 AM

Theme © iAndrew 2016 - Forum software by © MyBB