Forums Register Login

some final separated questions

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
Thank you, Carlos. That is so clear. And I like the idea of how you handle exceptions.

Thanks again.

Yu
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Thanks Ralf. That works!

Yu
straws are for suckers. tiny ads are for attractive people.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1161 times.
Similar Threads
Some questions about b&s
gui
NX: Non-Networked mode
nx:All of URLy Bird1.1.3 about record lock
NX: extends DB and fire listener
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:04:35.