猿问

业务逻辑层 应该返回 errorMessage 还是 throw new Exception(err

比如:

1)

BusLogic.BillService.Insert(BillInfo info,out string errorMessage)

2)

BusLogic.BillService.Insert(BillInfo info)

{

  if ( info == null )

    throw new Exception(errorMessage);

}

究竟我该采用那种设计呢?


MMTTMM
浏览 778回答 2
2回答

函数式编程

我觉得如何按OOP的思想来做的话,用throw new 逻辑名Exception比较合适一些.

蝴蝶刀刀

业务逻辑层:应该返回 errorMessage当然如果是我的话,我会返回errorcode,然后有errorcode去对应resource中预先定义的错误信息,显示到页面上。
随时随地看视频慕课网APP
我要回答