• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:Interface

 
Linda Andersson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I�m working with the URLyBird assignment.
According to the specification from Sun my access class must be called "Data.java" and must implement the given interface "DBAccess.java".
The way I interpret it we are not allowed to change or add anything to the
DBAccess interface. We are also suppose to implement this interface on the
client side (or are we not?) and use it when we retrieve data so that it looks the same if we run it lokal or remote.
This gives me the following problem. How am I suppose to retrieve the information about the field names, field length and number of records in file from the dbfile? There are no methods for this in the interface.
Please give me some advice.
//Linda
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Linda,
Welcome to this forum !
The way I interpret it we are not allowed to change or add anything to the DBAccess interface.

Agreed.
We are also suppose to implement this interface on the client side (or are we not?)

Mmh... difficult question . If you have some time there is a huge discussion on the subject.
I must tell you that in the meantime people from both camps passed with a high score, proving that both positions are defendable and allowed. It means that you may make your own opinion on the subject and apply it in confidence.
and use it when we retrieve data so that it looks the same if we run it lokal or remote.

Yes. You may have a look at Javini's recent post for further information.
This gives me the following problem. How am I suppose to retrieve the information about the field names, field length and number of records in file from the dbfile? There are no methods for this in the interface.

You are allowed to add methods to the Data class, and even add new classes. Some MetaData class may be useful, along with a getMetaData() Data method.
Best,
Phil.
 
Linda Andersson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil!
Thank�s for the advises but I don�t really understand what you mean with.
Some MetaData class may be useful, along with a getMetaData() Data method.
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Linda,
MetaData class can contain information about database fields (e.g. name, max. size), to help the client apllication be more flexibile to database structure changes.
Best,
Vlad
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Linda,
To complete what Vlad wrote above, some getMetaData() method (or whatever you name it) may be added to your Data class to ease access to the meta-information it contains. Nothing more than that.
Cheers,
Phil.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To, umm, further complete what's been said so far:
You must implement the given interface, and you can't change that interface. But there's nothing wrong with creating additional methods that weren't part of the interface. You can even create another interface which extends the original:

You can declare that Data implements both interfaces, or you can just use NewImprovedDBAccess, since if you implement that, you have implemented DBAccess too. But it's been suggested there's a small chance that Sun might have some sort of automated testing which fails to properly recognize this fact. So to save yourself a possible round of arguments with Sun, you can just declare that you implement both interfaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic