ファイルを転送し、リモートサーバーで操作するためのインターフェイスを設計しています。混乱は、インターフェイスのメソッドが呼び出し元のコードを返す必要があるかどうかです。想定される利点は、呼び出し元が例外をキャッチする必要がないことです。
または、正しい方法は、ボイドを返し、失敗条件で例外をスローすることです??? もしそうなら、例外はカスタムであるべきですか?または言語によって定義されたプリミティブなもの (この場合は C#) ??
//Remote transfer interface 1
enum codes { SUCCESS, FAIL, HOSTUNREACHABLE, so-on and so forth }
codes init(String host, int port);
codes transferFile(String filepath, String remotename);
codes deleteRemote(String remotePath);
転送する 2 番目のタイプの iterface
//Remote transfer interface 2
//Following methods throw exceptions when they occur, catched by caller..
void init(String host, int port);
void transferFile(String filepath, String remotename);
void deleteRemote(String remotePath);
どの方法が最適で、その理由を教えていただけますか?