refactor: Interpret score with a provided method on Score #100
Reference in New Issue
Block a user
No description provided.
Delete Branch "interpret-score"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR implements the option (2) described below with a bit of "hardcoded" instrumentation. The refactoring to better manage state will come in a future PR because of more decoupling needed (
Installable,AlertReceiver,AlertSender, all make use of theInterpretStatusand such).Context
In the current design, we execute the interpretation of a score as such:
The signature being:
We can do it whenever we want, wherever we want.
Because of this, it is no easy task to control the lifecycle (status) of an Intrepret, without pushing this responsibility back to the developers of scores/interprets. Even if we try to have a "smart" interpret state that handle itself the lifecycle/instrumentation.
So after some consideration, here are the 2 options I explored that allows to keep the flexibility of executing interprets whenever, wherever we want as well as composing scores together.
Possible implementations
1. Introduce an
interpret_scorefunctionPlays a similar role to
Maestro::prepare_topologyby "orchestrating" the execution of anInterpret:Pros:
Score/InterpretimplementationsCons:
2. Add
interpretdirectly toScore(as a provided method)Similar to proposal (1), the difference is that it's part of the
Scoretrait directly, making it easier to discover and use without needing to remember a separate function:Pros:
Score/InterpretimplementationsScore, it feels less like an anemic domain modelCons:
I 100% agree with the pros as required elements of the design :
However, I think the implementation can be better. Adding orchestration-related logic to the Score feels wrong. I'll try something in a playground when I have an hour to spare.