Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

some final separated questions

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 221
Scala Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Yu Sun
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Carlos. That is so clear. And I like the idea of how you handle exceptions.

Thanks again.

Yu
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Yu Sun
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ralf. That works!

Yu
 
I don't even know how to spell CIA. But this tiny ad does:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic