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

UrlyBird: handling recNo

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic