0

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)

  • The best way to get away from things you feel are idiotic is to move to another company. – theMayer Sep 12 '18 at 18:42
  • Flow control via exception is a red flag, but when dealing with hardware devices sometimes you see some pretty strange things, and they might be justified. Can't tell from the information provided. You should talk it over with your architect, and try to keep an open mind. – John Wu Sep 12 '18 at 18:55

0 Answers0