Content deleted Content added
No edit summary |
m added a wiki link for reflection |
||
Line 17:
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 supposed benefit of encapsulation is that it can reduce system complexity, and thus increase [[robustness (computer science)|robustness]], by allowing the developer to limit the inter-dependencies between software components{{Citation needed|date=April 2014}}.
Almost always, there is a way to override such protection – usually via [[Reflection_(computer_programming)|reflection]] API (Ruby, Java, C#, etc.), sometimes by mechanism like [[name mangling]] ([[Python (programming language)|Python]]), or special keyword usage like <code>friend</code> in C++.
Below is an example in [[C Sharp (programming language)|C#]] that shows how access to a data field can be restricted through the use of a <code>private</code> keyword:
|