Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions print_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

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.

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?

Choose a reason for hiding this comment

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

This is a test

class Node {

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?

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!

Copy link

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

constructor(value, next) {
Copy link

@i-vs i-vs Sep 9, 2021

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?

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;
Copy link

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?

this.next = next;
}
Copy link

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?

Choose a reason for hiding this comment

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

Nice closing curly brace!


getNext() {
return this.next;

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?

}

setNext(next) {

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;
}

Choose a reason for hiding this comment

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

More testing, lolz

getValue() {

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?

return this.value;
}

setValue(value) {

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?

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

this.value = value;
}

printList() {

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?

let current = this;

while (current != null) {
console.log(current.value);
current = current.getNext();
}

Choose a reason for hiding this comment

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

Great loop!

}
}

export default Node;

Choose a reason for hiding this comment

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

THIS IS HIDEOUS

Choose a reason for hiding this comment

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

THIS.UGLY = YOU

Copy link

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"

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!