Add storage impl#1917
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| private K[] keys = (K[]) new Object[10]; | ||
| private V[] values = (V[]) new Object[10]; | ||
| private int size = 0; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
Checklist item #3: Magic number 10 should use the MAX_SIZE constant. Replace new Object[10] with new Object[MAX_SIZE].
| if (getIndex(key) >= 0) { | ||
| values[getIndex(key)] = value; |
There was a problem hiding this comment.
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.
No description provided.