Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

NX: Questions about DB server

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
     
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic