Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Loops and Final Touches Foreach Loops

Yiqiu Li
Yiqiu Li
11,619 Points

Very confusing structure

For someone who has had no experience with C# previously, this project is quite different to follow. There are way too many jumping around classes with no detailed explanation.

For example I only just realised the overload DistanceTo method in the Point class is created because of this isInRange method, and this was myth to me before this point. Why cant you create the DistanceTo method in this video when we actually needed it?

Also the interlinks between classes are not explained at all, some sort of high level UML would be very helpful for beginners to understand the whole structure of the project, because again, it is very difficult to follow.

2 Answers

Angel Smith
Angel Smith
1,590 Points

I think he is doing it this way because this is how you would go about it while creating your own, real world projects. There is no set order in which to write the methods, properties, etc. in your own projects because you'll always think of something you need later down the road, which will require jumping around the classes. And since as beginners, we aren't really used to project flow, it's harder for us to remember what was done in previous episodes.

Plus, I believe he is also jumping between things to cover different topics. If he did it all based on what he felt he would write first, we'd cover topics that we aren't ready for yet. The DistanceTo (if I remember correctly) was to show us that we can write methods with the same name but with different parameters, and also how to return in those methods. The InRangeOf is being written now because we only need it in this foreach loop, which would have confused us earlier on.

I think these tracks to start off are mostly just teaching us the syntax, so we know how to implement it later on in our own projects.

For following along the project itself, I have found leaving comments to remind myself where a certain segment of code connects in another class is helpful.

For example, where we used the IsInRangeOf in the if statement, you can write a comment reminding yourself that it returns the DistanceTo method in Point.

(remember, you can write comments in your code by typing //write your comment here)

I know it's easy to get lost when you're just starting out, but I highly recommend going back over the code to make sure you fully understand what is happening before moving onto the next video. I usually print out the code or write it in my notebook, and while I have downtime at work, I'll go over the code, highlighting where certain parts connect and writing what things mean.

Hope this gives you some ideas on how to make it work for you!

Umy Ikem
Umy Ikem
21,383 Points

I quite agree with Yiqiu Li on the overloaded DistanceTo() method, that's a confusing one for beginners. sure as hell confused me. i was wondering which video i missed but just realising i didn't miss any. I think that method should have at least being explained a little further and discussed when it was used.

Like Angel Smith says though , I think the teaching for now is just for us to really get the hand of the syntax. You can figure out your own logic when writing your programs.