On Wikipedia about MVVM it is written:

It is convenient to use MVVM instead of classic MVC and the like in cases where “data binding” is present in the platform on which the development is being conducted.

  1. Explain, please, what is data binding? There is very little information on the net. I can bring my guesses on the example of Delphi. There you can put on a DBGrid form, and the data from the database will fall into it. That is, they will be tied to him. But, of course, if everything is correct in the settings. Is this data binding?
  2. Then, as I understand it, there is no data binding in Java Swing. Is it possible to use MVVM there? In principle, you can probably just write the bind and backBind functions backBind , in which you need to transfer the necessary data back and forth?
  3. If possible, is it worth it? Or is MVC or MVP better? I understand that it is impossible to say so unequivocally, it probably depends on the situation. I have a desktop project with a small database (JDBC and MySql), but the GUI is quite voluminous and complex, with many features. The subject area for my application is a complex algorithmic problem ( the knapsack problem , for whom it is interesting). Please tell me that in my situation it is better to use - MVC, MVP or MVVM (I have no experience in any of this).

    2 answers 2

    The MVVM pattern is more focused on Microsoft’s .Net technologies, in particular under the XAML markup language.

    In WPF or Silverlight, data binding is important, it is difficult to imagine a serious application without bindings.

    There is an alternative to Java - the JavaFX platform.


    1. Binding involves the interaction of two objects: the source and receiver. The receiving object creates a binding to a specific property of the source object. In case of modification of the source object, the receiving object will also be modified (the behavior depends on the type of binding).

      There are 4 types of bindings.

      OneWay : the property of the receiving object changes after modifying the property of the source object.

      OneTime : the property of the receiving object is set by the property of the source object only once. Further, changes in the source do not affect the receiving object.

      TwoWay : both objects are applications and the source can change each other’s attached properties.

      OneWayToSource : the receiver object in which the binding is declared changes the source object.

      Default : the default (if the TextBox.Text property changes, it has the value TwoWay, otherwise OneWay).

    Example

     <StackPanel> <TextBox x:Name="textBox1" Height="30" /> <TextBox x:Name="textBox2" Height="30" Text="{Binding ElementName=textBox1, Path=Text, Mode=TwoWay}" /> </StackPanel> 
    1. It’s not easy to write a mechanism with such functionality.
    2. Look at the JavaFX platform if you choose MVVM and Java.
      If .Net then WPF or universal applications under windows 10.
      Making a Web application recommend Spring MVC.

      On account of what kind of pattern I can’t really say anything. If you need a beautiful, high-loaded interface, I would use JavaFX, and there is a classic MVC pattern. And at the expense of data binding, I met such a feature in NetBeans (as in the good old Delphi - “without a single line of code”), there is a linking using my own libraries (they are then attached to the project).

      • 2
        In fact, this is not the answer to the question. - pavlofff