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 MAXIMUM SIZE OF AN ARRAY IN C LANGUAGE?

8 Answers   Carphone Warehouse, IBM, SAS,


What is the method to save data in stack data structure type?

0 Answers  


proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?

7 Answers   Hughes,


What are valid operations on pointers?

0 Answers  


Find the O/p of the following 1) #include int main() { char c='1'; int j=atoi(c); }

4 Answers   Subex,






What are operators in c?

0 Answers  


difference between malloc and calloc

3 Answers   HCL, Wipro,


WHAT IS HIGH LEVEL LANGUAGE?

2 Answers  


Please list all the unary and binary operators in C.

3 Answers  


What is "Duff's Device"?

0 Answers   Celstream,


4)What would be the output? main() { int num=425; pf("%d",pf("%d",num)); } a)Comp error b)4425 c)4253 d)3435 e)none

10 Answers  


Can u please send me the exam pattern and also Previous papers to javed123go@gmail.com

0 Answers  


Categories