• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Questions about DB server

 
David Chan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment URLyBird v1.2.2. I have some questions to develop the db server:
1. Is it necessary to validate the data when reading the db file?
2. Is it a good idea to use java class Vector to store the record? (By using this object, I can call wait() and notifyAll() method in my locking mechanism.)
3. In coding, need to set private to each instance variable in order to minimize the variable scope? (Cannot use default or protected modifier?)
4. In coding, in normal situation, no need explicitly to set final to the method, right?

Thank you
SCJP, SCWCD
David
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
  • I don't think so.
    In some ways this depends on whether you are developing a "database" server or a "hotel bookings" server. If the former, you could only validate the data against the schema (which has everything as Strings, so it should all validate). If the later, then you could validate against the data that you know is meant to be contained in the fields.
  • Well you can use wait() and notify() with any object. So the real question is what do you want to store and what are your requirements for storing it. This will lead you to the best object to store it in.
  • It is a good idea to minimize variable visability and scope. But whether you make variables private or use some other modifier (or use method variables instead of instance/class variables) is something that you will have to decide on a case by case basis. As you develop your solution, you will have to decide the correct scope and visibility for each variable / method.
  • Not only no need - why would you want to?


  • Regards, Andrew
     
    Ramses Tutoli
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In my Data() class I validate the db file by checking for the magic cookie at the beginning of the file. If it's not valid, I throw an exception. My Server and Client GUI's catch the exception and display an error message. I don't know if it's necessary, but it's not difficult.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic