Data flow analysis can help avoid this.
The idea is that given some complex scenario for software mechanics, we can fully iterate all of the issues in advance, so we know what we need to solve.
To do this, we can examine the flow of the data.
In a simple example, the data is something a user knows. They enter that into a screen. On completion, the data is sent to the back end, which then persists it.
So the flow is:
User -> screen -> request -> backend -> persistence -> response -> user
Two key problems:
- Data is invalid
- One of the two backend resources is down
- screen
- request
- persistence
We’d like to give the user a chance to correct the problem without having to start all over again. They really appreciate not having their time wasted.
There are at least three computers involved in this flow. If the first one is down, the flow is blocked, so we don’t need to worry about it.
If either of the other two is down, most of the time we want to wait for a little bit, just in case they become available again, so we sleep for a bit and retry.
If it's a long disruption at either computer, we want to let the user know. Since they may communicate it to support personnel, we want to be clear about which of the two resources is down. So there are two similar error messages for the user, but distinguishable for diagnostic purposes.
If the attempt to persist is successful, we also want to let the user know. But the backend is an intermediary, so it could fail just after the persistence worked and accidentally hide the success message. It was persisted, but the user gets informed about a failure instead. We need to avoid that somehow.
So, there are six arrows, four of which are problems that should be solved in the software.
One way of getting around this is to collapse the arrows as much as possible. Distributed programming is fraught with complex error handling and transaction integrity problems. Avoiding it is the best way of solving it.
Keep in mind that this is a tiny, common, simple example. But it does include all of the spinning pieces and issues. If you code all of the issues to work correctly, then you can extend that approach to much more complex scenarios. If you get this working, then filling in the missing deterministic computations is easier.
No comments:
Post a Comment
Thanks for the Feedback!