How can I prevent other programmers from violating
encapsulation by seeing the private parts of my class?



How can I prevent other programmers from violating encapsulation by seeing the private parts of my ..

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

Post New Answer

More C Interview Questions

What is this pointer in c plus plus?

0 Answers  


What are .h files and what should I put in them?

3 Answers  


Is main an identifier in c?

0 Answers  


What are comments and how do you insert it in a C program?

0 Answers  


Write a program to find the biggest number of three numbers in c?

0 Answers  






How do you construct an increment statement or decrement statement in C?

0 Answers  


How to print "I Love My India" without using semi colon?

4 Answers  


What does c mean before a date?

0 Answers  


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

0 Answers  


Do you know what is a programing language ?

0 Answers  


Explain how can I convert a number to a string?

0 Answers  


how to implement stack work as a queue?

2 Answers  


Categories