How short circuiting can make you debug 5X faster?

How short circuiting can make you debug 5X faster?

Assume you're working on a ticket - in which there is a bug - concerning a feature consisting of multiple processes. For example, there is an issue with changing the payment method of a particular customer.

If you try reproducing the error following the whole workflow to isolate the problem and search for a solution, this might take a lot of time.

The main idea is to change the codes in a way that avoid real codes running but instead isolate a certain point.

To illustrate our above scenario:

  • from email retrieve payment details of customer
  • check if payment details such as IBAN are different
  • if not, no need to proceed any further
  • if the details are different, check if they are valid
  • if they are valid, we send the payment provider the details to be updated
  • when the operation is completed, the provider either returns a response
  • if positive, we update the payment details for the customer in the database
  • else if negative, we send an error code and message to complete this long function
  • but before, in either case, we are going to log down - for tracking reasons - the customer Id, the initial payment details, the updated ones, and the payment provider's return data

Now assuming you've isolated the issue when you check if the updated payment details are valid. You don't need for the whole function to complete.

You can stop it by using a return or break or exit statement depending on the programming language. Similarly you can comment and mock values in above situations to just focus on one part.

Ideally, you would have a different method for checking this behavior; and can run it separately and independently of the rest.