Models in the MVC structure are only for database operations?

4

I've learned that "Whenever you think of data manipulation, think about model. It is responsible for reading and writing data, and also for validating it."

Later on another person told me that models is exclusively for data processing, specifically database interface, connection to server (or with others), update, insert, delete, select and these things referring to database .

In this case if I have a class called getAllPageContents responsible for:

  • Download a particular webpage.
  • Extract all meta tags from this page
  • Extract all links and text from this page

And that returns in an array format. If I want to make this class a model of my MVC I could not? Since it is not related to database operations?

In my case this same person recommended that this logic of the above class should be inside the controller itself or in a separate file but not considered as a model and outside the model folder.

I would like to know if this information that the files inside the model folder are unique only for operations with database is true, and if it is a design pattern?

    
asked by anonymous 25.03.2017 / 00:01

1 answer

1

Models refer to business rules

The Model layer refers to anything related to the business rules of the application, that is, it is not limited to database.

If the items you listed are part of the rules that define how your project works, then they are owned by the Model layer. It is not necessary to limit itself, because this layer can contain validations, reading data of files and etc.

    
15.07.2018 / 03:18