Content deleted Content added
Montrose64 (talk | contribs) m The portions that I deleted were plain wrong: abstract data type is about the behavior of a computational structure (call it a class, if you will), such as dynamic dispatch, but not about its implementation. There is no restriction on the type of behavior (i.e., operations) that an ADT can define. ADT is defined as a set of operations on a set of objects. ADT is also called a class. (see Aho & Ullman, Foundations of Computer Science, 1992, p. 250) |
→Encapsulation: Remove misinformation. |
||
Line 194:
===Encapsulation===
Encapsulation is
If a class does not allow calling code to access internal object data and permits access through methods only, this is a strong form of abstraction or information hiding known as [[Encapsulation (object-oriented programming)|encapsulation]]. Some languages (Java, for example) let classes enforce access restrictions explicitly, for example denoting internal data with the <code>private</code> keyword and designating methods intended for use by code outside the class with the <code>public</code> keyword. Methods may also be designed public, private, or intermediate levels such as <code>protected</code> (which allows access from the same class and its subclasses, but not objects of a different class). In other languages (like Python) this is enforced only by convention (for example, <code>private</code> methods may have names that start with an [[underscore]]). Encapsulation prevents external code from being concerned with the internal workings of an object. This facilitates [[code refactoring]], for example allowing the author of the class to change how objects of that class represent their data internally without changing any external code (as long as "public" method calls work the same way). It also encourages programmers to put all the code that is concerned with a certain set of data in the same class, which organizes it for easy comprehension by other programmers. Encapsulation is a technique that encourages [[Coupling (computer programming)|decoupling]].
|