-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Added root parameter #137
Added root parameter #137
Conversation
I don't really think this is the way to fix this problem, it's not very idiomatic C# code. You could just get rid of the Node class and move its two properties to Tree (and make them private). That way you don't have to create dummy nodes in advance. |
May be do that for the full example but I think that It's more comprehensive for the website which shows functions 1 by 1. |
I disagree, every language should implement the algorithms in a way that's idiomatic for that specific language. For example you won't see parallels between the C and Haskell implementations (and you really shouldn't). |
The problem is that if we do what you said, on the website a method like |
I still disagree. If anyone wonders where |
I think that the users reading this book should understand how it works directly without having to check the full code ! Using |
@Gustorn We could maybe move |
The thing is you don't want the root parameter. It makes no sense to have it (and as I said, you don't really need the |
If think it makes more sense to have a node parameter than a root node variable. |
You don't need a root node variable. public class Tree {
public int Value { get; set; }
private List<Tree> _children;
} |
@Gustorn you're right, your solution is maybe even better. But I would name the class still |
Aside from that, with a |
It's after all (like Buttercak3 mentioned in #141) a learning book & not a library. |
I'll obviously vote for my solution :) My argument for keeping the name But that particular detail is pretty inconsequential, I'm fine with either |
I have an other solution which is made just of one 'code' (basically two file but that's because of the language) in Java for this example. The root parameter is a variable in the class himself but is also passed as a parameter to a specific function. Look at the issue #149 and tell me what do you think of that ! |
@xam4lor Ok, but why should we have the parameter, if the root is already in the class & public? That doesn't make much sense to me. Either one or the other I would say. |
Added root parameter instead of having a global variable. @see #134.