Difference between revisions of "Object-oriented programming"

From CS 61A Wiki
Jump to: navigation, search
[checked revision][checked revision]
(Sources: 1 more)
(Added a bit more to summary for OOP)
Line 1: Line 1:
'''Object-oriented programming''' (OOP) is a method for bundling together information and related behavior.
+
{{OOP sidebar}}
 +
'''Object-oriented programming''' (OOP) is a method of programming using [[Object|objects]] that store/organize their own data and interact with each other via their methods. Programming languages that support object-oriented programming provide a built-in way to implement [[Data abstraction|data abstractions]], as classes correspond to abstract data types (ADTs).
  
 
== Motivation ==
 
== Motivation ==
* data abstraction/ADT
+
* [[Data abstraction|data abstraction/ADT]]
  
 
== Terminology ==
 
== Terminology ==
* object
+
* [[Object]]
* class
+
* Class
* instance
+
* Instance
* method
+
* Method
* [[attribute]]
+
* [[Attribute]]
  
 
== Syntax ==
 
== Syntax ==
Line 15: Line 16:
 
* bound method vs function
 
* bound method vs function
 
* self
 
* self
* [[init]]
+
* [[init|__init__]]
 
* attribute access/assignment
 
* attribute access/assignment
 
** for methods
 
** for methods

Revision as of 22:59, 12 July 2014

Object-oriented programming (OOP) is a method of programming using objects that store/organize their own data and interact with each other via their methods. Programming languages that support object-oriented programming provide a built-in way to implement data abstractions, as classes correspond to abstract data types (ADTs).

Motivation

Terminology

Syntax

  • dot notation
  • bound method vs function
  • self
  • __init__
  • attribute access/assignment
    • for methods
      • for the class: A.method = lambda self: "test"
      • for an instance: inst.method = lambda: "test"

Inheritance

Main article: Inheritance

Sources