When to split an MVC view into two?

I discussed the best practices in MVC the other day with a colleague, and he asked me how best to share opinions. He supported the MVC solution, which had a common input form with a controller with two actions, an action action and a post action. Both actions returned the same point of view that was filled with built-in logic, and conditional expressions that checked whether it was mail or the recipient.

What is the best solution for this situation? Should a view be divided into two separate views? I think it depends on how much logic is there, but when is it too much? Is there a way to quantify when you can motivate refactoring into two kinds?

+6
source share
1 answer

I would definitely split something like this into two separate views, and then use partial representations for parts that are common between them.

Composition, without inheritance and without conditional logic, is almost always a cleaner, more understandable and more user-friendly way when it comes to planning Views .

+3
source

Source: https://habr.com/ru/post/897994/


All Articles