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
  • While the Wikipedia article mentions both uses for encapsulation, the rest of the article is entirely about the first. I've always found the primary benefit from encapsulation in this paragraph: Hiding the internals of the object protects its integrity by preventing users from setting the internal data of the component into an invalid or inconsistent state. A benefit of encapsulation is that it can reduce system complexity, and thus increases robustness, by allowing the developer to limit the inter-dependencies between software components. How do you reconcile this to your answer? Commented Feb 15, 2014 at 18:16
  • @davidkennedy85: which part? Private to avoid invalid state? If they want to create an invalid state, they probably can. Reducing system complexity is generally beneficial, but not a goal in and of itself. Commented Feb 16, 2014 at 6:51