Sequence the checks in a defensive withdrawal method

A method withdraw(request) removes money from a stored account balance. The request object may be missing, and its amount field arrives from a web form, so it may not be a whole number. Valid withdrawals are 1 to 50000 cents inclusive and must not exceed the balance. The balance is held by a ledger service, and that service must only ever receive amounts already known to lie in the permitted range. Arrange the steps in the order a defensive implementation should perform them.

Loading ordering steps…

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Defensive Design Questions: