Try our affiliated browser extension - redirect to BreezeWiki automatically!

Object

Object Concept

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.

How an object is created varies among language. In prototype-based languages (e.g., JavaScript) an object can be created from nothing, or can be based on an existing object. In class-based languages (e.g., Java), objects are derived from classes, which can be thought of as blueprints for constructing objects.

Characteristics

When observing real-world objects (a basketball, tuna fish, phone, etc), two distinct characteristics are common:stateandbehavior.[1] 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.[1] When observing real-world objects, one should ask "What possible states this object be in?" and "What possible behavior can this object perform?".[1]

In comparison, a software object is similar to a real-world object.[1] 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).[1] 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.[1]

Benefits

When defining procedures was first introduced in the 1960s[2], 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:[1]

  1. Modularity: code can be maintained independently of other source code
  2. Information-hiding: specific implementations are unknown from the outside world
  3. Code reuse: code already implemented, tested, and case-specific may be used within another program
  4. Pluggability and debugging ease: problems can be traced to specific instances of code and may be replaced with another object

See Also

Links

Wikipedia Definition

Java Sun Definition

Java Sample Codes

Notes

*I think so. Find Out!

Smallwikipedialogo.png 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.



JAVA RULES!

  1. 1.0 1.1 1.2 1.3 1.4 1.5 1.6 Oracle. "What Is an Object?". The Java Tutorials. Accessed 2014-10-21 16:17:00UTC
  2. Michael Stevens (2011). "Programming paradigms and an overview of C - COMP3610 - Principles of Programming Languages: Object-Oriented programming". Australian National University. p. 5. Archived from the original on 2011. Retrieved 2012-05-22. "Object oriented programming extends the concept of modularity by introducing objects"