3 ms·
I think it depends on what you are doing. If the app has a single logical thread of execution, then sequential code is easier to understand than a series of cal
by frognibble 16y ago
I think it depends on what you are doing. If the app has a single logical thread of execution, then sequential code is easier to understand than a series of callbacks. If the app executes steps in parallel with forks and joins, then a state machine implemented with callbacks can be easier to understand.
The typical web app falls in to the former category: validate input, read from cache, maybe read from database, maybe write to database, generate response.
- dman 16y agoIf youre passing any state around with the callbacks or have shared global state then having callbacks will not buy you anything over the sequential code with loops, branches and joins imo. I think to prove correctness about the shared state you pretty much have to infer the loops, branches and joins.