Have I implemented a n-tier application with MVC correctly?

蓝咒 提交于 2019-11-28 10:35:47

I'm not sure if I can call this n-tier MVC when the models are lists/VO's returned from business objects in the logic tier

Those are perfectly good models. I also consider the ActionForms in Struts to be models. ActionForms are what Struts uses to represent/model HTML forms.

in MVC the view is supposed to observe the model and update on change, but this isn't possible in a web-application

Yep, and that is a matter of debate as to whether you can have true MVC with web-applications.

Should one always have a business layer?

It depends on the type of application. Some applications are database-driven, and are essentially a UI for the database. In that case, there's very little business logic required.

Data Tier:

The stored procedures aren't really part of the data tier code. You should be creating data access objects (DAOs) which are called by the business objects. The DAOs call the stored procedures. Further, the DAO interfaces should give no hint to the business objects as to where the data is stored, whether that be a database or file system or from some web service.

I think you are getting hung up in the terminology. The MVC pattern (I believe) pre-dates the classic web app arch you describe. It use to be that people called web app arch MVC 2 (Model 2 etc.) to differentiate it from the original MVC pattern...

see this link > http://www.javaranch.com/drive/servlet/#mvc2

HTH

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!