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

Android

gabriel wambua
gabriel wambua
5,061 Points

I did not understand why we had to separate the two model files i.e. page and choice.

Couldn't we have just put them together?

1 Answer

We separate the two model classes because of a fundamental object-oriented programming (OOP) concept called "encapsulation". Encapsulation is the process of bundling data with methods (functions) that perform operations on that data. Keeping one model separate from another not only keeps things tidy and easy to read and navigate but it also reduces unexpected results since the models are not modified externally.