Recently, in MVC, the boundary between M (model), V (view) and C (controller) has been changed. I think it's ambiguous in me, so I will add to this article how it should be separated from time to time.
Author environment Java
, `SpringBoot```,
`Thymeleef```
Be careful not to become a smart UI. →http://d.hatena.ne.jp/minekoa/20100116/1263657955
= introduced
for views.For example, there is an enum called State
<div th:if="${model.state == State.SUCCESS}">Succeeded!<div/>
If so,
<div th:if="${model.isSuccess()}">Succeeded!<div/>
I think it is better to say.
Otherwise
model.state and state.When SUCCESS matches, it is said to be successful
I suspect that business logic is seeping into the view.
View doesn't have to know that.
## 2. Judgment and processing are in the model, and the method of expression is in the view (WIP)
# M and C
## 1. Validation is a model (WIP)
Validation is implemented in the model.
In the controller, only the transition destination is changed when a validation error occurs.
Recommended Posts