Object Oriented Programming#

Overview

Questions:

  • What is Object Oriented Programming?

  • Why should I use Object Oriented Programming?

Objectives:

  • Understand the concepts behind Object Oriented Programming.

Object Oriented Programming#

Object Oriented Programming (OOP) is a style of programming that promotes the creation of objects to contain data and methods. Codes developed using OOP will contain a set of objects that interact with one another. Each object will consist of three main types of information:

  1. Constructor - A way to construct an element of the object. The process of constructing an object using its Constructor is called creating an instance of an object.

  2. Data - Each object may have data relevant to the object. These are often stored as variables within the object itself. Data is often assigned values through the constructor, meaning each instance of an object may have different values assigned to its data.

  3. Methods - Functions defined within a class are usually called methods. Similar to functions, they have a name, a set of zero or more parameters, and optionally a return value. Methods usually operate on the data within an object, sometimes utilizing information provided from outside the object.

Four main concepts of OOP covered in these lessons are:

  • Encapsulation - Enclosing data and methods within an object.

  • Abstraction - Securing variables and implementation details within objects.

  • Inheritance - Extending an object to create a new variation of the object.

  • Polymorphism - Using a similar object in place of an expected object.

This introduction will briefly cover each of these concepts and why they are useful to a software developer.

For further reading on Object Oriented Programming in Python, consider this tutorial or the Python3 documentation found here.