10 Scope your code with Access Modifiers
After reading this lesson, you will be able to:
- Make your values, variables, functions, and classes accessible only from their class
- Scope your code to a class and its subclasses
In lesson 9, you have learned about packages. Especially when creating external modules for third parties to use, you shouldn’t make every fragment of your code accessible. By protecting the access parts of your application, you reduce the entry points of your package, which makes it easier to use. By doing so, you can also prevent external manipulations that could expose sensitive data or introduce undesired behavior. In this lesson, you will learn about the Scala access modifiers, which are reserved keywords to change the visibility of your code elements. You should use them to protect and hide information that you should not expose to the public. In the capstone, you will use access modifiers to implement auxiliary functions that are accessible only from the class you declared them in.