• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Missing Post & Command Design

 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm...since JavaRanch went down a few of my posts are missing. Oh well, the one that I'm most interested in I'll mention here again. I'm having trouble implementing the Command Design Pattern. Actually, I implemented it fine and it works pretty slick but I have these few questions. First of all, when using the Command Pattern is it your experience that you have a separate class for each event handler and another separate class for each widget that you create that needs to implement the command interface? Whew! The number of classes adds up quick! The other thing is that I am still having problems accessing data in my UI class. You see in my UI class I had all my event handlers as anonymous inner classes. It worked great. But when I switched the system over, it seems I either need to pass things like the JTable and the TableModel and all that as parameters OR I have to declare them as static. Is that true? That doesn't seem desirable to me.
Thanks.
With Respect,
Matt DeLacey
 
R Bischof
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I simply use designated Action classes so I only have one class per activity but I also have to pass all these parameters around. I don't really like it since my Action classes know about tables, comboboxes and all that stuff but at least it makes the separation a bit clearer compared to the previous architecture.
Rainer
 
Matt Cannata
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run into a similar complexity with passing my data around my commands. I've found that encapsulating user-entered information (origin, destination, selected flight, # seats) into a model object has reduced the complexity. The only inner classes I have left are the ones modifying this user input, since they need to change the model. Hopefully, I'll find a way around that next.
I believe declaring your objects final will allow you to use them in your inner classes. It's not ideal, but it's better than making them static.
Hope this helps,
Matt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic