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
Reduce duplication #248
Reduce duplication #248
Conversation
Wow - nice duplicate code reduction so far! Like the approach and interested in how you go further |
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
I think I'm done for the most part. I would keep Note that subclasses of Proposed commit message:
|
Will have a look, hope tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before - like it very much :)
Open question: As with most traditional refactorings, I didn't touch existing tests. But do we want to have some additional tests for the new base class? |
I vote for yes. And if there are existing tests of the old extension which, in core, test the same, because the functionality moved to the base class, than we should merge them into tests for the base class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm :) thank you
I asked @beatngu13 if he wants to add tests for the base class and we wants so. So we wait for an update :) |
When I saw that we need six abstract methods, I was worried that the abstraction would the very fragile, bit it looks pretty good. Thank you very much @beatngu13! 👍 I was a bit surprised by the methods returning functional interfaces and turned that into "normal" methods (0c72122) - hope that's ok with you. From my perspective, this can be merged. |
@beatngu13 wanted to add some additional tests. After that is done we can merge. |
I looked at this for a few minutes, wondering what tests to add. With abstract base classes, I usually try to come up with an abstract base class for the tests as well. The concrete classes can then be tested by concrete test classes that extend the base class. In that scenario, actual tests are usually only in the abstract test base class and concrete test classes only implement some factory methods. I don't think this will work here because I know of no way to handle the annotations (e.g. I'm ok with just testing the implementation, i.e. just If you still want to add tests, keep in mind that we don't want to "overtest", i.e. if there's a bug in the abstract base class, we don't need its tests and the implementations to fail if that just adds more failing tests without providing more insight. |
Adds a more consistent style based on the System's property methods (clearProperty, getProperty and setProperty).
@nicolaiparlog makes sense, I'm fine with that. 👍 Just did a rebase to current |
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
This is an early draft to fix #180.
In order to reduce the code duplication among
SystemPropertyExtension
andEnvironmentVariableExtension
, I thought about an abstract base class for entry-based extensions, where entries (i.e. key-value pairs) shall be cleared or set.As outlined above, this is a draft. There may be still some design flaws,
the Javadoc is incomplete, no type wildcards… I just wanted to get some feedback if you think it is worth to further work on this, use a different approach or leave the extensions as they are. ✌️Personally, I quite like it because when you look at
SystemPropertyExtension
andEnvironmentVariableExtension
now, they are dead-simple.I hereby agree to the terms of the JUnit Pioneer Contributor License Agreement.