-
Notifications
You must be signed in to change notification settings - Fork 17
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
[InjectingExtension] Refactoring suggestions #496
Comments
This was added by me on purpose and should not be removed. The reason it is exists is for future proofing. If a subclass implements these interfaces, their method implementations should call the super methods in case they have important behavior. But if we do not now implement these methods, subclasses cannot call them. So we need to keep this to allow for the future were we want to implement these methods in the base class. |
That is not enough. There are other reasons why the subclass may know that it cannot handle the type and needs to communicate this with the caller in the base class. So I don't agree this is wrong. |
I am not sure what useful information the annotation has for supportsType? The TargetType parameter is the proper place (abstraction) to pass any necessary information to the method. If we need more information, we should improve TargetType and use it to pass information. |
I still disagree, for a couple of reasons:
However, I am happy to let this ship sail now rather than introduce another version change to remove them. |
Good point. I am not aware of all of them. I only put the counterparts to the Before interfaces for symmetry. (Asymmetry offends my OCD :-)
They would only know if they see the compiler complaining about the lack of Override if they recompile to the new version.
The sane subclasser would call the super methods now. But we should more clearly document this requirement in the javadoc. Properly designing classes for subclassing is hard :-) I don't always get it right, but I try to think about the future.
Agree, at this point, it is already done. Removing then would be a major version bump. |
As I understand the pattern working:
Returning |
True. But that's why a good developer always looks at the compiler warnings. 😄
Crystal balls are hard to come by and notoriously unreliable. 😄 |
Because the question of whether or not it supports a type may depend on how it has been configured in the annotation. For those injectors that always inject into a particular type, this will not be an issue. But I managed to work around this by pushing the code into This overlaps a bit with the issues I raised for |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you can reproduce this or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request. |
Having reviewed the
InjectingExtension
in more detail, I believe that we've made some mistakes in the pattern that we should consider addressing:supportsType()
should have taken the resolved annotation as a parameter. We can add this as a new method and delegate to the old.InjectingExtension
implementsAfterEachCallback
andAfterAllCallback
. However, the implementations do nothing. There is therefore no reason for the base class to implement these methods - if a specific implementation wishes to add this functionality, it can do so by directly implementing them.supportsType()
to return a boolean.supportsParameter()
andsupportsField()
both do a check to see if the field/parameter is annotated by the annotation type that is "owned" by the extension. If it is not owned by the extension, then it should return false so that Jupiter can find the rightful owner. But if if it is owned by the extension, then supportsField()/supportsParameter() must either return true (if all is well) or else throw an informative exception if there is some kind of misconfiguration. Simply returning false at this stage would be uninformative and implementations should be discouraged from doing so.boolean supportsType()
should have perhaps beenvoid checkField()
.Were it not for the fact that
InjectingExtension
has already found its way into a release in its current form, I would simply make these changes. However, I'm looking at the versioning consequences.The first change would introduce a minor or a major change depending on whether we simply change the signature or else add a new method that delegates to the old. The second would be a major change. The third - we could simply ignore the boolean return value from
supportsType()
and avoid any formal change, though the practical change would still be there so it might be misleading to not bump the version in that case (I think it would be confusing to implementers have a boolean-valued override whose return value is ignored).Thoughts?
The text was updated successfully, but these errors were encountered: