File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes GuiController 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 "GuiController design " Watch "GuiController design " New topic

GuiController design

Maksym Odintsov

Joined: Jan 22, 2009
Posts: 11
Hi guys. I'm using GuiController class to obtain data class reference and to perform operations needed for GUI like searching records or booking rooms. I can't make my DataRemote class to be DB(data class interface) , because of exceptions that are thrown in the DB interface.
So in the GuiControler class I have one reference to the Data class and other reference to the DataRemote. So in order to avoid many if statements I decided to make Connection class

How do you think about this approach ? Is it ok for the SCJD or should I rethink my design.
Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
You can also use the Adapter pattern to adapt the remote interface to DB, or the other way round.

SCJP 1.4 100%
SCJD 99.5%
Maksym Odintsov

Joined: Jan 22, 2009
Posts: 11
I'm not shure about Adapter pattern. Can you explain me in details how you would adapt the remote interface to DB ?
Ulises Pulido
Ranch Hand

Joined: Jul 24, 2008
Posts: 81
Well I believe what Alecsandru believed (let me know if I am wrong) is that you may be able to use the Strategy Pattern (Having the interface DB implemented on the directConnection and remoteConnection) and the Adapter Pattern together (Having an instance of directConnection inside remoteConnection and calling the methods from directConnection inside remoteConnection)

SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCJD, SCEA in progress
I agree. Here's the link:
subject: GuiController design
It's not a secret anymore!