プログラム開発における良いプログラムロジックと異常処理方法

1056 ワード

ウェブ開発の正しい論理処理方式:
入力判定、業務処理スロー運転時異常、出力ブロック
javaプログラムで表示します。
入出力処理クラス

public class Action
{
public String doAction(String in1) {
if(in1==null)//
return "";
try {
Service1 a=new Service1();
a.exe(in1);
Db.commit();
return "ok";
} catch (Exception e) {// , log, , aop
Db.rollback();
}
return "error";
}
}
論理処理クラス

public class Service
{
public void exe(String in1) {
//if(in1==null)// , , in1 , , , , 。
// return ;
String str2=in1.substring(2);
try {
Db.save(str);
} catch (SqlException e) {// , , , spring jdbcTemplate , 。 , :exe 。 exe , 。 。
throw new RuntimeException(" ");
}
}
}