This article has left me a little confused.
In explaining a method on how to design MVC into Java Swing apps the author defines the controller class as Singleton and relays a series of calls to the Controller for each operation.
In a view object:
...
Controller.getInstance().setOwner(this);
Controller.getInstance().setNameTextField(this.nameTextField);
Controller.getInstance().setEmailTextField(this.emailTextField);
Controller.getInstance().processForm();
...
And inside the controller class:
public void processForm() {
result1 = doSomethingWithName(this.nameTextField.getText());
result2 = doSomethingWithEmail(this.emailTextField.getText());
this.owner.setResult(result1, result2);
}
I don't understand why this has been made so complex! Wouldn't it be simpler, less error prone and more modular to simply:
Controller.processForm(this, this.nameTextField.getText(), this.emailTextField.getText());
and
public static void processForm(OwnerClass owner, String name, String email) {
result1 = doSomethingWithName(name);
result2 = doSomethingWithEmail(email);
this.owner.setResult(result1, result2);
}
Is anyone familiar with this design pattern? Is there reason to this method?