Object Oriented Programming¶

In order to use the NumPy arrays, you need to know about object oriented programming and the concept of objects.

Your English teachers would have talked about this term a lot because it’s an important part of English sentences. In most cases, they probably talked about objects as nouns, which are people, places or things. For computer scientists, objects aren’t just people, places or things — basically everything in the world can be an object! And it doesn’t stop there! Computer scientists even say that you have the power to create your own objects whenever you feel so inclined.

So what are some examples of objects that you might see within object oriented programs?

See! I wasn’t kidding when I said computer scientists will try to describe everything as objects. And they do because their official definition of the term is super generic: an object is anything that has some state and behavior.

Let me rephrase; an object is a bundle of information and all the things we can do to interact with that information. Still a bit confused? Consider our friend the whale object. The bundle of information that makes him a whale object, as opposed to the pencil object, is quite large. This information might include the following characteristics: he is blue, large and alive; he is a mammal that lives in the sea and communicates through song.

More impressively, he can do things in this world that change some of that information (swimming makes him a tired whale while singing might make him a happy whale).

Need another example? Let’s try to conceptualize an object that is commonly used within music streaming software, the song. The characteristics that make up a song object might include: length, artist, writer, key, number of plays, and rank in the world. Obviously, we can change the data that represents the number of plays by pressing the play button – this action will increase the number of plays by 1! If the number of plays becomes large enough, we might even be able to change the song object’s rank in the world.

As long as you understand that an object is just a collection of data that can be changed by some action, then you’re good to go. But what about our computers? How do they reason about objects?