Java: To what extent should we encapsulate our methods and classes? <p>To what extent should we encapsulate our methods and classes? for example, besides getter and setter, what else non-static methods should be declared as public?</p> <p>And if we declared too many private methods, how can we conduct the unit tests for them?</p> <p>I heard a saying that "if your private method is so complex that it needs a separate unit test, it often means that it deserved its own class", so how can we decide if a method is complex enough to have a separate unit test? (for example, for methods like getter/setter we do not need to test them right)</p>