Note that there are some explanatory texts on larger screens.

plurals
  1. POShould the business logic be separate from the model?
    primarykey
    data
    text
    <p>We're working on a fairly code-heavy PHP5 project, and in the last week I worked on a PoC of a RESTful API. We are separating Model Classes from Business Classes.</p> <p>Trying to implement CRUD functionality, I discovered, that implementing CRUD against the Models directly would be pretty straight-forward while implementing it against the Business Logic isn't, since its functionality is specific to the currently existing Views and its interface doesn't provide the general data access model I need for implementing the API.</p> <p>Thinking about this, the following questions came to my mind:</p> <ul> <li><p>What is the best way to interact with the data, keeping the flexibility of the model <em>and</em> keeping the functionality the model doesn't care about at the moment (like sending a mail with an activation link when changing the email address)?</p></li> <li><p>Working a lot with django previously, where most of the business logic is implemented in the model, why should you keep the business logic separate anyway? Do you have any real-life examples? What problems does this solve, if any?</p></li> </ul> <p>Some possible solutions came to my mind, too:</p> <ul> <li>Putting the whole business logic into the model. Checking which fields changed after / before calling the save method.</li> <li>Using the observer pattern to notify the business objects of changes in the model and interact with the models directly.</li> </ul> <p>What are the pros and cons in your opinion, what would you do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload