It seems to be the view and controllers are rigidly defined, but the model is highly nebulous. For instance, views go in views folder, controllers have the word controller in their name and have controller annotation, but models...?
What is the standard or de facto or at least the recommended way of implementing the model in Spring MVC and where is it located in the directory structure?
How does the model tie in with the controller? Does the model have direct access to the database? Thanks
-
1The Model is everything that is not a Controller or a View. That can include a Data Access Layer, a Service Layer, a Business Logic Layer, Aggregate Roots, and maybe even some DTO's and ViewModel objects. If you want to put all that in a "Model" folder, that's as good a strategy as any.Robert Harvey– Robert Harvey2016年08月18日 18:16:48 +00:00Commented Aug 18, 2016 at 18:16
-
Which of these model elements generally constitute a barebones model that interfaces with a database?Wes– Wes2016年08月18日 18:48:30 +00:00Commented Aug 18, 2016 at 18:48
-
In other words what would be the bare minimum I would need to implement a model. I imagine I'd need a data access layer for sure. What else?Wes– Wes2016年08月18日 18:54:57 +00:00Commented Aug 18, 2016 at 18:54
-
That's all you'd really need for a basic application.Robert Harvey– Robert Harvey2016年08月18日 19:12:11 +00:00Commented Aug 18, 2016 at 19:12
-
1Ah, c'mon. Think for yourself! Don't let other people do your thinking for you. There's no value in a software developer that can't make their own decisions.Robert Harvey– Robert Harvey2016年08月18日 19:54:12 +00:00Commented Aug 18, 2016 at 19:54
1 Answer 1
Robert Harvey's answer "The Model is everything that is not a Controller or a View. That can include a Data Access Layer, a Service Layer, a Business Logic Layer, Aggregate Roots, and maybe even some DTO's and ViewModel objects. If you want to put all that in a "Model" folder, that's as good a strategy as any."