3 ms·
Suppose you are at some node. Here are two questions you might ask: 1. How did I get here? 2. Where will I go next? In the first program, those questions are
by nickdrozd 5y ago
Suppose you are at some node. Here are two questions you might ask:
1. How did I get here?
2. Where will I go next?
In the first program, those questions are pretty easy to answer. Node D has two entry points and node A has two exit points, and in all other cases there is only one possible answer. If you are at nodes B or C, you know exactly how you got there and exactly where you will go next. If you are at node A, you just came from D, and if you are at node D then you will go to node A next.
But in the second program, three of the four nodes have both two entry points and two exit points. If you are at node C, how did you get there? You could have gone the A-B-D-C route, or you could have come directly from A. And where will you go next? Maybe you will go to A, or maybe you will go to D, and from there...possibly back to C? Or maybe on to A.
The difficulty in answering these basic questions is what makes the second program spaghetti.
- Sniffnoy 5y agoBut you can logically group C and D, and then it's not so complex, I would say.