4. Object Structures, Aliasing, and Encapsulation
4. Object Structures, Aliasing, and Encapsulation
4. Object Structures, Aliasing, and Encapsulation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Alias control <strong>and</strong> encapsulation techniques areanother approach to reduce aliasing problems:1. Side-effects are simpler to control.2. Consistent access to objects can be achieved.3. By-passing of interface operations can be avoidedOverview:• Notions of alias control• Type-based encapsulation<strong>4.</strong>3.1 Notions of Alias ControlWe need better control over the objects in an objectstructure to avoid aliasing problems.Approach: Alias modes:- Define roles of objects in object structures- Assign a tag (alias mode) to every expression to indicatethe role of the referenced object- Impose programming rules to guarantee that objects areonly used according to their alias modes13.05.13© A. Poetzsch-Heffter, TU Kaiserslautern20