Skip to content

Ready for push, passed tests and checkstyle#1920

Open
acidden wants to merge 2 commits into
mate-academy:masterfrom
acidden:master
Open

Ready for push, passed tests and checkstyle#1920
acidden wants to merge 2 commits into
mate-academy:masterfrom
acidden:master

Conversation

@acidden
Copy link
Copy Markdown

@acidden acidden commented May 24, 2026

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

Your implementation has two critical violations of the checklist requirements that must be fixed before approval. First, [CHECKLIST ITEM #6] explicitly prohibits using java.util.Objects class, but your code uses Objects.equals() at line 21 — replace this with direct null-safe comparison: key == null ? otherKey == null : key.equals(otherKey). Second, [CHECKLIST ITEM #5] requires avoiding repeating code patterns, yet the key-search loop logic is duplicated in both put() and get() methods — extract this into a private helper method like findKeyIndex(K key) that returns the index or -1 if not found. These are functional requirements from the checklist, not style preferences. Once you fix these two violations, your implementation should meet all requirements.


✨ 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

package core.basesyntax.impl;

import core.basesyntax.Storage;
import java.util.Objects;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #6 states 'Don't use class Objects'. Replace Objects.equals() with direct null-safe comparison or use .equals() method on the key objects.

@Override
public void put(K key, V value) {
for (int i = 0; i < size; i++) {
if (Objects.equals(this.key[i], key)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #5 states 'Don't create repeating code'. The key comparison logic in put() and get() methods follows the same pattern. Extract this into a private helper method (e.g., findKeyIndex()) that returns the index of a key or -1 if not found.

Comment on lines +36 to +38
public V get(K key) {
for (int i = 0; i < size; i++) {
if (Objects.equals(this.key[i], key)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #5: Same repeating pattern issue as line 21. The key search loop exists in both put() and get() methods.

Comment on lines +8 to +9
private K [] key;
private V [] value;
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 variable names 'key' and 'value' (lines 8-9) are not informative. Consider using plural forms like 'keys' and 'values' since they store multiple elements.

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

Your implementation is now complete and meets all requirements. The code properly handles key-value storage using arrays with generics, correctly replaces values for duplicate keys, enforces the 10-element capacity limit via MAX_CAPACITY, and implements all required methods (put, get, size). The previous issues have been successfully resolved: direct null-safe comparison is used instead of Objects.equals(), and the duplicate key-search logic is cleanly extracted into the findIndex() helper method. All non-constant fields are properly initialized in the constructor. Great work on addressing all the feedback and producing clean, well-structured code!


✨ 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