Difference between revisions of "Object-oriented programming"

From CS 61A Wiki
Jump to: navigation, search
[checked revision][checked revision]
(Terminology: add list)
(add skeleton)
Line 2: Line 2:
  
 
== Motivation ==
 
== Motivation ==
 +
* data abstraction/ADT
  
 
== Terminology ==
 
== Terminology ==
Line 11: Line 12:
  
 
== Syntax ==
 
== Syntax ==
 
+
* dot notation
to override method for the class: A.method = lambda self: "test"
+
* bound method vs function
to override method for an instance: inst.method = lambda: "test"
+
* self
 +
* [[init]]
 +
* attribute access/assignment
 +
** for methods
 +
*** for the class: A.method = lambda self: "test"
 +
*** for an instance: inst.method = lambda: "test"
  
 
== Inheritance ==
 
== Inheritance ==
 
{{Main|Inheritance}}
 
{{Main|Inheritance}}

Revision as of 15:33, 6 July 2014

Object-oriented programming (OOP) is a method for bundling together information and related behavior.

Motivation

  • data abstraction/ADT

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