Yo.
Suppose i have a View class in an MVC application and i have the private JTextField. Now i also have the Controller class that is responsible for user inputs. Relationship between classes is Controller depends on View ---> Controller has a View.
Now, the question is: should the View class expose the TextField or just provide methods to manipulate it.
Approach 1 :
Approach 2 :
Is it a question of preferance of is one more encouraged than the other one.
THanks.
Suppose i have a View class in an MVC application and i have the private JTextField. Now i also have the Controller class that is responsible for user inputs. Relationship between classes is Controller depends on View ---> Controller has a View.
Spoiler
Now, the question is: should the View class expose the TextField or just provide methods to manipulate it.
Approach 1 :
class View{ private TextField field; public TextField getField(){return field;}
Approach 2 :
class View{ private TextField field; public String geText(){return field.getText();} public void clearText(){...} etc..
Is it a question of preferance of is one more encouraged than the other one.
THanks.