Think about how to divide MVC into M and V

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

M and V

Be careful not to become a smart UI. →http://d.hatena.ne.jp/minekoa/20100116/1263657955

1. Do not use `` = 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

Think about how to divide MVC into M and V
How to think when you suddenly understand about generics
How to divide a two-dimensional array into four with ruby
About TestSize advocated by Google and how to realize TestSize by Java and Maven
How to translate enum into Japanese and generate linked radio buttons
How to think about class design (division) in a business system (1)
How to use StringBurrer and Arrays.toString.
How to use EventBus3 and ThreadMode
How to call classes and methods
How to connect Heroku and Sequel
How to convert LocalDate and Timestamp
Think about how to follow container operation best practices with Nginx containers
I was curious about how to use Optional orElse () and orElseGet () properly.
AtCoder is called TLE and talks about how to write beautiful code
How to use OrientJS and OrientDB together
[Core ML] How to convert YOLO v3 to Core ML
[Java] How to output and write files!
How to build SquashTM and how to support Japanese
How to find the tens and ones
[Easy] How to upgrade Ruby and bundler
How to use substring and substr methods
[Spring MVC] How to pass path variables
Note: [Docker] How to start and stop
How to write and explain Dockerfile, docker-compose
[Rails] How to translate devise into Japanese
How to use @Builder and @NoArgsConstructor together