my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes some final separated questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "some final separated questions" Watch "some final separated questions" New topic
Author

some final separated questions

Yu Sun
Greenhorn

Joined: Nov 06, 2006
Posts: 29
Hi guys,

I am almost done with my project and doing the final check. I would like to ask some questions to make sure it is correct:

1. There is a Magic Cookie Value in the beginning of the file, I use it to check if the file selected is a valid database file for this application. I think this is a fixed value for my application, right? For example, I read the file Sun provided, and this value is 513, then I just use 513 to decide if a certain file is valid or not.

2. There are two Exceptions required to implement - RecordNotFoundException, and DuplicateKeyException. I only put two constructors in this two classes as mentioned in the instruction - one without argument, the other with a String argument. Is this OK? Is there anything else we need to do in the Exception class?

3. When handling the Exceptions in the project, I just throw the Exceptions from one class to another, and catch them in the end out side. And, in the catch block, I just simply printStackTrace(), is this OK?

4. I have a configuration window for Network-mode Client to setup the host address and port before the main GUI. I also have a different configuration window for Standalone application to setup the location of the database file before starting the main GUI. Is this OK? Do we need to merge these two windows? Because in the instruction, it says
Non-networked Model
... Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all.
...
Network Approaches
...the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely.


5. When I test my program now, I need to run "start rmiregistry" first. Do we need to somehow make this also in program?

Thanks a lot.

Yu
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Hi Yu,

Yu Sun wrote:1. There is a Magic Cookie Value in the beginning of the file, I use it to check if the file selected is a valid database file for this application.

Please check the SCJD Forum FAQ.
Yu Sun wrote:
2. There are two Exceptions required to implement - RecordNotFoundException, and DuplicateKeyException.

Yes.
Yu Sun wrote:
3. When handling the Exceptions in the project, I just throw the Exceptions from one class to another, and catch them in the end out side.

Personally, I did create a DataAccessException class for the Data layer and a BusinessServiceException for my business service and a ControllerException for my GUI.
I do this in order to isolate the implementation of a layer and avoid causing ripple effects when changing implementation (IOException in a file to SQLException in a RDBMS).

In the catch block you might want to do some notification to the user about the problem,
since the intention of throwing an exception is to signal that something went wrong and a stacktrace
might be cryptic to the end user.

Yu Sun wrote:
4. I have a configuration window for Network-mode Client to setup the host address and port before the main GUI.

Yes, it's OK
No, you don't need to merge the 2 windows as long as it works and you don't violate any must requirements.
The only GUI must requirement is to use a JTable.
Yu Sun wrote:
5. When I test my program now, I need to run "start rmiregistry" first. Do we need to somehow make this also in program?

Yes, it must be started programmatically.
I am sure in Google or if you search the SCJD forum or in a Java RMI tutorial should show how to start the registry from a program.


Hope this helps,


Carlos.


SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Yu Sun
Greenhorn

Joined: Nov 06, 2006
Posts: 29
Thank you, Carlos. That is so clear. And I like the idea of how you handle exceptions.

Thanks again.

Yu
Ralf Titgemeyer
Greenhorn

Joined: May 18, 2010
Posts: 9
Hi Yu,

here ist the code for starting the RMI registry in your code...in my case newPort is a string from a dialog, but generally it has to be the port on which you want to start the registry...



Kind regards,
Ralf


SCJP 6.0
Yu Sun
Greenhorn

Joined: Nov 06, 2006
Posts: 29
Thanks Ralf. That works!

Yu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: some final separated questions