-
Notifications
You must be signed in to change notification settings - Fork 228
Migrate disease provider under healthcare providers (#1137) #1188
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
Migrate disease provider under healthcare providers (#1137) #1188
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1188 +/- ##
============================================
- Coverage 92.35% 92.02% -0.33%
- Complexity 2821 3037 +216
============================================
Files 292 308 +16
Lines 5609 5981 +372
Branches 599 629 +30
============================================
+ Hits 5180 5504 +324
- Misses 275 319 +44
- Partials 154 158 +4 ☔ View full report in Codecov by Sentry. |
|
To me, though I only had a quick look and didn't test it myself, this looks very good. I don't think the API is broken (maybe we should have a library API tester?), since the decease only moved, and the public API seems quite similar, so on a quick glance, it seems the API hasn't been broken. |
|
Completely changing the location of methods is API breaking. Users have to re-code things to make them work again. While it is minimal effort to adapt it's still a breaking change. |
| List<Supplier<String>> providers = List.of( | ||
| this::internalDisease, | ||
| this::neurology, | ||
| this::surgery, | ||
| this::paediatrics, | ||
| this::gynecologyAndObstetrics, | ||
| this::ophthalmologyAndOtorhinolaryngology, | ||
| this::dermatology | ||
| ); |
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.
I don't see a reason to create this list on each method call, it could be extracted in a const imho
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.
Done
| static final String INTERNAL_DISEASE_KEY = "healthcare.disease.internal_disease"; | ||
| static final String NEUROLOGICAL_DISEASE_KEY = "healthcare.disease.neurology"; | ||
| static final String SURGICAL_DISEASE_KEY = "healthcare.disease.surgery"; | ||
| static final String PAEDIATRIC_DISEASE_KEY = "healthcare.disease.paediatrics"; | ||
| static final String GYNECOLOGY_AND_OBSTETRICS_DISEASE_KEY = "healthcare.disease.gynecology_and_obstetrics"; | ||
| static final String OPHTHALMOLOGY_AND_OTORHINOLARYNGOLOGY_DISEASE_KEY = "healthcare.disease.ophthalmology_and_otorhinolaryngology"; | ||
| static final String DERMATOLOGY_DISEASE_KEY = "healthcare.disease.dermatology"; |
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.
Probably it's better to use enum for this
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.
Tbh I don't see a value of enum here, as it would not add any benefit, but complicate the code.
enum DiseaseType {
INTERNAL("healthcare.disease.internal_disease");
final String key;
}then
public String internalDisease() {
return resolve(DiseaseType.INTERNAL.key);
}Imo it would make sense only if there is some interface which then could be passed to resolve method (resolve(KeyHolder holder)), eg.
interface KeyHolder {
String key();
}
enum DiseaseType implements KeyHolder {
...
}
public String getSomething() {
return resolve(DiseaseType.ABC);
}This way it could work for other providers too easily.
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.
I don't mind if you keep it as is, these are mostly (only?) internal things anyway, we can always refactor it later.
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.
if you use enum, then you don't need private final List<Supplier<String>> allDiseaseProviders at all
and anyDisease could be implemented as Options.option..
And each time there will be a new disease, then with current approach you need to add both string var for this disease + maintain allDiseaseProviders. With enums you just need to update enums...
Thus finally less code
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.
Hm, I need to play with that, cause Options.option is new to me. Thanks for that hint, sounds reasonable now.
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.
Hi all, hope you don't mind, but I've addressed these comments in a commit on this PR, I didn't want to let these efforts go to waste. Thanks @filipowm for this improvement. @snuyanzin , can you please have another look at the PR?
src/test/java/net/datafaker/providers/healthcare/DiseaseTest.java
Outdated
Show resolved
Hide resolved
I might be missing something, but I don't see it? They will still do |
|
I'll have to pull the branch and play with it. If, as you've said, the methods are still accessed the same way then I totally agree it's non-breaking. I took bullet one from the PR description to mean that access had changed. |
|
🤦♂️ I'm being brain dead. The unit tests would have been different if there were API changes. I know they did move but the faker usage is the same. So ignore me 😔 |
|
The tests are failing, but not because of your changes, there still seems to be something broken in our internal works: |
|
I haven't looked but is this PR branched after that fix or does it need rebasing? |
@kingthorin I branched out on saturday, so it might require rebasing. I will do that in the evening. |
|
#1180 was merged "3 Days ago" (that's all the web UI shows). So hard to know. |
|
Hi all, what should we do with this PR? |
|
I guess addressing of this comment is still in progress #1188 (comment) |
Hi,
I started migrating
Diseaseprovider underhealthcare, however I'm not sure if this wouldn't break backward compatibility, because:Diseaseis moved fromBaseProviderstoHealthcareProvidersdisease.ymlwas changed to be prepended keys withhealthcareprefix.What are your thoughts on this? Is this approach safe enough to move on?