This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Trying to get started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: Trying to get started" Watch "NX: Trying to get started" New topic
Author

NX: Trying to get started

Tatiana Hyde
Greenhorn

Joined: Dec 06, 2003
Posts: 12
Hi,
I have been going around in circles with my assignment and struggling to get started so would be extremely grateful if someone could please help me by confirming if my design plan is correct and whether I am missing anything.
Here goes:
I have the BS Contractor assignment with the cookie variable in the update, delete and unlock method signatures.
I was provided with the DBAccess interface and have to implement these methods in the Data.java class. Because of the limitations in DBAccess (the exceptions thrown), I have created another interface (DataInterface) with all the same methods as DBAccess but the methods also throws an extra �IOExceptions�. I then created a class (DataSource) that implements this new DataInterface, with a member variable (private DBAccess data = new Data() . The Data class will also have other methods added to it.
For the remote side, I have an interface (DatabaseRemote) that extends Remote and the new DataInterface. I also have a class (DatabaseImpl) that implements DatabaseRemote and has a member variable (private DataSource ds = new DataSource()
On the client side, I will have a connectionFactory to get a local connection:
<DataInterface data = new DataSource();>
and to get a remote connection: <return (DataInterface)Naming.lookup("rmi://" + ip + "/Contractor");>
Please can someone let me know if this plan is OK.
Have I declared my member variables in DataSource and DatabaseImpl correctly and have I created the connections in the connectionFactory correctly??
Many thanks in advance.
T.H.
[ February 10, 2004: Message edited by: Tatiana Hyde ]
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
Welcome Tatiana!

Because of the limitations in DBAccess (the exceptions thrown), I have created another interface (DataInterface) with all the same methods as DBAccess but the methods also throws an extra �IOExceptions�. I then created a class (DataSource) that implements this new DataInterface, with a member variable (private DBAccess data = new Data() . The Data class will also have other methods added to it.

Have you thought about how you are going to get the IOExceptions out of Data to be thrown by the methods in DataSource?


Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Tatiana,
Welcome to the forum.
Originally posted by Tatiana Hyde:
Please can someone let me know if this plan is OK.
Have I declared my member variables in DataSource and DatabaseImpl correctly and have I created the connections in the connectionFactory correctly??

Yes. Yes and yes.
(Sorry for the short answers, but there's nothing that you've posted with which I disagree so I don't know what else to say.)
Hope this helps,
George
P.S. I finally thought of something to say. DataSource and DatabaseImpl are implementations of the object adapter design pattern and so you might want to mention that in your class comments as well as your design choices document. And of course the fact that ConnectionFactory is a implementation of the factory design pattern. Also, "going around in circles with my assignment and struggling to get started" is a proven development methodology for the SCJD exam. Enjoy the journey.
[ February 10, 2004: Message edited by: George Marinkovich ]

Regards, George
SCJP, SCJD, SCWCD, SCBCD
Tatiana Hyde
Greenhorn

Joined: Dec 06, 2003
Posts: 12
George, thank you so much for your yes answers and other comments � they are very much appreciated!
Jacques, thank you also for your reply. Please excuse my ignorance� but I am confused by your question. If you have some time and don�t mind, please can you try explain in a different way. � Thank you!
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
I Tatiana.

Jacques, thank you also for your reply. Please excuse my ignorance� but I am confused by your question. If you have some time and don�t mind, please can you try explain in a different way. � Thank you!

I'll try quick.
Data implements DBAccess. For example, the DBAccess' readRecord method doesn't throw a IOException, but the implementation of the method in Data might throw IOException. (From the RandomAccessFile, or Channel or whatever).
So, my question is, how are you going to get the IOException out of the readRecord method in Data to be handled in DataSource, since it can't be thrown?
Hope I'm making more sense this time.
If you still don't get what I'm trying to ask, I'll try again tomorrow.
J
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Tatiana,
Jacques might be asking the following question. Let's say you have the following method in your DBAccess interface.

I think it is further assumed that:

The two commonly used techniques are to wrap the IOException in the already declared checked exception (RecordNotFoundException), or wrap the IOException in an unchecked RuntimeException (or subclass thereof).
For example,

On the other hand, maybe I've missed Jacques' question entirely.
Hope this helps,
George
Tatiana Hyde
Greenhorn

Joined: Dec 06, 2003
Posts: 12
Hi Jacques & George,
OK, now I get it. Sorry, I really should have understood it in the beginning but was not thinking clearly. Thanks both of you for explaining further. This has been a massive help!
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
George, yes, that was what I was trying to get at.
I'm gleaning some 'explaining' tips from you.
 
wood burning stoves
 
subject: NX: Trying to get started
 
Similar Threads
NX: DBAccess and RemoteException
Can Data_Stub be present in all clients?
Object adapter design pattern
Lock/Unlock on Client side or Server Side
[UrlyBird 1.2.1] A design issue with the Remote exception