在框架设计指南书中有关于Exception的章节,他们讨论基于返回值的错误报告和基于异常的错误报告,以及我们在像C#这样的OO语言中应该避免基于返回值的错误报告并使用异常。考虑到这一点,我正在研究八年前用Visual Basic编写的代码,去年一款自动工具被转换为C#!uplifitng返回值错误报告异常
所以这里是我正在看的一种方法,我想知道这本书的建议是否适用于这种方法,如果是的话,那么重写这种方法会是更好的方法吗?
public int Update(CaseStep oCaseStepIn)
{
int result = 0;
//Update the master object with the passed in object
result = UCommonIndep.gnUPDATE_FAILED;
if (Validate(oCaseStepIn) == UCommonIndep.gnVALIDATE_FAILED)
{
return result;
}
CaseStep oCaseStep = get_ItemByObjectKey(oCaseStepIn.CopyOfObjectKey);
if (oCaseStep == null)
{
return result;
}
return result;
}