Model view controller 此代码的MVC等价物是什么:

Model view controller 此代码的MVC等价物是什么:,model-view-controller,language-agnostic,Model View Controller,Language Agnostic,下面是简单的伪代码: void TextBox1Changed() { //If the text isn't a number, color it red if (!IsValidNumber(TextBox1.Text) TextBox1.Color = Pink; else TextBox1.Color = WindowColor; } MVC enterprisey的版本是什么?不尝试特定于语言,但想法是创建一个数字文本控件,该

下面是简单的伪代码:

void TextBox1Changed()
{
    //If the text isn't a number, color it red

    if (!IsValidNumber(TextBox1.Text)
        TextBox1.Color = Pink;
    else
        TextBox1.Color = WindowColor;
}

MVC enterprisey的版本是什么?

不尝试特定于语言,但想法是创建一个数字文本控件,该控件知道该值是否有效。很容易对M、V和C的确切角色产生疑虑。然而,对于所有实际用途,将视图和控制器结合起来用于桌面应用程序是有意义的。Swing采用了这种方法,因为控制器和视图具有非常紧密的耦合,将它们合并为一个是有意义的。请阅读c2中有关该主题的内容

class NumberTextBox extends TextBox {
    bool isValid() {
        return IsValidNumber(this.Value);
    }
}


ageTextBox = new NumberTextBox();
ageTextBox.addChangeHandler(function() {
    this.Color = this.isValid ? WindowColor : Pink;
});

你能告诉我们你在说什么mvc框架吗?如果是web开发,那么应该使用javascript来完成,因此对于所有服务器端web框架都是一样的。