cucumber / cucumber/common

Consider inverting the messages dependency

Open
#1,614 5 comments 0 reactions 0 assignees View on GitHub
:bank: debt library: cucumber-messages
Dominant language
No language data
Stars
3.4k
Forks
679
PR merge metrics
No merged PRs in 30d

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](https://search.maven.org/artifact/com.fasterxml.jackson.core/jackson-databind).

As a visual aid (note note quite accurate, I was sketching out something else):

![image](https://user-images.githubusercontent.com/6946919/122121915-731b8b80-ce2c-11eb-8ce3-ef5b0a2aa2c4.png)

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.

https://github.com/cucumber/common/blob/f96daddbedd679969bee1609ac9a71e857752720/messages/messages.proto#L13-L43

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.

![image](https://user-images.githubusercontent.com/6946919/122126285-d22fcf00-ce31-11eb-8da5-754174e10038.png)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.