In its simplest embodiment, an object is an allocated region of storage. An object is sometimes called a member* Since programming languages use variables to access objects, the terms object and variable are often used interchangeably. However, until memory is allocated, an object does not exist.
All programming languages present objects. The presence of objects should not be confounded with the concept of object-orientation.
In procedural programming, an object may contain data or instructions, but not both. (Instructions may take the form of a procedure or function). In object-oriented programming, an object may be associated with both the data and the instructions that operate on that data.
When observing real-world objects (a basketball, tuna fish, phone, etc), two distinct characteristics are common:stateandbehavior. The state of an object describes properties of the object; a basketball has radius, pressure, flat, bouncing, etc. The behavior of an object describes what actions the object can perform. When observing real-world objects, one should ask "What possible states this object be in?" and "What possible behavior can this object perform?".
In comparison, a software object is similar to a real-world object. In terms of Java, states of an object are stored infields(similar to variables in other languages) and behaviors of an object are defined bymethods(similar to function in other languages). By using methods, objects communicate state with one another. In order to achieve data encapsulation, an object must hide its state from other objects by limiting access through only using its behaviors.
When defining procedures was first introduced in the 1960s, creating reusable code is a coveted goal in programming. Objects are distinct units of code. Specifically, Oracle lists the benefits of using objects as units of code include:
- Modularity: code can be maintained independently of other source code
- Information-hiding: specific implementations are unknown from the outside world
- Code reuse: code already implemented, tested, and case-specific may be used within another program
- Pluggability and debugging ease: problems can be traced to specific instances of code and may be replaced with another object
See Also Edit
*I think so. Find Out!
|This page uses content from Wikipedia. The original article was at Object (computer science). The list of authors can be seen in the page history. As with Java Wiki, the text of Wikipedia is available under the GNU Free Documentation License.|
<ref>tags exist, but no
<references/>tag was found