The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Missing Post & Command Design Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Missing Post & Command Design" Watch "Missing Post & Command Design" New topic
Author

Missing Post & Command Design

Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
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

Joined: Feb 13, 2001
Posts: 48

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


Rainer<br />SCJP, SCJD, SCWCD
Matt Cannata
Greenhorn

Joined: Mar 23, 2001
Posts: 23
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
 
IntelliJ Java IDE
 
subject: Missing Post & Command Design
 
Threads others viewed
Design Dilemma
Cannot find symbol...
What is the advantage of adding custom listener to panel
Program design--to inner-class or not to inner-class?
Issues about Command pattern in UI
IntelliJ Java IDE