• 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

NX: Contractor questions

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
1.I am not sure if my implementation to open the RandomAccessFile is ok.
I have a separate class, DataInfo with only static variablen and methods to read the lenght of fields, header etc. I have also a static getRaf() method
witch returns new RandomAccessFile(dbFile, "rw"); I use this method every time I need the raf.
2. My find method returns the records depending on the exactMatch flag. The default is true. I have another constructor in the Data class with an additional boolean parameter to can set the exactMatch to false. In the case that the client will be later extended to search for inexact matches, than this constructor has to be used. Is this OK?
The find method searched for all fields, but in my GUI I use only the search for name and/or location. I have seen that many people searched for all field in the screen, but I think this is not in the requirement, so I don't need the other fields.
3. It is necessary to implement the create and delete methods? In GUI I don't need them. For the update method I have to update besides the owner field also the other fields? It is possible only to update the owner.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,Maria.

1.I am not sure if my implementation to open the RandomAccessFile is ok.
I have a separate class, DataInfo with only static variablen and methods to read the lenght of fields, header etc. I have also a static getRaf() method
witch returns new RandomAccessFile(dbFile, "rw"); I use this method every time I need the raf.


it sounds good.

My find method returns the records depending on the exactMatch flag. The default is true. I have another constructor in the Data class with an additional boolean parameter to can set the exactMatch to false. In the case that the client will be later extended to search for inexact matches, than this constructor has to be used. Is this OK?


Don't you have something like this in your DBAccess interface:


// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);


are you saying that the findByCriteria method in the Data class will return
records depending on the exactMatch flag which can be set in the Data class?
if so,i don't think it is a good design,cos your implementation of the DBAccess interface should be according to the method comments provided in the interface,and i think your implementation of the find method is inconsistent to the comment of the findByCriteria method which had told you definitely the match rule.
so,IMO,you should use a Adapter class to provide the exactly matches rather than provide it directly in the Data class.

3. It is necessary to implement the create and delete methods? In GUI I don't need them. For the update method I have to update besides the owner field also the other fields? It is possible only to update the owner.


base on the same reason above

your implementation of the DBAccess interface should be according to the method comments provided in the interface

,
i think you should implement the create and delete methods fully.
hope this help.
[ February 22, 2004: Message edited by: janvy wei ]
 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Janvy,
Many thanks for your reply. I think you have right about the find method.
But for me is not clear that I can use a Adapter class because in my instructions stays: "Your data access class must be called "Data.java" ".
That means, from the gui I have to call the Data class and not another class. Please clarify me.
Regards,
Maria.
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Maria,

Originally posted by Maria Lepschy:
But for me is not clear that I can use a Adapter class because in my instructions stays: "Your data access class must be called "Data.java" ".
That means, from the gui I have to call the Data class and not another class. Please clarify me.


I think Janvy is correct. Your GUI does not necessarily have to call the Data class directly. It can call another class directly (say an adapter class) as long as indirectly it ends up using the Data class for data access.
Regarding question 3, I think it is necessary to fully implement in Data all the methods declared in the Sun-supplied interface. In addition they should be implemented in a way consistent with the comments provided in the Sun-supplied interface. So, I think it is necessary to implement an update that updates all the fields of the database. At the client you can perform an update as follows:

So that effectively, you are only changing the owner field.
 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
Thank you for your reply- your answer is very helpfull. I will create a adapter class.
Regards,
Maria
 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George, Janvy
I have another question about the find method. I changed it following exactly the instructions. Now I think if I have in GUI two not editable comboboxes where the user can select the name and location entirely written, it is not necessary to adapt the method to search for only exact matches.
What do you think? Is this enough?
Regards,
Maria
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maria Lepschy:
Now I think if I have in GUI two not editable comboboxes where the user can select the name and location entirely written, it is not necessary to adapt the method to search for only exact matches.
What do you think? Is this enough?


I think you're right. I think it completely satisfies the search requirement in the assignment instructions.
 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, George, you help me to go ahead.
Regards,
Maria
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1.I am not sure if my implementation to open the RandomAccessFile is ok.
I have a separate class, DataInfo with only static variablen and methods to read the lenght of fields, header etc. I have also a static getRaf() method
witch returns new RandomAccessFile(dbFile, "rw"); I use this method every time I need the raf.


Since there is not a single raf you don't need to lock on the raf because another thread cannot move the file pointer. But I think you will need to lock the record on reads as well as writes. Otherwise, I think it will be possible to read a record that has been partially written.
I am still learning about the raf and locking so maybe I am just confused about how it all works. Any clarification would be helpful.
[ February 23, 2004: Message edited by: Don Wood ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic