Encapsulation
Explore how encapsulation works in Perl using Moose to declare and protect class attributes. Understand how internal details of objects are hidden while maintaining consistent usage, improving code maintainability and flexibility. Learn to set default values and manage object construction with Moose.
We'll cover the following...
We'll cover the following...
Overview
Moose allows us to declare which attributes class instances possess (for example, a cat has a name), as well as the attributes of those attributes (we can name a cat once and thereafter its name can’t change). Moose itself decides how to store those attributes—we access them through accessors). This is encapsulation: ...