Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Strangely enough, this is still downvoted (while being quite correct) ;) To add, one can expose even the (interrelated) internals of a class' instance, if he obliges the user of the class to maintain respective relationships "by hand" -- it's nothing (conceptually or practically) wrong with having such a contract. But if the object can fulfill the same role with less being known about its proper usage (i.e. conforming to a "smaller" contract), that makes it possible to change the internals w/o changing the client code. That's one thing about encapsulation. Commented Jun 3, 2012 at 8:03
  • Another thing is, using several objects together is plain easier when their contracts are more compact -- since the (conceptual) complexity of the code is a "multiplication" of the complexities of those contracts. Of course, in each context there is a limit on "encapsulation level" of the objects involved -- you must still be able to fulfill the given task in the client code, or the (perfectly encapsulated) objects/classes used are ..useless. Commented Jun 3, 2012 at 8:09