How can I prevent other programmers from violating
encapsulation by seeing the private parts of my class?
Answer Posted / 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 View All Answers
Why does this code crash?
Write a program to print numbers from 1 to 100 without using loop in c?
What is the difference between void main and main in c?
What is strcmp in c?
What is meant by errors and debugging?
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
How do I convert a string to all upper or lower case?
What is this pointer in c plus plus?
Explain how can I prevent another program from modifying part of a file that I am modifying?
How can I recover the file name given an open stream or file descriptor?
What are the 5 types of inheritance in c ++?
cavium networks written test pattern ..
What is the difference between array and structure in c?
What is meant by preprocessor in c?
What is the data segment that is followed by c?