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

Extend database and domain for 'analysis performed' and 'comment' #311

Merged

Conversation

wow-such-code
Copy link
Member

No description provided.

@wow-such-code wow-such-code requested a review from a team as a code owner July 11, 2023 15:39
Copy link
Member

@KochTobi KochTobi left a comment

Choose a reason for hiding this comment

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

Hi @wow-such-code
your build fails ;) Please address the failure.

Copy link
Member

@KochTobi KochTobi left a comment

Choose a reason for hiding this comment

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

Hi @wow-such-code
Thank you for the changes. I'd like to motivate the use of the Optional class for these optional properties.
Looking forward to your changes :)

@KochTobi KochTobi self-requested a review July 12, 2023 12:35
Comment on lines 41 to 45
public Optional<String> getAnalysisType() {
return Optional.ofNullable(analysisType);
}
public Optional<String> getComment() {
return Optional.ofNullable(comment);
Copy link
Member

Choose a reason for hiding this comment

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

I read up on it. As soon as you have optional fields you should not use a record. The getter will still give back null so if you call sampleRegistrationRequest.analysisType() you would get null.
We should convert this to a class instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had this problem when I used the original method names "analysisType()" and "comment()". The suggestion to fix this problem was to explicitly add the "get" to the method name. This difference is also displayed by the IDE:
image
See first reply here for the solution I used: https://stackoverflow.com/questions/62945049/java-records-with-nullable-components

Copy link
Member

Choose a reason for hiding this comment

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

yes that happens because there would be two methods with the same signature and name but different return type
public String analysisType() and public Optional<String> analysisType() which is not possible in Java. That is why I recommend overwriting the method and making it a class instead of a record or not using optional in this case but simply returning null and make use of optional in the Sample class.

Comment on lines 61 to 62
this.analysisType = analysisType.orElse("");
this.comment = comment.orElse("");
Copy link
Member

Choose a reason for hiding this comment

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

I think the sample itself should have null values in these fields as they are optional for the sample.

Copy link
Member Author

Choose a reason for hiding this comment

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

How does this fit with using Optional?

Copy link
Member

Choose a reason for hiding this comment

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

the sample does have nullable fields and optional getters. the sample registration request can have null values. that is fine by me.
In the initial review, I missed the record for the constructor.

@sonarcloud
Copy link

sonarcloud bot commented Jul 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@KochTobi KochTobi left a comment

Choose a reason for hiding this comment

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

Hi @wow-such-code thank you for your patience!

@wow-such-code wow-such-code merged commit 400e866 into development Jul 13, 2023
5 checks passed
@KochTobi KochTobi deleted the feature/dm-819/extend-domain-for-analysis-performed branch July 13, 2023 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants