This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird 1.3.2 : GUI Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBird 1.3.2 : GUI Doubt" Watch "URLyBird 1.3.2 : GUI Doubt" New topic
Author

URLyBird 1.3.2 : GUI Doubt

Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
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)
Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
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.


SCJP 5.0
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
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

Joined: Sep 18, 2007
Posts: 57
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

Joined: Oct 01, 2007
Posts: 759
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

Joined: Sep 18, 2007
Posts: 57
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

Joined: Oct 01, 2007
Posts: 759
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)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: URLyBird 1.3.2 : GUI Doubt