must we handle these situations ("a)" and "b)") in findRooms of Business-class ?
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs wrote:b) now the deleted and recreated records: because you have to filter the returned records (in the client you just want to see exact matches, the find-method returns startsWith matches) these recreated records will get filtered out if they don't match.
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Sean Keane wrote:How did you handle this Roel? Create a seperate find method in your Data class that returned record details in one atomic operation?
Dmitri Cherkas wrote:- in my the new findRecords I will catch the RNFE, but just ignore it (in catch block I will add some code comment "record could have been deleted...").
Dmitri Cherkas wrote:Why and when must i apply the exact match filter after calling new findRecords(String[] criteria) ?
Roel De Nijs wrote:
your code comment makes no sense at all, because you are executing an atomic operation, no records can't be deleted when executing this findRecords-method.
Roel De Nijs wrote:
startsWith-matching is not the same as exact matches.
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Sean Keane wrote:
...Because you must filter the search results for exact matches. So when you come across a record that has been deleted and a new one recreated with the same ID it either will or will not match the entire search critieria..
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Dmitri Cherkas wrote:Can you suggest me anything ?
Dmitri Cherkas wrote:am I right ?
Dmitri Cherkas wrote:I already redesign tomorrow findRooms-method to take as parameter Room-valueobject instead of String[].
Dmitri Cherkas wrote:What do you think about all it above ?
Roel wrote:
That's already a good improvement (in comparison of using String[] or seperate Strings), but maybe you can consider creating a RoomFilter-object. This object is only used for searching. Could you think of some advantage(s) for using a seperate RoomFilter-object (instead of reusing the Room-object).
Dmitri Cherkas wrote:At this moment i don't see advantage(s) for using a seperate RoomFilter-object... but only because now I have not panoramic view of my complete application...
Dmitri Cherkas wrote:And the last small question
Interesting... very interesting...Roel wrote: It has nothing to do with the current application, but with possible new functionality in future releases.
Dmitri Cherkas wrote:Interesting... very interesting...
Dmitri Cherkas wrote:Effective Java Second Edition (Joshua Bloch)
Dmitri Cherkas wrote:This is generally the exception to throw if the invocation is illegal because of the state of the receiving object.
Dmitri Cherkas wrote:
... But if you used java.lang.IllegalStateException to handle this situation ... and pass with famous score i will use this construct too...
Consider Paul's rocket mass heater. |