简体   繁体   中英

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. 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.

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.

I am trying to get a grasp coming from the java/Wicket side of things how to understand the asp.net MVC best practices.

ASP.net is similar to the Spring MVC in Java, or Struts2. 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. 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. So You cannot compare Wicket to ASP.net MVC because Wicket is widgets API in java similar to the standard ASP.net. Hopefully this give you better idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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