Log in / create account | Login with OpenID
DocForge
Programmer's Wiki

Object oriented programming

From DocForge

Object-oriented programming is a style of software development characterized by having complex data types called "objects" which encapsulate data and functionality. They are typically defined by "classes" and later instantiated for use during program execution.

Contents

[edit] Common Object Characteristics

  • Properties represent data stored within an object. Properties usually represent characteristics of the object. For example, an object representing a car might have color and weight properties. Properties are typically variables defined within a class. Strongly typed languages enforce typing of properties in the same way they enforce typing of variables.
  • Methods are functions which may act on data stored within an object.
    • Accessor methods are used to retrieve data from an object. Accessor methods are sometimes used when public properties aren't made available. They allow other code to alter and view the data stored in an object.

[edit] Scope

Many languages, such as C++ and PHP 5, support some form of scope (or visibility) which determines what code may execute a method or evaluate a property. In other languages, such as Python, every aspect of an object is always public.

  • Public properties and methods can be accesssed by code written outside of a class definition.
  • Private properties and methods can not be accesssed by code written outside of a class definition.
  • Protected properties and methods can only be accessed within the class defining them and in any other classes which inherit them.

[edit] Languages Supporting Object-Oriented Programming

Languages vary in their support of objects. Java, for example, requires object-oriented development. In PHP, Perl and Python objects are completely optional.

[edit] See Also

Do you have information or insights to contribute to this article? Please feel free to edit this page. Ask questions or contribute to the discussion on this article's talk page.