-
-
Notifications
You must be signed in to change notification settings - Fork 687
Open
Labels
Description
Currently everything depends on messages.
- This happens partially because messages contains the entire domain.
- And partially because we use messages as the Gherkin AST.
This is not great because:
- We have a serialization format at the core of our domain rather then in an adaptor.
- Because the Gherkin AST is the serialized format we can not utilize any patterns that make working with ASTs easier.
- When anything in the domain changes, everything has to be updated.
- Messages depends on Jackson. Due to it's nature as a de-serialization library Jackson gets frequent security updates.
As a visual aid (note note quite accurate, I was sketching out something else):
As such I would propose inverting the dependency and splitting messages into several smaller submodules. The modules are already hinted at by the comments in the proto file.
common/messages/messages.proto
Lines 13 to 43 in f96dadd
message Envelope { | |
oneof message { | |
// Gherkin | |
Source source = 1; | |
GherkinDocument gherkin_document = 2; | |
// Compiler(s) | |
Pickle pickle = 3; | |
// | |
StepDefinition step_definition = 4; | |
Hook hook = 5; | |
ParameterType parameter_type = 6; | |
TestCase test_case = 7; | |
UndefinedParameterType undefined_parameter_type = 8; | |
// Execution | |
TestRunStarted test_run_started = 9; | |
TestCaseStarted test_case_started = 10; | |
TestStepStarted test_step_started = 11; | |
Attachment attachment = 12; | |
TestStepFinished test_step_finished = 13; | |
TestCaseFinished test_case_finished = 14; | |
TestRunFinished test_run_finished = 15; | |
// Parsing | |
ParseError parse_error = 16; | |
Meta meta = 17; | |
} | |
} |
By inverting the dependency:
- We push the serialization format out to the edges of the architecture. This allows for proper ports and adaptors design. Only root dependents (e.g. the Cucumber CLI) would have a dependency on messages.
- The impact of updating external dependency changes is limited to the root dependents (e.g. the Cucumber CLI).
- Changes that impact Gherkin won't impact execution related code.and vice-versa.
Now I imagine the biggest perceived obstacle will be additional copying the domain objects into messages. However for example if the Gherkin AST was modelled as a tree of nodes using the visitor pattern it would be relatively straightforward to convert it to a message object.