Skip to content

task competed#1899

Open
IvanKlever wants to merge 2 commits into
mate-academy:masterfrom
IvanKlever:ivan-task
Open

task competed#1899
IvanKlever wants to merge 2 commits into
mate-academy:masterfrom
IvanKlever:ivan-task

Conversation

@IvanKlever
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

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

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 implementing the Storage functionality! Your code correctly handles all the core requirements for adding and retrieving data. However, changes are needed because there's a significant amount of duplicated code. In StorageImpl.java, the logic for finding a key's index is repeated in both the put and get methods. This violates a key principle of writing clean code and goes against one of the task's requirements: 'Don't create repeating code' [CHECKLIST ITEM #5]. To fix this, please extract the search logic into a single private helper method. Both put and get can then call this new method to find the index, making your code more maintainable and easier to read. Once you've refactored this, 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 on lines +19 to +25
for (int i = 0; i < size; i++) {
if ((key == null && this.keys[i] == null)
|| (this.keys[i] != null && this.keys[i].equals(key))) {
this.values[i] = value;
return;
}
}
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 loop for finding a key is nearly identical to the one in the get method. This violates checklist item #5: 'Don't create repeating code'. Consider extracting this search logic into a separate private helper method that returns the index of a given key. Both put and get methods could then use this helper method to avoid code duplication.

Comment on lines +37 to +42
for (int i = 0; i < size; i++) {
if ((key == null && this.keys[i] == null)
|| (this.keys[i] != null && this.keys[i].equals(key))) {
return this.values[i];
}
}
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 logic for finding a key is a duplicate of the logic in the put method. As per checklist item #5, you should move this repeated logic to a separate private method to avoid redundancy and improve the code's structure.

Copy link
Copy Markdown

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

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. You've successfully addressed the previous feedback by extracting the key-finding logic into a private helper method. This significantly improves the code's readability and maintainability by following the DRY principle. Your solution now fully meets all the task requirements. Great job!


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

Footnotes

  1. Rate AI review example

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