Difference between revisions of "Object-oriented programming"

From CS 61A Wiki
Jump to: navigation, search
[checked revision][checked revision]
(Added a bit more to summary for OOP)
(Terminology: Updated links)
Line 7: Line 7:
 
== Terminology ==
 
== Terminology ==
 
* [[Object]]
 
* [[Object]]
* Class
+
* [[Class]]
* Instance
+
* Instance - a single occurrence of a class as an object
* Method
+
* [[Attribute#Method|Method]]
 
* [[Attribute]]
 
* [[Attribute]]
  

Revision as of 00:12, 17 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