I am working in an OO-Environment and am just having conceptual discussions with colleagues. Suppose you have two classes ("A
" and "B
") with no common ancestors, and B needs to access information from A
. It can do that via fields or getters. The dilemma is that these would have to be declared "public" and consequently be visible to the whole world. Since "private" visibility is not possible (completely different positions in the class-tree due to different purposes), they have been implemented as public.
But I'm wondering if there is a concept (in any OO-Language) which would allow to control that these fields should only be visible to B
and noone else?