Skip to content

First Update#1393

Open
obvly wants to merge 3 commits into
mate-academy:mainfrom
obvly:main
Open

First Update#1393
obvly wants to merge 3 commits into
mate-academy:mainfrom
obvly:main

Conversation

@obvly

@obvly obvly commented Mar 31, 2026

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

Great job on the overall implementation! The use of the Stream API is correct and all functional requirements have been met. However, I am requesting a change in the CandidateValidator.java file. The code currently uses hardcoded values (e.g., 35, 10, and "Ukrainian"), which are often called 'magic values'. This is a violation of a specific project requirement to use constants [CHECKLIST ITEM #6]. Please refactor this by declaring these values as named private static final constants. This will significantly improve the readability and maintainability of your code.


✨ 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

public List<String> validateCandidates(List<Candidate> candidates) {
return Collections.emptyList();
return candidates.stream()
.filter(new CandidateValidator())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While the usage of CandidateValidator here is correct, its implementation violates checklist item #6: 'Use constants'. The test method in the CandidateValidator class uses magic numbers (e.g., 35, 10) and a magic string ("Ukrainian"). These should be defined as constants for better readability and maintainability.

Comment on lines +11 to +14
return candidate.getAge() >= 35
&& candidate.isAllowedToVote()
&& "Ukrainian".equals(candidate.getNationality())
&& yearsInUkr >= 10;

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 #6: 'Use constants'. The numbers 35 and 10, and the string "Ukrainian" are 'magic values'. They should be declared as named constants (e.g., private static final int MIN_AGE = 35;) to make the code clearer and easier to maintain.

@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

Great job addressing the feedback from the last review! The CandidateValidator now correctly uses constants, which is a significant improvement. Your use of the Stream API is very well done.

I am requesting one small change in the getCatsNames method within src/main/java/practice/StreamPractice.java. The task description asks for the names of all cats that meet the criteria, but the use of .distinct() filters out duplicate names. For example, if two different owners have cats with the same name, that name should appear twice in the final list.

Please remove the .distinct() operation to align the implementation with the requirement. After this minor adjustment, your solution will be perfect!


✨ 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

.filter(p -> p.getAge() >= femaleAge)
.flatMap(p -> p.getCats().stream())
.map(Cat::getName)
.distinct()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task description asks for the names of all cats that meet the criteria. Using distinct() filters out duplicate names. If two different owners have cats with the same name, that name should appear twice in the final list, but this implementation would only return it once. Please consider removing this step to align with the requirement.

@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

Great job on this task! Your implementation is clean, correct, and effectively uses the Stream API, especially with the custom CandidateValidator. I am approving your solution so you can continue making progress.

As a small tip for future improvements, you can make your code even more concise and efficient by combining consecutive filter() calls into a single one. For example, in selectMenByAge, you can merge the two filters using a logical &&. This is a good practice that helps minimize the number of operations on the stream.

.filter(p -> p.getSex() == Person.Sex.MAN
        && p.getAge() >= fromAge && p.getAge() <= toAge)

This is just a minor refinement in an otherwise excellent submission. Well done!


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

Footnotes

  1. Rate AI review example

Comment on lines +50 to +51
.filter(p -> p.getSex() == Person.Sex.MAN)
.filter(p -> p.getAge() >= fromAge && p.getAge() <= toAge)

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 is functionally correct, but you can make it more concise. It's a good practice to combine consecutive filter operations into a single one to reduce the number of operations on the stream. This aligns with checklist item #1.

You can combine these two filters like this:

.filter(p -> p.getSex() == Person.Sex.MAN
        && p.getAge() >= fromAge && p.getAge() <= toAge)

Comment on lines +76 to +77
.filter(p -> p.getSex() == Person.Sex.WOMAN)
.filter(p -> p.getAge() >= femaleAge)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job addressing the feedback from the last review by removing .distinct()!

Similar to my other comment, you can combine these two filter calls into a single one for better conciseness and performance, as suggested by checklist item #1:

.filter(p -> p.getSex() == Person.Sex.WOMAN && p.getAge() >= femaleAge)

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.

2 participants