简体   繁体   English

控制器vs视图模型vs域模型Asp.net MVC最佳实践VS Wicket框架MVC

[英]controller vs viewmodel vs domain model Asp.net MVC best practices VS Wicket Framework MVC

I have been learning Asp.net MVC 4 and have a background in Wicket. 我一直在学习Asp.net MVC 4,并且在Wicket中有背景。 I understand the MVC architecture from a design approach but reading the book "pro asp.net mvc 4 4th edition," there are some practices I am adjusting to. 我从设计方法上了解MVC架构,但是在阅读“ pro asp.net mvc 4 4th Edition”这本书时,我会适应一些实践。

One example (using entity framework) abstracts the domain away from the project entirely - creating a separate project for the domain model. 一个示例(使用实体框架)将域完全从项目中抽象出来-为域模型创建一个单独的项目。

My interpretation of this is: 我对此的解释是:

domain model = strictly objects to store a row of table data. 域模型=严格地对象用于存储一行表数据。 Sanitation done here for input. 此处已完成卫生工作以供输入。

view model = any data passed to from controller to view 视图模型=从控制器传递到视图的任何数据

controller = processing information to send to the view 控制器=处理信息以发送到视图

As you can see my understanding is pretty lightweight of each type because the view model vs domain model confuses me. 如您所见,我对每种类型的理解都很轻巧,因为视图模型与域模型使我感到困惑。

In the Wicket Framework it was model = business logic/database push and pulls, controller handled the logic of preparing to the data for presentation, and pushed it to the view, then the view is presentation/markup only code. 在Wicket框架中,模型是=业务逻辑/数据库推拉,控制器处理了准备要呈现的数据的逻辑,并将其推入视图,然后该视图仅是呈现/标记代码。

I am trying to get a grasp coming from the java/Wicket side of things how to understand the asp.net MVC best practices. 我试图从Java / Wicket方面来掌握如何理解asp.net MVC最佳实践。

ASP.net is similar to the Spring MVC in Java, or Struts2. ASP.net与Java或Struts2中的Spring MVC相似。 so basically you have model object which is you data object, this data object will get filled by the controller for you different operation such as GET, POST, PUT, and Delete. 因此,基本上,您有一个模型对象,即您的数据对象,该数据对象将由控制器填充,以执行诸如GET,POST,PUT和Delete之类的不同操作。 then the controller is responsible to send these model to the view which will use the Razor to manipulate your syntax, so in this context Razor is some thing similar to JSTL in Java. 然后控制器负责将这些模型发送到将使用Razor操纵您的语法的视图,因此在这种情况下Razor与Java中的JSTL类似。 So You cannot compare Wicket to ASP.net MVC because Wicket is widgets API in java similar to the standard ASP.net. 因此,您无法将Wicket与ASP.net MVC进行比较,因为Wicket是Java中的窗口小部件API,类似于标准ASP.net。 Hopefully this give you better idea. 希望这能给您更好的主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM