Controlling Visibility

Programming Crystal — by Ivo Balbaert, Simon St. Laurent (66 / 125)

👈 Applying Inheritance | TOC | Working with Structs 👉

Objects that are visible can be read or even changed through external code, which is a common cause of bugs and surprises. Restricting this visibility, encapsulating your code, is very common in object-oriented languages.

It all centers around the concept of a namespace in code — an area in the code that’s defined by a name. A class is a simple example: everything inside…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
The Pragmatic Programmers

The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.