• 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:

URLyBird 1.3.2 : GUI Doubt

 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all the SCJD candidates and the SCJD certificate holder. Here's my progress of my project assignment:

For the DB, I already implemented all the interface provided except for find method which make me a little bit confused about implementing it.

For the networking, I already implemented a server which call the interface in the DB as well as the client which call the interface too. I already create a custom protocol (I chose to use socket).

For direct connection, I already implemented the code which access the database file directly.

The final section is no doubt is the GUI, but I have a little doubt with it.

The interface provided by the DBMain.java (which is implemented by the server and the client in the networking code) doesn't provide methods that can be used directly to fulfill user's criteria. For instance, the interface provide only find method which the return type is int[], but the searching mechanism wants me to present the search method in the JTable.

What should I do ? Do I have to create custom method (and of course adding the custom networking protocol) that didn't defined in the DBMain interface such as the method below ?



Or maybe you have another suggestions?

Thanks for your help.

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A lot of people including myself took a "3-tier" approach. Instead of advertising the DBMain interface directly, wrap it with another business layer class that implements an interface that is defined by your client requirements. This class can contain the logic necessary to "adapt" the requests to the DBMain specs. Write your protocol around this interface and have your client instantiate it for your connector. Now your client has direct access to the methods it needs and nothing else.
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a very good solution. Is it ok to never call method that defined in DBMain interface in GUI code ?

thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes... update and read are the only methods my adapter class will ever end up calling (besides lock/unlock of course). But you still have to provide a full working implementation of the DBMain interface, even if your code never ends up calling it.
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I'll implement your solution.

May I know which project you are working on? Just curious.

It is already a week + 2 days since I receive my assignment. How about you?

Thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
B&S. You sound like me... I finished 99% of the project in about 2 weeks working 6-7 hours a day. I've spent about another month on details and tweaking so far. The biggest hang ups for me have been concurrency, logging, and exception handling.

I'm freaked out from reading threads where people got failed because of seemingly minuscule and debatable threading issues, so I've been extensively testing the concurrency of my server. I'm convinced my synchronization for the database file access is solid, but trying to play out all of the possible threading issues for the logical record lock manager has been difficult. Also wrapping my head around class instantiation: where to assume there may be multiple threads running through a single class instance and where to force single class instances (ie singletons), etc.

I wasn't going to implement logging at all because it's not required, but then I decided to go with an extremely minimal approach and log fatal/unexpected errors.

I also think I've over-generalized my exceptions and they need to be slightly more robust... namely I've decided to change some of my checked exceptions to runtime exceptions.
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My instruction didn't said that I must implements GUI that can create a record. It only said that the GUI must used Swing, JTable, implement search with a specific criteria, and book and update a record.

Should I implements the create-new-record code in GUI? Or I only need to implement the interface in DBMain but don't be called in GUI code?

By the way, for the locking and logging, I used similar technique in Andrew's book

thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
reply
    Bookmark Topic Watch Topic
  • New Topic