Content deleted Content added
→History: date for oberon |
→Objects: copy intro from Object (computer science) |
||
Line 87:
===Objects===
{{Main|Object (computer science)}}
An object is a [[data structure]] or [[abstract data type]] containing [[Field (computer science)|fields]] (state [[variable (computer science)|variable]]s containing data) and [[Method (computer programming)|method]]s ([[subroutine]]s or procedures defining the object's behavior in code). Fields may also be known as members, attributes, or properties. Objects are typically stored as contiguous regions of [[Memory address|memory]]. Objects are accessed somewhat like variables with complex internal structures, and in many languages are effectively [[Pointer (computer programming)|pointers]], serving as actual references to a single instance of said object in memory within a heap or stack.
Objects sometimes correspond to things found in the real world.<ref>{{cite book|last=Booch|first=Grady|title=Software Engineering with Ada|year=1986|publisher=Addison Wesley|isbn=978-0-8053-0608-8|page=220|url=https://en.wikiquote.org/wiki/Grady_Booch|quote=Perhaps the greatest strength of an object-oriented approach to development is that it offers a mechanism that captures a model of the real world.}}</ref> For example, a graphics program may have objects such as "circle", "square", and "menu". An online shopping system might have objects such as "shopping cart", "customer", and "product". Sometimes objects represent more abstract entities, like an object that represents an open file, or an object that provides the service of translating measurements from U.S. customary to metric.
Objects can contain other objects in their instance variables; this is known as [[object composition]]. For example, an object in the Employee class might contain (either directly or through a pointer) an object in the Address class, in addition to its own instance variables like "first_name" and "position". Object composition is used to represent "has-a" relationships: every employee has an address, so every Employee object has access to a place to store an Address object (either directly embedded within itself or at a separate ___location addressed via a pointer). Date and Darwen have proposed a theoretical foundation that uses OOP as a kind of customizable [[data type|type system]] to support [[RDBMS]], but it forbids object pointers.<ref name="ThirdManifesto">C. J. Date, Hugh Darwen. ''Foundation for Future Database Systems: The Third Manifesto'' (2nd Edition)</ref>
|