MVC: What is the difference between a model and a service?

Why in some frameworks the logic layer is called “Model” whereas in some it is called “Service”. Are they different from each other or just different by naming conventions?


UPDATE 1

The reason I’m asking is because in Zend Framework, a classical MVC framework, everybody uses the concept of Model. Now I’m learning AngularJS and it seems that the word Model disappeared and was replaced by the word service.

What I noticed is that a service is more like a singleton that can be reused again and again (example: a REST client) whereas a model is more related to the data manipulations coming from the controller in the MVC pattern.

2

Model: Fields that belong to the object, methods that help to get/set data from the object (a fullname accessor that returns first + last name)

Service: Methods to perform operations with one or more models, see ‘unit of work’, transactions, etc…


Employee::create should just take a set of data, perform model validation if necessary, and return an Employee Object.

EmployeeService::hireEmployee might create the employee, send them a welcome email, create a mailbox, make them a sandwich, etc… it may return the set of data, or a result code, etc…


This can also affect validation:

Model Validation: Employee must have a id, first and last name, and birthday

Service Validation: Employees for the bartender position must be 21 or over, and approved by a manager.

1

According to my experience, the Model layer within the MVC design pattern refers to every software component involved with data manipulation (POJOs, DAO, all the way to SQL, JDBC, and so on).

Whereas the service layer is actually an addition to MVC:

We know that the Model layer components are invoked inside the Controller layer. Once the latter is built, you come to realize that it doesn’t look concise (messy with dirty code); the Controller may not afford extra details (e.g. formatting request parameters before calling a DAO method that are going to consume them …). Therefore, you might include this extra layer, namely the Service layer.

Eventually, you may encompass your dirty code inside static methods with a meaningful name, parameters and so forth, which would outcome a synthetic Controller layer.

Take a look at this link:

https://stackoverflow.com/questions/2762978/the-purpose-of-a-service-layer-and-asp-net-mvc-2

1

Structurally these base classes are the same, however they are used to classify a different concerns of the Service and Model tiers of the MVCS implementation

Service:- A concrete service class defines the API of an external Service.

Model :- Defines the API of the applications data model.

So, whilst the base classes are alike, the concrete classes created by extending these base classes serve two entirely different purposes.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật