Evan Harmon - Memex

Object-Oriented Programming

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects, which can contain data and code: data in the form of fields, and code in the form of procedures.
wikipedia:: Object-oriented programming

"the focus is on the creation of objects which contain both data and functionality together. Usually, each object definition corresponds to some object or concept in the real world and the functions that operate on that object correspond to the ways we interact with real-world objects."

Uses objects that are data structures containing data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods.

Most popular OOP are class-based, meaning that objects are instances of classes, which also determine their types.

Classes bundle data and behavior

Some problems are easier to conceptualize with state, such as UI objects, etc

Mirrors real-world Objects

  • "fits our mental chunking and real-life experience more accurately. In real life our cook method is part of our microwave oven — we don’t have a cook function sitting in the corner of the kitchen, into which we pass the microwave! Similarly, we use the cellphone’s own methods to send an sms, or to change its state to silent. The functionality of real-world objects tends to be tightly bound up inside the objects themselves. OOP allows us to accurately mirror this when we organize our programs."

Grammar

  • Instead of procedural functions like draw_circle(tess ,100) =... it's: Implied you/subject/instance (function), verb the object adverbly...
  • in OOP it is tess.draw_circle(100) = subject verb adverb.

Class-based Programming

Prototype-based Programming

Objects/instances

  • Objects in Python
    • “Pretty much everything that isn’t a keyword can be considered an object. An object is a combination of data and behaviors that has a name. You can change an object’s data, retrieve information from it, and even manipulate other objects. ... In Python, strings, lists, functions, modules, and even numbers are objects. A Python object can be thought of as an encapsulated collection of attributes and methods. You get access to these attributes and methods using a simple dot syntax”
  • Method
    • Methods are essentially just functions you call on objects
  • State
  • Instances
  • Properties
  • fields
  • properties
  • attributes

Classes

  • "in Python, a template for creating user-defined objects. Class definitions normally contain method definitions which operate on instances of the class."

Types

Class vs. type[edit]
In its most casual usage, people often refer to the "class" of an object, but narrowly speaking objects have type: the interface, namely the types of member variables, the signatures of member functions (methods), and properties these satisfy. At the same time, a class has an implementation (specifically the implementation of the methods), and can create objects of a given type, with a given implementation.[5] In the terms of type theory, a class is an implementation‍—‌a concrete data structure and collection of subroutines‍—‌while a type is an interface. Different (concrete) classes can produce objects of the same (abstract) type (depending on type system); for example, the type Stack might be implemented with two classes – SmallStack (fast for small stacks, but scales poorly) and ScalableStack (scales well but high overhead for small stacks). Similarly, a given class may have several different constructors.

Attributes/Fields/Properties

Methods/Procedures (functions)

Object Relational Mapper

  • technique for converting data between incompatible type systems in object-oriented programming languages.

"Code To interfaces"

Object-Oriented Programming
Interactive graph
On this page
Object-Oriented Programming
Classes bundle data and behavior
Some problems are easier to conceptualize with state, such as UI objects, etc
Mirrors real-world Objects
Grammar
The 4 Pillars of OOP
Class-based Programming
Prototype-based Programming
Objects/instances
Classes
Types
Attributes/Fields/Properties
Methods/Procedures (functions)
Object Relational Mapper
"Code To interfaces"