MVVM: raising exceptions from business layer to presentation to request display

53 Views Asked by At

At our company, the lead architect for the MVVM-based point of sale system we're developing, in C#, .NET 3.5, has chosen for the following as the best possible solution for our needs:

1) All peripherals are to be placed in the presentation layer, including cheque reader, cheque printer, pos drawer, just about everything. That's a rule.

2) We are expected to produce code like this in the business layer, called by the presentation layer until it stops throwing exceptions, and completes:

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) My question is: how, if any, is there any possibility that at professional level this counts as code of good quality? How should I go about trying to convince the management that we are on a wrong track? (doing this in .NET 3.5)

0

There are 0 best solutions below