Hi pals, Got 3 simple questions: 1. Data.java: my assigment requires: "my data access class MUST be called Data.java". I am using the data catching approach, i.e., keep a list of the records in memory. I found it will be very messy if I put my file writing and reading methods inside the Data.java, so I created another class only for reading and writing data, which is used by the Data.java. Is this allowed by the exam? 2. Config file: my assigment requires: "such configuration information MUST be stored in a file called xxxx.yy". But I feel that no need to use config file at all. Is this allowed? 3. JRMP: I am following the RMI Tutorial from SUN to do my RMI part. Is that considered as using RMI over JRMP? Thanks a lot.
hi Jin: 1-You said you are using data caching approch. I havan't decided which approch I will use yet, however as initial thought, caching the data will be faster, but you never know how larg the data is, or how larg it can grow to. One day the program will crash starving for memory. 2-The config file is important to read meta data at runtime. For example: The magic cookie value. You can hard code it in your classes, but how about they decide to use different magic number. 3-I don't know much about RMI yet, but I heard many people using that tutorial.
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
2. Are you talking about the SunCertify.properties file?....We capture & store the IP address, port and db file location for the first time. We use these entries in the subsequent times and do not prompt the CSR to select the entries everytime he launches the application.(a matter of better human computer interface!).
3. Yes - but we are not expected to use any RMI policy file or security manager. (which makes our life even simpler!)
Joined: Jan 15, 2004
Thanks Vishwa and Hanna! 1. I know the performance for the RandomAccessFile is not very bad. But I still want to do some caching. I think I can justify that there will not be memory problem. Because that small company will not have that much contractors in the near future and this is only "the starting point ... and to use that system as a learning exercise before going on to a web based system". My problem is I do not know I put the data file reading and writing tasks in a class other than Data.java is allowed or not. English is not my native language, I cannot clearly understand that requirement: "YOur data access class MUST be called "Data.java". 2. I do not store the db file location, because I require it to be in the current directory and named db-2x2.db. I do not store the magic cookie because my program just read and ignore it. I assume the db-2x2.db is the correct file. I do not store the port number because I hardcoded it as 1099, the default RMI port. Only need the CSR to key in the IP address everytime. Do you think is it OK? Do we really need to spend time on those small things? :=) 3. Thanks.
Joined: Aug 20, 2003
Hi Jin: I believe you can pass with your design. It is just matter of personal taste in design. You said you ignore the magic value, also you said you hard code the db file name. My requerment says that a user must be able to locate and choose a datbase file. Hence, database file can have different names. The magic vlaue there for a reason. As far as I understand, any database file choosen by a user must have the same magic value as the one provided by sun. Again, this is my understanding of my own requerments, yours might be different.
Hi Jin, I think you are fine with having multiple classes behind the Data class. In effect your Data class becomes a Facade to all the classes which do the real work (ooh, a design pattern in use ). This is a very good technique to use. You are still meeting the requirements that your "YOur data access class MUST be called "Data.java". That is, if your clients want to access the data, they must call a method in the Data class - they cannot call your methods in the other classes that you have behind the Data class.
2. I do not store the db file location, because I require it to be in the current directory and named db-2x2.db. I do not store the magic cookie because my program just read and ignore it. I assume the db-2x2.db is the correct file. I do not store the port number because I hardcoded it as 1099, the default RMI port. Only need the CSR to key in the IP address everytime. Do you think is it OK? Do we really need to spend time on those small things? :=)
Do I think you can pass with such a design? Yes. Many people have passed with similar design decisions. Do I think it is a good design? No. But then that is just my opinion I have seen too many companies who put applications and data in different drives / directories to feel that forcing a single location for the data is a good idea. By the way - your application could be started with a different current directory than where your application is stored. If you are forcing the use of a particular location, I hope you are taking that into account. That is, you could have your program and data in the C:\SCJD directory, and run it from the c:\TEMP directory, like so:
Likewise the way most people use RMI in this project precludes other programs from using the same RMI Registry. (That is, most people start the registry from within their program, and don't have a security manager, so no separate application cannot connect to your registry). So if you are forcing the use of port 1099 then you are potentially stopping your application from running on some servers, or potentially stopping other applications from running on the server where your program is running. Regardless of all this, you still need to store the server name / ip address for the client application. You may be running the client and the server on the same computer (in which case you can use the loopback address or "localhost"), but the client (examiner) may want the server on one computer and the client on a different computer. In which case they will need to be able to enter the IP address of the server, and it will need to be stored. Regards, Andrew
Hi all, Thanks all of you for the valuable suggestions.
1. I will go with my caching design with Facade pattern, if it does not violate the "Your data access class MUST be called Data.java" requirement. 2. OK, I will put all those things into the config file to make things better. Cheers, Zhang Jin
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Simple Questions about the Data.java and config files and JRMP