refactor: Interpret score with a provided method on Score #100
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: NationTech/harmony#100
Loading…
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 theInterpretStatus
and 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_score
functionPlays a similar role to
Maestro::prepare_topology
by "orchestrating" the execution of anInterpret
:Pros:
Score
/Interpret
implementationsCons:
2. Add
interpret
directly toScore
(as a provided method)Similar to proposal (1), the difference is that it's part of the
Score
trait directly, making it easier to discover and use without needing to remember a separate function:Pros:
Score
/Interpret
implementationsScore
, 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.