R
Royan
Lets say you have the following interface:
Interface IFoo {
public String[] readStrings();
}
The thing is that you cannot change that interface, but you have to
implement it. Now that readStrings() method must read from file, then
do some parsing and finally retrieve an array of Strings. As you can
imagine a couple of exceptional conditions have to be handled within
the implementation of this method:
1) IOException
2) EOFException
3) Reader initialization error (failure of BufferedReader, or
DataInputStream, whatever is used in implementation)
....
n)
I'll repeat, one cannot change the signature of the method, for
instance, I cannot add *throws* declaration. So what would you do in
order to tell caller of an error? Please note that caller needs to
differentiate one error form another, so returning null is OK but only
for one type of error.
And one the most important things, that method must implemented in two
roles: RMI and File-System, what would be your suggestions taking into
consideration everything said above?
Interface IFoo {
public String[] readStrings();
}
The thing is that you cannot change that interface, but you have to
implement it. Now that readStrings() method must read from file, then
do some parsing and finally retrieve an array of Strings. As you can
imagine a couple of exceptional conditions have to be handled within
the implementation of this method:
1) IOException
2) EOFException
3) Reader initialization error (failure of BufferedReader, or
DataInputStream, whatever is used in implementation)
....
n)
I'll repeat, one cannot change the signature of the method, for
instance, I cannot add *throws* declaration. So what would you do in
order to tell caller of an error? Please note that caller needs to
differentiate one error form another, so returning null is OK but only
for one type of error.
And one the most important things, that method must implemented in two
roles: RMI and File-System, what would be your suggestions taking into
consideration everything said above?