Object-oriented programming: Difference between revisions

Content deleted Content added
Undid revision 1185215634 by 42.118.39.58 (talk)
Data abstraction: The added line emphasizes the significance of abstraction in programming languages, especially within the context of object-oriented languages.
Line 164:
 
If a class does not allow calling code to access internal object data and permits access through methods only, this is a form of information hiding known as [[Abstraction (computer science)|abstraction]]. 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.{{sfn|Bloch|2018|loc=Chapter §4 Item15 Minimize the accessibility of classes and members|pp=73-77}} 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).{{sfn|Bloch|2018|loc=Chapter §4 Item15 Minimize the accessibility of classes and members|pp=73-77}} 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]]). In C#, Swift & Kotlin languages, <code>internal</code> keyword permits access only to files present in same assembly, package or module as that of the class.<ref>{{Cite web |date=2023-01-05 |title=What is Object Oriented Programming (OOP) In Simple Words? – Software Geek Bytes |url=https://softwaregeekbytes.com/object-oriented-programming-simple-words/ |access-date=2023-01-17 |language=en-US}}</ref>
 
In programming languages, particularly object-oriented ones, the emphasis on abstraction is vital. Object-oriented languages extend the notion of type to incorporate data abstraction, highlighting the significance of restricting access to internal data through methods.<ref>{{Cite journal |last=Cardelli |first=Luca |last2=Wegner |first2=Peter |date=1985-12-10 |title=On understanding types, data abstraction, and polymorphism |url=https://dl.acm.org/doi/10.1145/6041.6042 |journal=ACM Computing Surveys |language=en |volume=17 |issue=4 |pages=471–523 |doi=10.1145/6041.6042 |issn=0360-0300}}</ref>
 
===Encapsulation===