Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Changing DBMain/Data method signatures???

 
Dave Knipp
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am at a point in my assignment where i would really really love to change the signatures in the supplied interface from sun. In my case that interface is DBMain and the class that implements it is Data. The read method in particular looks like this:

But i would like it to look like this:

The reason for this is that when i parse my database, i create each record as a Record object and then I hold all these Records in memory. So if i could just return each record in the database as a Record within any method in Data/DBMain then that would be ideal.
If i am unable to change the signatures of the Data methods, i'll have to translate these Records into string arrays, pass them to the client, and then iterate through the arrays contents once again when i populate the tablemodel with the data. It just seems more logical to pass a Record to the client and then just pull all the contents directly from the record.
Has anyone ever come across such a design decision?? Is this an automatic failure condition? Has anyone ever passed after submitting a DBMain and Data that are edited to suit your needs more logically?? If anyone has any hints that would be great.
Thanks in advance!
Dave
[ November 05, 2003: Message edited by: Dave Knipp ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this an automatic failure condition?
To the best of our knowledge, yes.
Has anyone ever passed after submitting a DBMain and Data that are edited to suit your needs more logically??
Not that we know of. Admittedly, probably not many people even try, because we tend to discourage them.
Consider though that although the DBMain interface is a fixed requirement, and Data muct implement it, it's not clear that this interface needs to be implememted on the client as well. That is, DBMain and Data may be a component that lives only on the server (or in standalone), whereas the interface that clients see might be something different. E.g. many people have some sort of facade class in their design which wraps the DBMain interface to abstract away tedious details like locking and unlocking, providing a simpler interface with methods like book() instead. The question is, should simplification be performed on the server, or the client? There's been a long discussion on this topic, and ultimately you can justify either answer. But I bring it up here because if you do choose the thin client / 3-tiered solution, you can export whatever interface you want to the client - and if that uses Record rather than String[], that's OK. Of course, I am obliged to point out that thin client is Wrong for this assignment and that you risk eternal damnation of you do this. But at least you'll have plenty of company. Cheers...
 
David Chan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that the signatures in the supplied interface from sun cannot be changed. Can I add IOException to the method in the implementation class like this? Thanks.
Interface class from sun:
public String [] read(int recNo) throws RecordNotFoundException;
Implementation class:
public String [] read(int recNo) throws RecordNotFoundException, IOException
{
...
}
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Dave, Jim and David!
I have designed "RecordAdapter" which follows the Adapter Design Patterns and its function is to convert between 2 incompatible interfaces. So my client code never has to work with array of strings and always uses Record objects. All client GUI (JTable, Dialog boxes) use Record objects to display Rooms. Also my Record class defines some methods, which make it easier to use on the Server, such as:
public boolean isValid();
to determine if the record should be passed back to the client or not, because it might be deleted (or booked)
Please comment on this approach.
Thank you very much!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that the signatures in the supplied interface from sun cannot be changed. Can I add IOException to the method in the implementation class like this?
No.
Seid: that sounds like a good approach. For a lengthy discussion of pros and cons and related issues, you may want to check out this thread. Not necessarily the whole thread - just read until you get tired of it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic