• Post Reply Bookmark Topic Watch Topic
  • New Topic

meaning of data access class  RSS feed

shan chen
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I hope someone could help me to clearify the meaning of "data access class". The instruction.html says:
Your data access class must be called "Data.java".

Does this mean Data is the only class that DIRECTLY handle database read/write? Data can not call another class to access database?
For example, I want to defind the create method as synchronized, so that it is the method DIRECTLY handle database:
synchronized int createRecord(String []) {}
Its signature is differenct from the create method in Data:
public int create (String [] ) {}

The second method actually calls the first method.
My question: is the following understanding correct?

I CANNOT define another class which contains these synchronized methods, otherwise Data is NOT data access class. I must put the first method within Data.java either, as a member method.
Thanks to any suggestion.
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12105
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shan,
Personally I would read data access class as meaning "the class throught which I access the data".
That is, if I want to do a read, I call Data.read. If I want to do a write, I call Data.write etcetera. I do not (and cannot) call multiple classes to do the same thing.
But I cannot see why the Data class itself cannot call helper classes to do more specific functions. You would need to be careful with those other classes though: if you give them public access, then someone could break your database in scary ways. You would probably only want package level access for them.
Any other opinions?
Regards, Andrew
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!