WEEK: 11
Active: March 21st - April 3rd
Note: Spring Break runs from March 23rd - March 31st
Work Due: April 4th @ 9:00AM

Intro to Object Oriented Programming (OOP)

Object Oriented Programming (OOP), is a style of programming that conceptualizes code as a series or set of objects. These objects are literally digital things, that have attributes describing them, and functions or methods of ways they can act.

Part of the philosophy of this programming style is that as humans, we approach our understanding of our world through the examination, manipulation, and interaction with objects. Objects in our real world are things that have properties and can do things or can have things done to them. For instance, I am currently sitting on a couch; more specifically, this couch is a navy-blue love seat, that is specifically designed for outdoor use. Through this description, we just defined three additional properties for this couch;

  1. it’s color is navy-blue
  2. it’s size is a love-seat
  3. it’s placement is outside

Additionally, this couch is doing something, as I am sitting on it. At the very minimum, we could say I am “interacting” with this couch and it is currently “full”. (As opposed to “empty” when no one is sitting on it.)

If this was code, we would try and find someway of representing this object, its specific parameters, and the functions/methods it is capable of.

What is significant about this approach is that we can encapsulate these qualities and ideas in a class, which can be used as a blueprint or recipe. This set of instructions representing a couch can then be used to create couch objects. Each of these couch objects is its own thing, just like two couches in the real world are unique, even if they are they same model couch. This couch class can also be used to create different types of couches, such as pink couches that are full-size with three seats and are designed to be used indoors (like the couch I am about to move to, since it is getting cold outside).

As you dive deeper into coding over the years to come, you will see many people use the “real-world” objects metaphor when describing OOP.

All of this piggy-backs off of our previous weeks conversation about functions (As you will see throughout this lesson, this is true in many ways). Specifically at the moment, one of the reasons for learning to write functions is so that your code can be modular. Modular code encapsulates specific functionality or processes, that can then be reused in projects or across projects. We saw during that previous conversation that one of the things functions allow us to do, is take bits of code that we repeat or want to repeat, encapsulate them in a function, and then simply call that function instead of “copy/paste”-ing the code.

4 Videos

What follows are 4 videos to introduce the larger ideas and topic of OOP.

1.

The following video introduces what OOP is and why you may want to use this paradigm.

2.

This second video explores the idea of code reuse and inheritance. As with the first video, the main take away is reasons why someone would want to move from procedural programming to object oriented programming.

3.

Dan Shiffman returns, with his take on OOP. Please ignore the bits of code that do not make sense. He is describing this in reference to Processing (p5’s older brother which is based on the Java programming language).

4.

This last video does a nice job of introducing terminology of OOP. Please pay attention to that, as we will discuss these terms more on the next page.


Previous section:
Next section: