Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Shadab Khan5,470 Points
Question regarding Path class encapsulation
Hi, I understand Jeremy's explanation on how encapsulation can foolproof the consumers of a class should the class creator decide to use another form of an array (List for e.g.) instead of simple arrays in the future. However, what happens to the existing consumers of the class in that case ? Won't their code break in case they're still passing an 'array' of path to perform path operations. How will a List cater for an array in that case then ?
Steven Parker212,126 Points
If backwards compatibility is an issue, the implementer should leave the original method and create the new one as an overload (same name, different argument(s)).
Optionally, the body of the original method can be modified to perform any necessary conversions and then call the new method.