1 All public methods is synchronized in my Data.java , should the private methods synchronized?
I think they shouldn't be synchronized, because if each public method is synchronized,then just one thread in the object,private methods is safe too.
2 The createRecord(String[] data) must throw DuplicateKeyException ,but which is the key ,i am confused
,about the contractor ,i can't see a key, now i just throw the DuplicateKeyException when matchs all the fields. is right?
3 The description of createRecord(String[] data) is "Creates a new record in the database (possibly reusing a deleted entry). " .my doubt that when reuse a deleted entry? must i reuse,can i never reuse?
4 May i add some methods in the interface DBAccess which the instruction provided? i feel if a getFieldInf() that get the information of Fields is more reasonable,or i must put the information of Fields in the "suncertify.properties ".
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
"Do what you want", but know what might be the consequences and to defend your decision in your design/choices document.
Mark
quote:
--------------------------------------------------------------------------------
1 All public methods is synchronized in my Data.java , should the private methods synchronized?
I think they shouldn't be synchronized, because if each public method is synchronized,then just one thread in the object,private methods is safe too.
--------------------------------------------------------------------------------
I agree with your second statement.
quote:
--------------------------------------------------------------------------------
3 The description of createRecord(String[] data) is "Creates a new record in the database (possibly reusing a deleted entry). " .my doubt that when reuse a deleted entry? must i reuse,can i never reuse?
--------------------------------------------------------------------------------
I think the use of the word "possibly" means that you do not have to reuse the deleted entries. But you can if you want to.
quote:
--------------------------------------------------------------------------------
4 May i add some methods in the interface DBAccess which the instruction provided? i feel if a getFieldInf() that get the information of Fields is more reasonable,or i must put the information of Fields in the "suncertify.properties ".
--------------------------------------------------------------------------------
I think the general consensus here is that you can add extra methods to the Data class if you want to, but you should not change the provided interface at all (do not add methods or change signatures of provided methods).
and what about the 5, should write ?
I think that you over-synchronize to the detriment of concurrency and that you contradict the DBAccess interface itself (because if you don't allow concurrent reads / updates / deletes, there is no need for the lock / unlock methods). Why not only synchonize the critical sections in your code ?
I don't agree with you "there is no need for the lock/unlock methods" syschronized is for the safety of more than one threads accessing a Data object .and the lock/unlock is for the safety of more more than one threads which each have a Data object . so they are differently.
"I'm not back." - Bill Harding, Twister
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |