Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird ]Should find call read?

 
pan zhixiong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I am wandering whether find should call read, how do you think?
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've decided to use read in find method. I've got data access class implementing my (not DB.java) data access interface (no find here). And Data.java (implementing DB.java) where find is implemented and uses read. In such case it seems to me you can easily switch to another data access class and/or use decorator pattern. And it is simple

P.
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an additional private method to read a record



Which returns a null string array if the record is deleted, the main difference being that the RecordNotFoundException is not thrown.

This method is used by the public read method which throws a RecordNotFoundException if the array is null.

Jason.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic