We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Not Security

Encapsulation is all about making code easy to work with by "hiding" complicated code within a "black box". It makes it so that we don't have to worry about details of how a function or method works... we just use it.

It's kinda like how the inner workings of your car's power steering are hidden from you. You don't need to be an expert on hydraulic systems to turn the wheel from side to side.

Let me say this next part loud and clear:

Encapsulation and the concepts of private and public members have NOTHING to do with security. This really confused me as a new developer. Just as the casing on your computer hides its inner workings but doesn't stop you from opening the case and looking inside, encapsulation doesn't stop anyone from knowing how your code works, it just puts it all in one easy to find place.

Encapsulation is about organization, not security.

Encapsulation is like storing folders in an unlocked filing cabinet. The cabinet doesn't stop anyone from peeking inside, but it does keep everything tidy and easy to find.