Chapter5_1-ClassesAndObjectsInDepth

Encapsulation facilitates but does not guarantee

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: on that data in the same class • Information hiding is a design principle that strives to shield client classes from the internal workings of a class. • Encapsulation facilitates, but does not guarantee, information hiding. • Smearing the two into one concept prevents a clear understanding of either. Page 9 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP public and private modifiers • Let’s consider a class X. • Let’s consider Y a client class of X. • Y is a class that uses X. • Attributes (and methods) of X declared with the public modifier are accessible from instances of Y. • The public modifier does not guarantee the information hiding. • Attributes (and methods) of X declared with the private modifier are not accessible from instances of Y. • The private modifier guarantee the information hiding. Page 10 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Accessibility from Inside (the Instance itself) object:X public private - Accessible - Inaccessible All members of an instance are accessible from the instance itself. Page 11 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Accessibility from an Instance of another Class object:X Accessibilit...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online