Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Refactoring: add execute operation to requests, extract SPI package #27

Merged
merged 18 commits into from Oct 18, 2018
Merged

API Refactoring: add execute operation to requests, extract SPI package #27

merged 18 commits into from Oct 18, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 4, 2018

API Refactoring proposal containing the following changes. The most important changes are:

Provide an execute() operation on PlcRequest, returning PlcResponse. This has already been discussed in the mailing list. The idea is to remove temporal coupling which forces the client to invoke operation in pairs: for example, creating the request off a PlcReader and submitting the created request back to the same PlcReader for execution.

Move PlcDriver away from the API into the SPI package. Since execution of the requests will be implemented on the request itself, one level of indirection (PlcReader, PlcWriter, PlcSubscriber, PlcProprietarySender) in the chain PlcConnection -> PlcReader -> PlcReadRequest.Builder -> PlcReadRequest becomes trivial and unnecessary. However, the execution of the requests will be performed differently depending on the protocol being implemented. This variation should be encapsulated behind the PlcReader interface, but it should not be exposed to the client. Therefore, these interfaces are placed in the driver-base module for protocol implementers.

Other minor changes include:

Remove default methods from the API. These were "workarounds" for sub-optimal API design. A public API should be as slim as possible, and default operations should be omitted.

PlcMessageBuilder renamed to PlcRequstBuilder. It is useful (and was acually used) only for constructing requests anyway.

Reduced the amount of generics. Many types were generic, which increased the complexity dramatically, but provided almost no benefit for the client. Wherever possible, the type parameters were removed to simplify the API.

Copy link
Contributor

@JulianFeinauer JulianFeinauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated on the list, I like it!

@asfgit asfgit merged commit 48dbad0 into apache:master Oct 18, 2018
@ghost ghost deleted the feature/execute-operation branch October 26, 2018 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants