• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Developer Exam Style question

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've been working on my developer exam, and while I think I've met all of the program requirements, I am not experienced in swing, so I had a couple of style questions to ask the group.
1)Are Anonymous event handler classes ok?
2)Is it ok to have my custom TableModel do its own data loading?
3)Is it ok to use named field variables in my design, or should they be control arrays?
Question 1:
==============
I used Anonymous handler classes for the Booking Client instead of creating named classes, since that seemed like a more compact way of addressing the problem.
ie.
JButton searchBtn=new JButton("Search");
searchBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
//do something useful here
}
});
instead of
JButton searchBtn=new JButton("Search");
searchBtn.addActionListener(new SearchActionListener());
Question 2:
=============
When I created my JTable's TableModel, I gave it the capability load itself (the connection object is passed in via the constructor). It works fine, and simplifies the client code, but I'm wondering if this is a bad approach. (ie. use a helper class called from the Frame object instead)
Question 3:
=============
I'm using named JComboBox and JButton fields in my user interface, instead of arrays of buttons and fields. I dont know if this violates the "expectation of future functionality enhancements" clause, but it seemed like the most sensible way of solving the problem.
Thanks in advance for any help on this.
-Frank
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HiFrank,

Originally posted by Frank Roberts:
Hi,
I've been working on my developer exam, and while I think I've met all of the program requirements, I am not experienced in swing, so I had a couple of style questions to ask the group.



1)Are Anonymous event handler classes ok?


They are, but I always suggest that people, if they are starting out, use non-Anonymous ones, because the code is easier to read. Since you're done, this may not apply to you.


2)Is it ok to have my custom TableModel do its own data loading?


I did.


3)Is it ok to use named field variables in my design, or should they be control arrays?


See below


Question 1:
==============
I used Anonymous handler classes for the Booking Client instead of creating named classes, since that seemed like a more compact way of addressing the problem.
ie.
JButton searchBtn=new JButton("Search");
searchBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
//do something useful here
}
});
instead of
JButton searchBtn=new JButton("Search");
searchBtn.addActionListener(new SearchActionListener());


This is less maintainable code, though you could argue that event handlers are meant to be disposable, and that this design encourage the use of a separate event handler for user input, thus �architecting in�future customized pert event(and thus increasing the odds of catering to the user: after all, future enhancements are on their way ). Either way, I'd justify the decision in your readme.


Question 2:
=============
When I created my JTable's TableModel, I gave it the capability load itself (the connection object is passed in via the constructor). It works fine, and simplifies the client code, but I'm wondering if this is a bad approach. (ie. use a helper class called from the Frame object instead)


This is little different then what I had expected. Some people have the connection helper return an Object(say, a Vector), then they feed that to the TableModel.


Question 3:
=============
I'm using named JComboBox and JButton fields in my user interface, instead of arrays of buttons and fields. I dont know if this violates the "expectation of future functionality enhancements" clause, but it seemed like the most sensible way of solving the problem.


Seems fine to me.
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
reply
    Bookmark Topic Watch Topic
  • New Topic