Re: [NetBeans]changing menuitems



thufir wrote:
On Sun, 27 Jul 2008 23:46:14 +0100, RedGrittyBrick wrote:

// APPLICATION
Gen() {
GenModel model = new GenModel();
GenControl controller = new GenControl(model); JFrame view =
new GenListView(model, controller);
view.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
view.pack();
view.setLocationRelativeTo(null);
view.setVisible(true);
}


How would you achieve the same effect without passing parameters to constructors? Is that an unavoidable step?

Oh yes, another way is "Dependency Injection" or "Inversion of Control".

I'm not a fan of that since it seems heavyweight and looks rather mysterious and like magic to the casual reader.

E.g. http://www.picocontainer.org/ though I think Spring etc do this too. Picocontainer seems pleasantly lightweight and simple. Relatively.

--
RGB
.



Relevant Pages

  • Re: [NetBeans]changing menuitems
    ... GenModel model = new GenModel; ... GenControl controller = new GenControl; ... JFrame view = ...
    (comp.lang.java.help)
  • Re: [NetBeans]changing menuitems
    ... GenModel model = new GenModel; ... GenControl controller = new GenControl; ... How would you achieve the same effect without passing parameters to constructors? ... If I were writing this today I'd have the constructor or setController take an ActionListener argument rather than a GenController Argument. ...
    (comp.lang.java.help)