Failure to save a transaction should be considered an error #11

Open
opened 10 months ago by inga-lovinde · 0 comments
Owner

The entire premise of this service is very very odd.

Why would anybody need to calculate commission for every transaction separately (instead of, say, calculating the total commission for all transactions over a month in a final statement for that month)?

Why do we treat "a commission calculation was requested for this transaction input" as "this transaction is definitely going to go through, we need to save it"? "Calculate commission" and "save transaction" are two different operations, mixing them in one method is a huge smell.

But even leaving this aside: commission calculation relies on previous transactions, yet we ignore any errors happening when we are trying to save transaction to DB (and return response to a client before we even started trying to save it). Which means that if database is down, or if data is malformed, or whatever, then even the premise "this transaction is definitely going to go through, we need to save it" breaks down, and we'll end up incorrectly computing commissions for subsequent transactions.

In order to fix this, we need to wait for transaction to be saved in DB before returning commission to the client; and if DB operation failed, we should return an error.

The entire premise of this service is very very odd. Why would anybody need to calculate commission for every transaction separately (instead of, say, calculating the total commission for all transactions over a month in a final statement for that month)? Why do we treat "a commission calculation was requested for this transaction input" as "this transaction is definitely going to go through, we need to save it"? "Calculate commission" and "save transaction" are two different operations, mixing them in one method is a huge smell. But even leaving this aside: commission calculation relies on previous transactions, yet we ignore any errors happening when we are trying to save transaction to DB (and return response to a client before we even started trying to save it). Which means that if database is down, or if data is malformed, or whatever, then even the premise "this transaction is definitely going to go through, we need to save it" breaks down, and we'll end up incorrectly computing commissions for subsequent transactions. In order to fix this, we need to wait for transaction to be saved in DB before returning commission to the client; and if DB operation failed, we should return an error.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: inga-lovinde/test-assignment-payments#11
Loading…
There is no content yet.