在我们公司,我们正在使用 C#、.NET 3.5 开发的基于 MVVM 的销售点系统的首席架构师选择了以下作为满足我们需求的最佳解决方案:
1)所有外围设备都放在表示层,包括支票阅读器、支票打印机、pos抽屉,几乎所有东西。这是一个规则。
2)我们期望在业务层产生这样的代码,由表示层调用,直到它停止抛出异常,并完成:
public void DoPaymentAtEndOfTicket() {
if(eCurrentState == enuStates.iSTART) {
eCurrentState = enuStates.iCONTROL_MAXIMUM_AMOUNT_BREACHED;
objController.Throw_Exception_To_UI_If_Maximum_Amount_Breached(); // might throw Exception to be handled by presentation layer
eCurrentState = enuStates.iCHECK_MINIMUM_AMOUNT_BREACHED; // Skip the control for max amount breached since no exception
}
if(eCurrentState == enuStates.iCONTROL_MAXIMUM_AMOUNT_BREACHED) {
objController.Throw_Exception_To_UI_To_Request_Supervisor_Credentials();
eCurrentState = enuStates.iCHECK_MINIMUM_AMOUNT_BREACHED;
}
if(eCurrentState == enuStates.iCHECK_MINIMUM_AMOUNT_BREACHED) {
eCurrentState = enuStates.iCONTROL_MINIMUM_AMOUNT_BREACHED;
objController.Throw_Exception_To_UI_If_Minimum_Amount_Breached(); // might throw Exception to be handled by presentation layer
eCurrentState = enuStates.iSTART_READ_CHEQUE_SINCE_AMOUNT_OK; // Skip the control for min amount breached since no exception
}
if(eCurrentState == enuStates.iCONTROL_MINIMUM_AMOUNT_BREACHED) {
objController.Throw_Exception_To_UI_To_Request_Supervisor_Credentials();
eCurrentState = enuStates.iSTART_READ_CHEQUE_SINCE_AMOUNT_OK;
}
if(eCurrentState == enuStates.iSTART_READ_CHEQUE_SINCE_AMOUNT_OK) {
eCurrentState = enuStates.iCHEQUE_READING_FINISHED_PROCESS_CMC7;
throw new Presentation_Layer_Interacts_With_Cheque_Reader_Exception();
}
if(eCurrentState == enuStates.iCHEQUE_READING_FINISHED_PROCESS_CMC7){
objController.ControlTheCheque(sCMC7NumberFromReaderInViewModel);
}
}
3)我的问题是:如果有的话,在专业层面这是否有可能被视为优质代码?我应该如何说服管理层我们走错了路?(在 .NET 3.5 中执行此操作)