-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr-7 #7
base: master
Are you sure you want to change the base?
Pr-7 #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename the variable names to be more descriptive and maybe refactor?
@@ -0,0 +1,34 @@ | |||
|
|||
class Node { | |||
constructor(value, next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we used a default null
value for the next
property?
} | ||
|
||
getNext() { | ||
return this.next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there ever be a situation where this would be called and there is no next value?
@@ -0,0 +1,34 @@ | |||
|
|||
class Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add context here to explain what this Node class is supposed to do? Looks like a linked list to me, but some context might be helpful for others!
} | ||
} | ||
|
||
export default Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THIS IS HIDEOUS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THIS.UGLY = YOU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Ugliness is in the eye of the beholder"
@@ -0,0 +1,34 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a default value need to be declared for value and next in the constructor?
|
||
class Node { | ||
constructor(value, next) { | ||
this.value = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does 'this' refer to exactly? Is it an instance of the Node class?
constructor(value, next) { | ||
this.value = value; | ||
this.next = next; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using "value" and "next" in conjunction with "this" seems confusing from a readability standpoint. what is this.next referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we look at this together in understanding this portion of the code and if we can concise this with other lines above?
return this.value; | ||
} | ||
|
||
setValue(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we review this as being necessary or if it can be more concise?
@@ -0,0 +1,34 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a Docstring/comment on the class.
It seems to me that the class Node is part of the implementation of a linked list, it would be nice to not have to read all the code to get to know that.
@@ -0,0 +1,34 @@ | |||
|
|||
class Node { | |||
constructor(value, next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding comments on these variables, what sort of thing you expect a value to be? What sort of thing you expect next to be?
this.value = value; | ||
} | ||
|
||
printList() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printList will print all values from the node "this", onwards. If "this" is not the root of the linked list, It won't print the whole list. Is this the expected behavior?
@@ -0,0 +1,34 @@ | |||
|
|||
class Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this constructor? What is value and what is next? Should we have more specific naming here?
return this.next; | ||
} | ||
|
||
setNext(next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain to me what the difference between setNext and setValue will be in the overall code?
this.next = next; | ||
} | ||
|
||
getValue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain to me which value this function will 'get'? In other words, how is the value being searched and retrieved here?
} | ||
} | ||
|
||
export default Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks really great, there are just a few things that I would appreciate some clarity on, thank you!
constructor(value, next) { | ||
this.value = value; | ||
this.next = next; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice closing curly brace!
while (current != null) { | ||
console.log(current.value); | ||
current = current.getNext(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great loop!
return this.value; | ||
} | ||
|
||
setValue(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just practicing writing comments here, lol
@@ -0,0 +1,34 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a test
setNext(next) { | ||
this.next = next; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testing, lolz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, but maybe ask someone who knows linked lists already.
@@ -0,0 +1,34 @@ | |||
|
|||
class Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dittoing on the above. This is a practice post
No description provided.