Content deleted Content added
m Reverted edits by 89.28.143.182 (talk) to last version by 134.191.220.72 |
|||
Line 18:
== An information-hiding mechanism ==
{{See also|Information hiding}}
{{em| Encapsulation can be used to hide data members and members function.}} Under this definition, encapsulation means that the internal representation of an [[object (computer science)|object]] is generally hidden from view outside of the object's definition. Typically, only the object's own methods can directly inspect or manipulate its fields. Some languages like [[Smalltalk]] and [[Ruby (programming language)|Ruby]] only allow access via object methods, but most others (e.g. [[C++]], [[C Sharp (programming language)|C#]], [[Delphi (programming language)|Delphi]] or [[Java (programming language)|Java]]) offer the programmer a degree of control over what is hidden, typically via keywords like <code>public</code> and <code>private</code>.<ref name=Pierce/>
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}}.
Line 161:
{ ... }
</source>
== Encapsulation and Inheritance ==
|