• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UrlyBird: handling recNo

 
James Kitten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With reference to the methods defined in the DBMain interface. It suggests to me that the records "marked as deleted" should also be included in the find() method. Otherwise, the handling of the recNo becomes complicated.

Am I correct, or have I missed something basic?

JK
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Kitten:
With reference to the methods defined in the DBMain interface. It suggests to me that the records "marked as deleted" should also be included in the find() method. Otherwise, the handling of the recNo becomes complicated.

Am I correct, or have I missed something basic?

JK


There are two options here:

1) Cache.

A deleted record is represented by null in a cache in my project. find just skips nulls.

2) No Cache.

There should be a method which either a) tests record for being deleted before reading it, or b) reads a record and filters it out if it is deleted.
 
James Kitten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anton,

I see the problem as follows:

at start-up of the Data class (database server), I need to read all of the available records and pass them to the GUI. Now, lets say I have 5 records defined, but recNo 2 is marked as deleted on the disk. If I do not pass ALL 5 records, how can the GUI ask me to update recNo 3 later (because the GUI would treat it as recNo 3, if I filter deleted recNo 2). Bearing in mind that I can only use the methods in the DBMain interface (ie arrays)

Is there a better way?

I also think that filtering at the Data level is incorrect. To me that is a business rule. The data server is there simply to persist data records. Typically, in the real world an "Admin" mode would display all data defined in the file.

Comments?
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Kitten:
Hi Anton,

I see the problem as follows:

at start-up of the Data class (database server), I need to read all of the available records and pass them to the GUI. Now, lets say I have 5 records defined, but recNo 2 is marked as deleted on the disk. If I do not pass ALL 5 records, how can the GUI ask me to update recNo 3 later (because the GUI would treat it as recNo 3, if I filter deleted recNo 2). Bearing in mind that I can only use the methods in the DBMain interface (ie arrays)

Is there a better way?

I also think that filtering at the Data level is incorrect. To me that is a business rule. The data server is there simply to persist data records. Typically, in the real world an "Admin" mode would display all data defined in the file.

Comments?


There is a way. When you read records, and discard deleted records, it is known that there will be "gaps" in the record numbering. When you get to the GUI, a data model will be written (extending the AbstractTableModel class). If you pass your records as a Map (key - record number, value - record data), when you set this data to your data model, you can make another Map which will associate the real record number with the row number in your JTable. Thus you will be able to convert to and fro.
 
James Kitten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sorry for been stupid here, but how do I give that information to the TableModel?

In which method in the DBMain interface can I pass recNos to the GUI for it to make its map. Unless you mean the following:

1. return an array of ints containing record numbers: find() with empty criteria
2. GUI then performs a read() on each recNo.

That is a lot of roundtrips over RMI: with 100 records that would be 101 requests from the GUI to the Data layer, instead of one. And that would have to be repeated for every search.

I know perfomance is not specified in the assignment, but this is supposed to be a DEVELOPER exam. Or am I being to "real-world"?

Thanks for you help, by the way.
 
James Kitten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sorry for been stupid here, but how do I give that information to the TableModel?

In which method in the DBMain interface can I pass recNos to the GUI for it to make its map. Unless you mean the following:

1. return an array of ints containing record numbers: find() with empty criteria
2. GUI then performs a read() on each recNo.

That is a lot of roundtrips over RMI: with 100 records that would be 101 requests from the GUI to the Data layer, instead of one. And that would have to be repeated for every search.

I know perfomance is not specified in the assignment, but this is supposed to be a DEVELOPER exam. Or am I being to "real-world"?

Thanks for you help, by the way.
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would get Max Habibi's book (you can find info about it on this server) about this project. It contains very good ideas about how to handle data and business code.

As to the AbstractDataModel, I would look at Sun documentation about how to overwrite it.

Maybe Andrew, how is here on Shanghai time, I think, would be able to give better information.

But in general, exposing Data class to the client can result in too much network back and forth, and so there should be an adapter class in between which handles business logic (and maybe record filtering).
[ September 29, 2004: Message edited by: Anton Golovin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic