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

Pr-7 #7

wants to merge 1 commit into from

Conversation

CheezItMan
Copy link

No description provided.

@CheezItMan CheezItMan changed the title Node class Pr-7 Aug 30, 2021
Copy link

@maria-im015 maria-im015 left a 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) {
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?

}

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?

@@ -0,0 +1,34 @@

class Node {

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;

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"

@@ -0,0 +1,34 @@

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

constructor(value, next) {
this.value = value;
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?

Copy link

@ktiktok96 ktiktok96 left a 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) {

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

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) {

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() {

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 {

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) {

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() {

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;

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

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

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) {

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

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

Choose a reason for hiding this comment

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

More testing, lolz

Copy link

@Parseluni Parseluni left a 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 {
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

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.