Skip to content

Add storage impl#1917

Open
olegmak02 wants to merge 1 commit into
mate-academy:masterfrom
olegmak02:master
Open

Add storage impl#1917
olegmak02 wants to merge 1 commit into
mate-academy:masterfrom
olegmak02:master

Conversation

@olegmak02
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

The request meets the required criteria.


✨ 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 +8 to +10
private K[] keys = (K[]) new Object[10];
private V[] values = (V[]) new Object[10];
private int size = 0;
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 #2: All non-constant fields should be initialized in the constructor, not at declaration. Move keys, values, and size initialization to a constructor.


public class StorageImpl<K, V> implements Storage<K, V> {
private static final int MAX_SIZE = 10;
private K[] keys = (K[]) new Object[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.

Checklist item #3: Magic number 10 should use the MAX_SIZE constant. Replace new Object[10] with new Object[MAX_SIZE].

public class StorageImpl<K, V> implements Storage<K, V> {
private static final int MAX_SIZE = 10;
private K[] keys = (K[]) new Object[10];
private V[] values = (V[]) new Object[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.

Checklist item #3: Magic number 10 should use the MAX_SIZE constant. Replace new Object[10] with new Object[MAX_SIZE].

Comment on lines +14 to +15
if (getIndex(key) >= 0) {
values[getIndex(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.

Checklist item #4: getIndex(key) is called twice - once on line 14 for the condition and again on line 15 for assignment. Store the result in a variable to avoid repeating the method call.

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