Again something about Model layer im MVC architecture

I write about models importance quite often (maybe I’ll provide translation to my previous polish-only posts). But models are important, and I found confirmation that isn’t just my imagination. It was found in a book I actually read:

There’s a interesting paragraph about model layer:

A model is more than just data; it enforces all the business rules that apply
to that data. For example, if a discount shouldn’t be applied to orders of less
than $20, the model will enforce the constraint. This makes sense; by putting
the implementation of these business rules in the model, we make sure that
nothing else in the application can make our data invalid. The model acts as
both a gatekeeper and a data store.

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *