user1290651
user1290651

Reputation:

MVC architecture:What exactly does model comprises of?

Is model comprises of model object and classes that perform database connection and database operation and service class?

It is normally believed that service layer fills the gap between controller and model.So,what exactly service layer does,it creates the object of class that performs the database operation?

Upvotes: 1

Views: 224

Answers (2)

tereško
tereško

Reputation: 58444

Structures in service layer do not make database connections.

The connection is created at the bootstrapping stage of application and via builder/factory, it is passed to each of data access object (usually implementing DataMapper pattern). This is the part that actually interacts with database. The rest of structures in domain business logic part of application has no idea, where or how the information is stored.

Service layer itself has two major groups of structures:

  • Third party or your own component that have no interaction with rest of your business logic (like some lib which deals with sending emails).
  • Public API for interacting with domain business objects (what people tend to mistakenly: models) and data access objects. This is to limit controllers involvement in business logic.

Upvotes: 1

giorashc
giorashc

Reputation: 13713

The Model is used for storing and manipulating application data. It is not merely responsible for database connection/operations.

And there is nothing better than looking in the wikis.

Upvotes: 0

Related Questions