aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes on UI design :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "on UI design :(" Watch "on UI design :(" New topic
Author

on UI design :(

kris armada
Greenhorn

Joined: Jul 26, 2002
Posts: 3
Hello everybody,
I have read so many topics posted on this site about the MVC implementation. But I am still not able to go forward with the UI design.
Is it a good design to have only one model for the whole database and use multiple views for initial search, then results (with a 'book' button) and then a confirmation view ?
Or is it a better idea to have as many models as there are views ?
I have read the MVC topic at http://ootips.org/mvc-pattern.html as suggested in this forum, but I do not have much experience designing user interface.
If we have multiple models, and the first view has a Search button, who would be the best listener ? The main class or the corresponding controller ? If it is the controller and as a given controller should only be coupled with one model, how can we get the results model to be created ? And in fact is there a way we can make the main class listen to these events ?
And in case there is only one model, and I assume there is no argument over using multiple views, and all the views are listening to the same model's events, how can we make sure only one of the views is shown at any given point of time ?
Last question but on the network side though, does the user need to be given a Menu option to make the application run in network/local mode ? I was using a properties file (implementing Singleton) which will tell the app if it is run locally or in network mode at the start up. And I am trying to use FactoryMethod to get a reference to respective Data Service object which could be local or remote. Essentially the user does not know anything about the database mode. In a real world situation, I do not see why any user would want to use both local and remote databases switching between them. Is my assumption wrong ?

I really appreciate the answers and your time.
Thanks,
..Kris.
Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
Wow. A lot of good questions. Well, I'm no expert, but I'll pass along my .02 dollars and try to contribute back to the forum after taking so much.


Is it a good design to have only one model for the whole database and use multiple views for initial search, then results (with a 'book' button) and then a confirmation view ?

My understanding of the MVC pattern is one model and tehn use multiple views and controllers as needed. For instance, my implementation had a single model, one controller and one view. However, I designed the model so that I could have easily passed the data to another object that could format the data for XML use, presentation on a browser client, etc.


The main class or the corresponding controller ? If it is the controller and as a given controller should only be coupled with one model, how can we get the results model to be created ? And in fact is there a way we can make the main class listen to these events ?


My View was very dumb. It was actually close to being a Builder pattern. Based on user activity, diferent methods were called to construct the screen. The key for me was that while all the building methods were in the View, they were actually invoked by the Controller. Knowing this, it's pretty easy to figure out where to put the listeners.


And in case there is only one model, and I assume there is no argument over using multiple views, and all the views are listening to the same model's events, how can we make sure only one of the views is shown at any given point of time ?


I'd stay away from multiple views. Use the KISS method and Keep It Simple, Simon. I have seen where complicated GUI results in lower scores.


Last question but on the network side though, does the user need to be given a Menu option to make the application run in network/local mode ?


That's part of the exercise. What do good GUI implementation practices say? You could also decide to make the user make that choice at the time they enter the command line to invoke the application and you decide based on what parameters they enter.


And I am trying to use FactoryMethod to get a reference to respective Data Service object which could be local or remote. Essentially the user does not know anything about the database mode.


You're definitely doing the right thing here, IMHO.


In a real world situation, I do not see why any user would want to use both local and remote databases switching between them. Is my assumption wrong ?

Maybe, maybe not. The reality is they leave it up to you to decide. I decided not to allow them to switch after choosing the mode. It just didn't make much sense to me, because I would have to write so much code to destroy all the old objects and create new ones to use. Too much room for error.
Believe it or not, in some cases, there aren't any "right" decisions - you just have to figure out the one that makes the most sense to you based on your design choices.
One thing I would definitely do is make sure my design was really tight and I really understand what I was doing, because when you get way down the road and decide you need to make some changes, you can get really hosed. This happened to me - I made some very bad choices early on and I had to refactor a number of things. That made unit testing really hard.


Regards,
Jim
SCJP, SCJD, SCWCD, SCEA Part I
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I've always been under the assumption that you can have as many views, controllers, or models as you want, as long as that is really what it calls for.
Meaning if you are doing it just because you think you have to, then it probably isn't right. But if you know through OOP that there is no other way then multiple views, models, and controllers is fine.
Now in this assignment, I had multiple Models, 1. DataFacade, 2. and my TableModel. I had only 1 controller and only 1 GUI class.
Hope that helps clear up the first part of your questions
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Last question but on the network side though, does the user need to be given a Menu option to make the application run in network/local mode ? I was using a properties file (implementing Singleton) which will tell the app if it is run locally or in network mode at the start up. And I am trying to use FactoryMethod to get a reference to respective Data Service object which could be local or remote. Essentially the user does not know anything about the database mode. In a real world situation, I do not see why any user would want to use both local and remote databases switching between them. Is my assumption wrong ?

For the second part. You start by saying on the server side. But local mode does not have a server. I think that might be where you are getting confused a bit.
"In the real world"
If the db.db and the client GUI is running on the same machine then it should only be in local mode. meaning the client is using the DataAccess class to Data class directly, no RMI no sockets.
If the Server software is running on one machine "the Server" and all the client are running on other machines on the network, then you use remote access, using RMI or Sockets.
Does this help clear things up?
Mark
John Sinues
Ranch Hand

Joined: Feb 21, 2000
Posts: 52
I, too, got a little overwhelmed when I (re)started my FBN project. I recently started browsing this forum for ideas and various design considerations. After over a year of having the project in hand sitting on a bookshelf gathering dust, I decided to continue work on it.
Originally, I was considering designing the GUI using a GUI builder. Unfortunately, this tightly couples the interface. The MVC approach seemed to be the better method. I will, however, use a GUI builder to prototype various screen designs.
There have been a number of postings on using the MVC pattern for the GUI. I read the MVC articles on OOTips, but they did not do a lot for me. I found a better article - Sun's Fundamentals of Swing, Part II discusses using adapters to establish the model view relationship. I was planning on using this approach for my GUI design. The various examples and diagrams are clear and easy to understand (plus they're in Java ). This article also explains the benefits which you could quote in your design considerations document.
Good luck,
John
[ August 23, 2002: Message edited by: John Sinues ]
Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
I've always been under the assumption that you can have as many views, controllers, or models as you want, as long as that is really what it calls for.

I suppose this is possible, although I can't think of a reason to have multiple models for the same views and controllers. I mean, doesn't the data only have one state?
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
Originally posted by Jim Bedenbaugh:

I suppose this is possible, although I can't think of a reason to have multiple models for the same views and controllers. I mean, doesn't the data only have one state?

You could have more than one database for an app... and I suppose you could still have one model then, but I have seen multiple models and still a good solution.


scwcd, scjd, scjp<br /><a href="http://natejohnson.us" target="_blank" rel="nofollow">http://natejohnson.us</a><br /><a href="http://rice.kuali.org" target="_blank" rel="nofollow">http://rice.kuali.org</a>
Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171

You could have more than one database for an app... and I suppose you could still have one model then, but I have seen multiple models and still a good solution.

My experience is usually you have a relational database engine that has joined the data for you already into a single results set, so we're back to a single model by the time it gets up to the MVC.

, but I have seen multiple models and still a good solution.

Me too. We called them FD's in the Data Division of COBOL programs that I wrote for 18 years on mainframes using VSAM files.
I kinda thought we were getting away from all that. . .
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
Originally posted by Jim Bedenbaugh:

Me too. We called them FD's in the Data Division of COBOL programs that I wrote for 18 years on mainframes using VSAM files.
I kinda thought we were getting away from all that. . .

We have been trying to get away from that for years now and I think the estimated data is now about 2005... the mainframe may never go away I think we just bought cobol for unix so we can just move the code over instead of redesigning the system... the real world is just full of excitement
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I never had to write a single line of COBOL. Went from Fortran (thank the Lord that's over!) and Assembly to RPG to C to C++ to Java. Wrote a few little do nothing programs in Basic in the early '80s when some locals needed some help with their 8080's. Most of my hacks have been engineering/scientific stuff though.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
jQuery in Action, 2nd edition
 
subject: on UI design :(