• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NX:database design

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a few questions about my database design:
I have this in my assignmnet ( as may be everybody here).

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:


So I begin to code my class Data.java :
Data.java implements DB
The read method in DB is pubic
I created 2 read methods in Data

and
[\CODE]
private String[] readRecord(int recNo)
throws RecordNotFoundException, FileNotFoundException, IOException {
String[] record = new String[nFields];
RandomAccessFile raf = new RandomAccessFile(dbName, "r");
raf.skipBytes(offset);
......
[/CODE]

one public which has the same signature as the one in DB and which call another read ( this one PRIVATE) which is the real one which does the read ( open file, read etc...)
And I have a DataAdaptater which call

I don't understand when they say

data access class

.
Does that mean that the "real" read method ( the one which really does the work) must be public?
I Should I have just one read method in Data ( obviously public to implements the one in DB).
2) Or I could all the public read methods in the adaptater level now called Data ( which implements DB)which methods of an oter class doing the real work?
My question is where do I say implemet DB
1) at the class which is going to daccess the data
2) at the adaptater level ? But I need a class to accesss the data!
and this time it does not implement DB
I am not sure if I am very clear
- Lydie
[ March 18, 2004: Message edited by: lydie prevost ]
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lydie prevost:
I have a few questions about my database design


I could'nt see any questions
Maybe you have to post them again.
 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I hit the return butter too quickly
I have edited it again
- Lydie
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lydie,
If I understand what you said you have the following:


Originally posted by lydie prevost:

I don't understand when they say "data access class."
Does that mean that the "real" read method ( the one which really does the work) must be public?
I Should I have just one read method in Data ( obviously public to implements the one in DB).

I think they mean the Data class when they say "data access class." Yes, the "real" read method must be public. When you say Data implements DB you are obligated to provide all the methods specified in the DB interface, but it in no way restricts you from adding anything you want to add to the Data class.

2) Or I could all the public read methods in the adaptater level now called Data ( which implements DB)which methods of an oter class doing the real work?

Data is your data access class, but it can delegate anything you want to any other class you want. In the same way, the public read method must do what the DB interface claims it will do (that is, it should do what the method comment in the DB interface claims it will do), but your perfectly free to delegate that work to other methods such as your doing with the readRecord method. Not only is there nothing wrong with that , in fact it is highly advisable (often it is called refactoring) as it keeps the size of the method small and results in a very focused, easily understood method.

My question is where do I say implemet DB
1) at the class which is going to daccess the data
2) at the adaptater level ? But I need a class to accesss the data!
and this time it does not implement DB
I am not sure if I am very clear

I think you need to say that the Data class implements the DB interface. The Data class is your data access class. Of course, that does not mean the Data class cannot delegate the work to another class. For instance, all database file access may actually be done in a class called DataFile. Then the Data class would use methods from DataFile to do the things it's required to do by the DB interface. By the same token, your GUI client can call whatever adapter class you want. A some point the adapter class is going to be making calls on the Data class, so you are in effect using the Data class as your data access class.

 
it's a teeny, tiny, wafer thin ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic