posted 20 years ago
I am reconsidering my private method design.
I have the following 2 methods and they do the same thing.
However, I see most of candidates here use METHOD 2.
Can someone tell me why METHOD 2 is better??
METHOD 1: public void validateRecNo(long recNo) throws RecordNotFoundException
pro: Throw RecordNotFoundException with the exact, actual reaon
con: client doesn't have his control when calling the method.
METHOD 2: public boolean isValidRecNo(long recNo)
pro: client can do what he wants according to boolean value
con: client doesn't know what happens
Steve Taiwan<br />SCJP 1.2, SCJD 1.4, SCWCD 1.3, SCBCD 1.3, OCP 8i DBA, SCEA