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

GUI Design - Max's Book

 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
This is a question on Max's choice of classes for GUI design.
He starts the application with:
ApplicationRunner class which calls the
MainWindow class - After going through the the connection dialog box for local v/s network connection, he instantiates the
DVDWindow class which extends JFrame.
Focus on the two classes MainWindow and DVDWindow: MainWindow is the container class which contains DVDWindow as an inner class right?
MainWindow has a private instance variable declared as follows:
private JTextField searchField = new JTextField(20);
This is used for user-entry for typing in the search string.
The search button however, is declared and instantiated within the DVDWindow class in its overloaded constructor with a string parameter. Within this constructor, he goes on to assemble the "Search Panel." which is added to bottom panel.
It seems a bit odd to me to declare the searchField at the MainWindow level and its corresponding button in the Child class DVDWindow. Since they both go together. I would have declared the searchField within the DVDWindow class along with the search button.
I am not sure if this is an oversight or a deliberate design on Max's part?
The reason I am asking this question is:
1. I am staying as close to his class designs are I can.
2. I am trying to figure out where to declare the JComboBoxes for name and location fields?
Any ideas anybody?
Thanks.
Bharat
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bharat,
MainWindow is the container class which contains DVDWindow as an inner class right?

Correct.
It seems a bit odd to me to declare the searchField at the MainWindow level and its corresponding button in the Child class DVDWindow. Since they both go together. I would have declared the searchField within the DVDWindow class along with the search button.

You need to think about variable scope - what would be the implications if you did move the declaration of the searchField? Would all classes that need to access that variable still be able to do so?
I strongly suggest you stop and play around with this for a little while. Make sure you understand how the scope is working.
1. I am staying as close to his class designs are I can.

Only do that if you feel it is right for you. Personally I didn't have any inner classes. This made some parts of my code easier to read than Max's and some parts harder. Have you thought about alternatives to Max's code?
Note: I am not saying that Max's code is wrong, or even that I think an alternative is better. All I am suggesting is that you need to understand what you are doing and you need to be able to think of what alternatives there are in case some project you do in the future cannot be done in this particular fashion.
2. I am trying to figure out where to declare the JComboBoxes for name and location fields?
Any ideas anybody?

Lots of ideas, but you need to get comfortable with why Max has declared his variable in the location he did first. Then you can think about what needs to access your JComboBoxes, and you can then determine where to put them.
Regards, Andrew
[ September 02, 2003: Message edited by: Andrew Monkhouse ]
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew is completely right here. A lot of the decisions there could have gone in other directions: and if they had, we'd be talking about why we did that instead .
I think it's a good idea to follow the general principles that we did, and to ask yourself some of the main questions. However, there's no reason why you should come up with the same answers. After all, we're not necessarily better programmers then you are. The only real difference between reader and writer, really, is that we spent a year really researching this material, arguing about best approaches, and digging into design decisions. OTOH, we wrote down everything we found, so that puts us on pretty even footing
By and large, I suggest that take over the project and make it Bharat's DVDs.
All best,
M
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew and Max,
I guess another session in the library coming up I guess. I have most of my GUI interface up and running. Andrew's point is well taken. I need to spend a bit more time trying to really understand the finer details of scoping. Though, knowing Max, he usually has good reasons for doing things certain ways. I was just curious. This is the first time really since my Struts Kick Start book that an author has backed up his words so well, thank you Max.
Hey Andrew, you should think about writing a book yourself! I will buy it.
Regards to you both.
Bharat
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd buy it too
M
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Max,
Your new book, "Regular Expressions with J2SE" is coming out around October time-frame, right? I was curious as to why you decided to write an entire book on this topic? Is it that important in your experience? I must admit I have never used it in real-life. We were, and still are stuck with jdk1.3.1 in our work (WebLogic 7.0).
I would appreciate some comments on this topic.
Regards.
Bharat
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bharat & Max,
[Bharat] Hey Andrew, you should think about writing a book yourself! I will buy it.
[Max] I'd buy it too

Thanks for the kind words. I have been thinking about writing a book, but some of the topics I have thought about might have limited interest, so nothing in the pipeline yet.
[Bharat] (to Max) I was curious as to why you decided to write an entire book on [Regular Expressions]? Is it that important in your experience?

(Sorry for jumping in Max)
In my experience once you start using regular expressions regularly you start wondering how you got by without them. Most programs need to do some validation of user input, and regular expressions can make the whole validation process so much simpler and more efficient. The trouble is always the learning curve for regex. So a good book describing how to use regular expressions is always desirable.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic