challenge chain problem



  • I have a class that contains several other objects as fields:

    public class TabManager {
    

    private JTextField fieldForName = new JTextField();
    private Task task;
    //и т.д.
    }

    Next, I have other classes with this class that have a class object. TabManager transmitted as a parameter to the designer.

    For example:

    public class OKButtonBuilder extends MyButton implements ActionListener {

    private TabManager manager;

    public OKButtonBuilder(String s, TabManager manager) {
    super(s);
    this.manager = manager;
    }

    Next, in class. OkButtonBuilderI' this kind of treatment:

    manager.getFieldForName().setText("some text");

    Would it be better if I madeName in TabManager class?

    public void setName(String s) {
    fieldForName.setText(s);
    }

    And in class. OkButtonBuilder I'll call you:

    manager.setName("some text");

    Am I right to know that this will help to get rid of the chain of challenge?



  • Am I right to know that this will help to get rid of the chain of challenge?

    It depends on your task. If you work with Field Only for the text to be inserted would it be more appropriate to set a setName() method, if you change the other parameters of the facility, would it be sufficient to limit itself by method getFieldForName()




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2