Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

actions handling

 
Andrew Douglas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people!
I would like to consult with you.
On client side I have FileMenu which is responsible for local and remote connection. For this menu I use FileListener class.
For book and search button I apply Command pattern.
Question: Is it OK to have such actions scheme for application or it is better to have general Controller for handling file menu actions, button actions, table selected action and so on.
Thank You in advance,
Andrew
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the simplicity and ease of reading, a controller is better, not to say that your way would lose any points.
And this assignment is on the simplicity side.
Mark
 
Andrew Douglas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark!
In my GUI I tried different ways to handle actions:
Inner classes, Public classes, Command pattern with Mediator, Controller. In any case everything works fine. But I can't come to a decision which way is better. Not only for this assignment. For example if we have File menu, Edit menu, View menu and so on. I think for each menu it is better to have separate Handler or ...
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at some of my code here, and tell me if this will help.
This code is in the GUI class, they are separate methods to hook the Controller into the GUI class, and get ActionListeners etc.

and



OK Now here is the code in the controller that will attach a controller method to an Object on the GUI as the ActionListener.

Now the above code in the GUI and controller almost completely match, I just left a couple out of the GUI code, because it more than enough here to demonstrate a simple way to keep the GUI and Controller code seperate, and having the GUI code know nothing about anything except itself.
Mark
 
Andrew Douglas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mark.
I got it.
Andrew.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic