How can I prevent other programmers from violating
encapsulation by seeing the private parts of my class?
Answer / abalonesoft
Not worth the effort — encapsulation is for code, not people.
It doesn't violate encapsulation for a programmer to see the
private and/or protected parts of your class, so long as
they don't write code that somehow depends on what they saw.
In other words, encapsulation doesn't prevent people from
knowing about the inside of a class; it prevents the code
they write from becoming dependent on the insides of the
class. Your company doesn't have to pay a "maintenance cost"
to maintain the gray matter between your ears; but it does
have to pay a maintenance cost to maintain the code that
comes out of your finger tips. What you know as a person
doesn't increase maintenance cost, provided the code you
write depends on the interface rather than the implementation.
Besides, this is rarely if ever a problem. I don't know any
programmers who have intentionally tried to access the
private parts of a class. "My recommendation in such cases
would be to change the programmer, not the code" [James
Kanze; used with permission].
| Is This Answer Correct ? | 0 Yes | 0 No |
Can a local variable be volatile in c?
for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????
write a program to swap two numbers without using temporary variable?
What is the use of a conditional inclusion statement in C?
how to find the binary of a number?
What library is sizeof in c?
Explain output of printf("Hello World"-'A'+'B'); ?
is assignment operator is arithmatic or not
How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.
why do we use # in c-language?
if p is a string contained in a string?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM