5
votes
5answers
593 views

Should I always encapsulate an internal data structure entirely?

Please consider this class: class ClassA{ private Thing[] things; // stores data // stuff omitted public Thing[] getThings(){ return things; } } This class exposes the ...
0
votes
2answers
61 views

Is it 'safe' to expect myClasses to agree not to only call package Scope methods from other Package scope methods?

The questions says it all, but a quick overview of the situation. I'm creating a Model which contains classes (all inherriting myObject) which have a large amount of interconnection. I want the ...
4
votes
3answers
661 views

When too much encapsulation was reached

Recently, I read a lot of good articles about how to do good encapsulation. And when I say "good encapsulation", I am not talking about hiding private fields with public properties; I am talking about ...
1
vote
2answers
370 views

initial Class design: access modifiers and no-arg constructors

Context: Student working through Class design in personal/side project for Summer. I've never written anything implemented by others or had to maintain code. Trying to maximize encapsulation and ...
7
votes
6answers
3k views

Are Get-Set methods a violation of Encapsulation? [duplicate]

Possible Duplicate: When are Getters and Setters Justified In an Object oriented framework, one believes there must be strict encapsulation. Hence, internal variables are not to be exposed ...
6
votes
4answers
2k views

Is JavaBeans a good example of encapsulation?

I'm trying to understand if JavaBeans is a good example of encapsulation. In my view, it's not as usually all the internal state is exposed through getters and setters. A simple example is public ...