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 Encapsulation with Properties Computed Properties

I feel this course is moving way too fast...

I have been doing this C# course for about a week now and it's taken me an extremely large amount of time to absorb and understand the concepts of the language that other people seem to get right away the first time. I am never able to complete the challenges myself and always end up having to Google the answers... Is there any possible way I can get more examples and explanations of properties and accessor methods? C# seems like a fun language when you understand it but its becoming all very intimidating and even at some points, frustrating.

Phillip Kerman
Phillip Kerman
Courses Plus Student 285 Points

Generally, I'd suggest not to apply a measurement on yourself (like expecting things to click in x number of hours). I'll often sit down to take on a task I think "should" take 20 minutes only to look up at the clock 4 hours later and feel like I've made no progress. Mixing things up and looking at the same topic from different perspectives can help. Perhaps just read a few online discussions of the topic from other languages (properties and methods to access them is not a topic unique to C#... I'd suspect you can find a ton of stuff for Java).

Using a forum like this is a great way to... so you're doing that. Trying to answer other people's questions is also a great way to solidify what you're learning.

Let me take a quick stab at this one:

object properties are "state" that are tied to individual instances. If you had two boxes on screen, each might have a their own "x" property and "y" property. While each box has an x and a y, the specific value for each one is independent... it's part of the particular instances state.

The idea of accessor methods is that instead of just letting the property be accessed directly, you let the property be accessed, but only via a method. This lets you have more control over what's going on. For example, you might want to let (code in a different part of your app) change a box's x and y. But, instead just letting code change the x and y directly, you force it through a method. That way, you get as many lines of code as you want to ensure things go like you want. For example--say the code wants to set the x to -1000 but you want to limit it so it never goes below 0. By channeling any such code through a method, you can do a simple conditional or whatever to make sure it never goes below 0. Accessor methods just let you define how (code from other parts of your app) can get/set properties.

The control isn't only for "preventing bad things" like my example above. Maybe, when you set the x or y, you want to follow that up with actually changing something visual on the screen. This way, you don't just have a property for x and y that holds a number, but you perform some additional code any time your code wants to modify the property.

Finally, realize accessor methods are useful for "get" operations as well. Say you want a "full name" property. But, you designed your class to have a firstName and a lastName? Just make a getter that, when accessing the "full name" you concatenate those two properties and return that.

HTH

11 Answers

Bonnie Edens
Bonnie Edens
1,214 Points

Hi Cole,

I feel exactly the same so I'm glad to read your thread! Even if I can fix the code on my own, I have no idea what I'm doing most of the times, I just copy the video. How are you doing now, did you make more progress?

I agree on what Phillip says; I've been doing a few different courses at the same time, and I see the same topics in every course. Often in another order and with a somewhat different approach. That can help me to really understand something.

However, I understand very little so far. I just go through this course in the hope of understanding it in a later stage. I hope I'm not a hopeless case.. :-|

I hope you're doing ok by now!

James Churchill
STAFF
James Churchill
Treehouse Teacher

Cole,

I'll echo what Phillip (hi Phillip!) said above in his response... everyone learns at their own pace, so don't worry about how long something takes you to learn.

Rewatching videos, after you've had time to think about the material, can help you to gain a deeper understanding. Also, one of the best ways to learn how to code, is to spend time reading and writing code. This can seem like an obvious thing, but don't discount spending time reading someone else's code. A great way to do that is to try and answer questions on this community. And don't forget to just spend time writing code and experimenting with the C# language. Write a simple app... make it work... try a different approach... intentionally break it... then fix it.

Most of all... stick with it. You'll get there!

I hope this helps.

Thanks ~James

jordan weitz
jordan weitz
1,431 Points

Man I'm right where y'all are. I felt like there was wayyyy more review questions early on compared to where the course is at this video. We are doing more sophisticated concepts now but there are maybe 1 or 2 questions between each video. There used to be like 4 or 5 that were situated around maybe 3 different concepts but now they are throwing definitions at us like candy and only giving us one or two review questions. I feel like the later stage of this course was rushed a bit. Fields, Properties, Methods, Classes, Accessors etc. These names all seem interchangeable and the differences between them are negligible. I feel confused :/

Bonnie Edens
Bonnie Edens
1,214 Points

So, here I am again, quite some months later. In the mean time, I've had a course of a few weeks, read the C# exam book and I am now waiting for a job which should be arranged by my employment agency, but I've been waiting for 2 months now. So, I'm back to Treehouse. Now everything makes sense and is actually easy. But now I also understand why I had no idea what I was doing the previous time. In my opinion, not all topics aren't explained very well.. If I should explain these things to a beginner, I would leave some unnecessary vague things out, and add other helpful information. Sometimes I miss information about what we are actually doing in the videos. Maybe this works for some people, but clearly not for everyone. Long story short: don't worry if you don't get it yet. You will be fine!! :)

PS: I recommend doing more than one course at the same time. They all explain things a little different so this might help.

Yea I can confirm the c# classes move way too fast on treehouse. One thing they should do is actually teach the basics with some .NET already established classes that have documentation and what not. It makes it extremely hard to follow when everything that is used is a self created class. This is actually at the point where I think they should redo many of these.

Shaun Barbour
PLUS
Shaun Barbour
Courses Plus Student 1,907 Points

I agree with Cole. Early in the course, everything was explained well. The pace was perfect. Not only was "what we were doing" and "how to do it" explained well, but "why we were doing it" was very clear. That approach went a long way in helping our minds learn how to think about programming and how a computer thinks.

Now... "what" is mentioned quickly, but not explained well, and "why" is completely unknown most of the time. Stuff is being thrown at us at such a rapid pace with little explanation. All I'm doing now is just copying what is written in the video with no understanding as to why I'm doing what I'm doing. I don't feel like I'm learning anymore.

I agree with the comments above. I was at a point where I almost felt like dumping this course completely because I felt it was too fast paced. The game in my opinion is not the most effective way to start teaching a complete beginner how to program. There are a several unknown terms being thrown around and a single video a can pack a whole lot of information that would take someone with no experience whatsoever a couple of days to decipher and properly understand. I have now changed strategies and I am working to get through the course as fast as I can and then I will go over two C# books I purchased recently. Personally, books and interactive programming work better for me than just watching videos. Going through this course will certainly help you grasp the basic concepts of OOP and how things work on a higher level. However, use different resources and learning methods to make sure you can become decent at programming afterwards.

Yeah, I would agree that the game example is a little abstract and ill-suited to teaching the concepts covered here.

Perhaps the most frustrating part is that the program we've created does absolutely nothing right now! Lots of stuff happening in the background, but in terms of actions when run — it does zero.

I think this is one of the biggest failings: a lack of being able to see our progress in action in any tangible way.

Having said that, I strongly prefer this course over the robotic teaching over at Pluralsight — frankly Jeremy's a lot more pleasant and relatable. And I do feel like I'm learning well, but I take notes on literally everything so perhaps that's helping. It gives me my own personal reference to look back on when details get hazy.

Thank you for your very intense response haha

Richard Külling
Richard Külling
9,465 Points

Guys, the course needs to be good for both experienced programmers learning C# as a new language and entirely new programmers learning C# as a first language. If you take a week, googling every question and watching every video twice on slo-mo, I'd say that's fine, that's they way you learn best: putting in effort to follow all the essentials of this language. A tip that might let you go faster: don't try to grasp why he programs this game the way he does just yet, only make sure you follow along and get why it works. Once you get to program something by yourself, you'll find out why it makes sense this way, but also that there's multiple ways to solve a problem. As long as you are matching pieces of a puzzle, it doesn't matter where you start nor where you finish, you'll always solve it in the end. That's how learning works. Keep going!

A beginners course should be for beginners. A course for experienced programmers should not be part of the beginners series.

It's also very difficult for neurodivergent people like myself to get why it works without understanding why what is being done is being done. Without understanding the process, we're lost.

Food for thought.

Stephen Cole
PLUS
Stephen Cole
Courses Plus Student 15,809 Points

Years later, I have to say I agree. As I try to follow along on my own (on my own computer and not in a workspace) after the last couple of lectures, the changes do not compile.

At the end of this lecture, for example, there are these three:

Game.cs(32,39): error CS7036: There is no argument given that corresponds to the required formal parameter 'path' of 'Invader.Invader(Path)'
Game.cs(40,17): error CS0272: The property or indexer 'Invader.Location' cannot be used in this context because the set accessor is inaccessible
Invader.cs(7,31): warning CS0649: Field 'Invader._path' is never assigned to, and will always have its default value null

The code is not wrong. It's incomplete.

While I like the presentation, overall, slowing down and compiling more would be a big help.

Right there with you. I have a friend who is an experienced C# coder helping teach me, and he's looked at a few of the "objectives" parts and said even he'd have trouble with them. A little more thought into what it actually means to be a beginner should have gone into this series.