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 trialAngel Smith
1,590 PointsSome more examples of encapsulation?
I've watched this video over and over, and I think I mostly grasp the concept, but does anyone have any other code (not analogy) examples of it? And maybe does someone have more of a definition of what it really means to encapsulate in code?
Thanks!
1 Answer
Steven Parker
231,269 PointsThe code for any class is an example of encapsulation, it doesn't need to be written any particular way. Encapsulation is simply grouping and/or concealment of process (such as methods) and possibly data (such as private fields).
A programmer using a class doesn't need to know how it works internally, only what it does and what input it requires.
Angel Smith
1,590 PointsAngel Smith
1,590 PointsThat makes so much sense now, thank you. I wasn't sure if it was a specific thing or not. Thank you!