Skip to content

Finish README task#1697

Open
melnyk317 wants to merge 1 commit into
mate-academy:masterfrom
melnyk317:hw16
Open

Finish README task#1697
melnyk317 wants to merge 1 commit into
mate-academy:masterfrom
melnyk317:hw16

Conversation

@melnyk317

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

Your solution is approved as part of an educational override so you can continue progressing while you practice the remaining style details. Functionally, your MyHashMap looks solid: put, getValue, getSize, initial capacity, load factor, and resize logic are all implemented correctly, and your inner Entry<K, V> class is properly parameterized and kept simple without getters/setters. One point to improve is the use of generics: in your put method where you create new entries (e.g., new Entry<K, V>(key, value)), you should prefer the diamond operator new Entry<>(key, value) to reduce verbosity and follow the generics guideline [CHECKLIST ITEM #8]. Another stylistic issue is in your resize() method, where you double the capacity using a hardcoded 2 (e.g., capacity *= 2;); this should be extracted into a named constant like RESIZE_FACTOR to avoid magic numbers and make the intent clearer [CHECKLIST ITEM #2]. These are not functional bugs, but addressing them will make your code more maintainable and closer to production-quality standards. Overall, you did well on the core logic and structure of the hash map; tightening up these small style points will further improve your code quality.


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

Footnotes

  1. Rate AI review example

if (size >= threshold) {
table = resize();
}
Entry<K, V> toPut = new Entry<K, V>(key, 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.

"Diamond operator\nBe attentive with the diamond operator in java. \nWhat is the difference between: new Node<>(...) and new Node<K,V>(...)and new Node(...). Read more about it" — You're instantiating the entry with explicit type arguments: new Entry<K, V>(key, value) (line shows this). Consider using the diamond operator: new Entry<>(key, value) to avoid redundancy and follow the checklist guidance.


private Entry<K, V>[] resize() {
size = 0;
capacity *= 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"Any magic numbers should be constants\nYour code should be easy to read. Move all hardcoded values to constant fields and give them informative names. For example: constants can be defaultCapacity, loadFactor..." — In resize() you use the literal 2 to double capacity (capacity *= 2;). Consider extracting this as a named constant (for example GROWTH_FACTOR or RESIZE_MULTIPLIER) to satisfy the magic-number guideline.

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