Git Product home page Git Product logo

python-p3-defining-object-oriented-programming's Introduction

Defining Object-Oriented Programming

Learning Goals

  • Define Object Oriented Programming
  • Explain the benefits of Object Oriented Programming

Key Vocab

  • Class: a bundle of data and functionality. Can be copied and modified to accomplish a wide variety of programming tasks.
  • Object: the more common name for an instance. The two can usually be used interchangeably.
  • Object-Oriented Programming: programming that is oriented around data (made mobile and changeable in objects) rather than functionality. Python is an object-oriented programming language.
  • Function: a series of steps that create, transform, and move data.
  • Method: a function that is defined inside of a class.

Introduction

Object-Oriented Programming (OOP)

An object-oriented approach to application development makes programs more intuitive to design, faster to develop, more amenable to modification, and easier to understand.Object-Oriented Programming with Objective-C, Apple Inc.

It's natural to wonder, "how can a string of ones and zeroes be referred to as an 'object'?" The use of the word "object" is an abstraction of thought. An "object" in code has no more physical form than does a word in any human language. Sure, words have physical representations: speaking a word causes air to vibrate in a sound wave, ink on a page can be shaped into symbols that represent the word, a meaning can be pointed at or mimed out; but none of these are the word itself. Human language is a system of abstraction: it communicates the idea of a thing, but not the thing itself.

Magritte: Ceci n'est pas une pipe

Translation: "This is not a pipe." - The Treachery of Images, René Magritte, 1927

This image of a pipe is no more a pipe than the word "pipe" is a pipe; in the same way, a code object named pipe is not a pipe, but only another form of representing a pipe.

As humans, we’re constantly faced with myriad facts and impressions that we must make sense of. To do so, we must abstract underlying structure away from surface details and discover the fundamental relations at work. Abstractions reveal causes and effects, expose patterns and frameworks, and separate what’s important from what’s not. Object orientation provides an abstraction of the data on which you operate; moreover, it provides a concrete grouping between the data and the operations you can perform with the data—in effect giving the data behavior.
Object-Oriented Programming with Objective-C, Apple Inc.

A code object representing a water pipe (instead of a smoking pipe) might contain values for length, diameter, material, and manufacturer. The bundling of these individual pieces of information together begins to form a larger whole.

Object-Oriented Programming, however, does more than just bundle up individual pieces of data that represent a "thing" — it also bundles customized functions that can be performed on that data. These are called methods: behaviors that an object performs upon its internal data and even upon other code objects.

An object in code is a thing with all the data and all the logic required to complete a task. Objects are models and metaphors for the problems we solve in code.

Object-oriented programming was born from the trend of making digital lives reflect our real lives. In the 1970's, Adele Goldberg and Alan Kay developed an object-oriented language at Xerox PARC called Smalltalk, which was used in the first personal computer.

Python comes with a few types of Objects to get us started, things like int, str, list, etc. We call these base types of Objects "Primitives." But what if we wanted to create a new type in our programming universe, a new kind of object for our code? That's what the class keyword and object orientation allows us to do.


Resources

python-p3-defining-object-oriented-programming's People

Contributors

professor-ben avatar lizbur10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.