Skip to content

Stream Practice solution#1392

Open
tylerj231 wants to merge 2 commits into
mate-academy:mainfrom
tylerj231:solution
Open

Stream Practice solution#1392
tylerj231 wants to merge 2 commits into
mate-academy:mainfrom
tylerj231:solution

Conversation

@tylerj231

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Changes are needed for this submission because it violates two core requirements of the task. While you've done a great job with most of the stream logic, please address the following:

  • In StreamPractice.java, the getOddNumsAverage method uses a for loop. The task requires all solutions to use only the Stream API, without any loops [CHECKLIST ITEM #2]. Consider using IntStream.range() to process elements by their index within a stream.
  • In CandidateValidator.java, the values 35, 10, and "Ukrainian" are hardcoded. These magic values must be declared as private static final constants as specified in the checklist [CHECKLIST ITEM #6].

Once these issues are resolved, your solution will be in great shape!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/main/java/practice/StreamPractice.java Outdated
Comment thread src/main/java/practice/StreamPractice.java
Comment thread src/main/java/practice/StreamPractice.java
Comment thread src/main/java/practice/StreamPractice.java
Comment thread src/main/java/practice/StreamPractice.java
Comment thread src/main/java/practice/StreamPractice.java
Comment thread src/main/java/practice/CandidateValidator.java
Comment thread src/main/java/practice/CandidateValidator.java Outdated

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Excellent work on this iteration! I am approving your solution as you've successfully addressed the previous feedback and met all the core requirements. The use of the Stream API is now correct, and constants are properly implemented.

I have a couple of minor suggestions for future improvements:

  1. In CandidateValidator.java, the check candidate.getClass() == Candidate.class is redundant. Since the test method parameter is of type Candidate, this check will always be true and can be removed for cleaner code.
  2. In StreamPractice.java, the .sorted() method in validateCandidates should be on a new line to adhere to the project's style guide [CHECKLIST ITEM #5].

These are just minor points to keep in mind. Great job completing the task!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

return Collections.emptyList();
CandidateValidator validator = new CandidateValidator();
return candidates.stream()
.filter(validator).sorted(Comparator.comparing(Candidate::getName))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #5: 'Call each new method from a new line in the stream'. The .sorted() method should be moved to a new line to improve readability.

public boolean test(Candidate candidate) {
int from = Integer.parseInt(candidate.getPeriodsInUkr().split("-")[0]);
int to = Integer.parseInt(candidate.getPeriodsInUkr().split("-")[1]);
return candidate.getClass() == Candidate.class

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This check candidate.getClass() == Candidate.class is unnecessary. Since this is an implementation of Predicate<Candidate>, the test method will only ever be called with an object that is an instance of Candidate. You can safely remove this part of the condition.

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.

3 participants