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 trialTizmiz Tizzer
1,040 PointsWhys is it a good reason to encapsulate this data and make it a path object?
Whys is it a good reason to encapsulate this data and make it a path object rather than just keeping it as a nonencapsulated array? I'm looking a both version of the code and I feel like we just hid information that didn't have any reason to be hidden?
1 Answer
Jon Wood
9,884 PointsThat's good encapsulation if you feel it hides implementation from you. :p
This is a good Microsoft blog post on it for further and more detailed info.
Basically, it keeps methods, fields, and other members of a class "hidden" (or private) so, if someone is using the class, they can't call anything on the class that can cause negative affects to how the rest of the code runs.
Hope that helps, but let me know if you need more information.
Tizmiz Tizzer
1,040 PointsTizmiz Tizzer
1,040 PointsSo this is pretty much good practice if someone other than yourself is going to be using your code? If that is the case it would make more sense. I just feel as if on such a small scaled project like this it isn't that important especially if it's just you using the code.
Christopher Debove
Courses Plus Student 18,373 PointsChristopher Debove
Courses Plus Student 18,373 PointsIt's mainly for best practices and didactic purposes that it's done on a small project like this =)