Button logic to disable or not in mvc

Here is an excerpt from a book I'm reading about app design with MVC:

Ideally, the view is so simple and without logic without the need for testing. Users (and developers to users) can reasonably test just by looking at the pixels on the screen. Everything else behind a clean graphic display should ideally be removed from view and placed in the controller and model. This includes , for example, logic that determines whether a particular button is set to be turned on or grayed out at some point.

What does a bold statement mean to you? what would it look like?

thank you rod.

+3
source share
2

, , , , view.EnableContinueButton(), / .

/ , , EnableContinueButton(), - btnContinue.Enable().

, (/// ) - . , , -.

, ,

public void ProcessOrder()
{
   if (!controller.ValidateOrder(model.OrderNo))
       view.EnableContinueButton(false);
   else
       // Process the order
       ...
}

public void EnableContinueButton(bool enabled)
{
    btnContinueButton.Enabled = enabled;
}

, MVC ( ), , .

+1

, :

  • if
  • ( viewmodel) , , .

, , , - .

. , .

viewmodel ShowExamineeDetails. , .

ShowExamineeDetails = -?

.

, , "... ..."

+1

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


All Articles