What is Object Oriented Programming?

872 viewsOtherTechnology

I can’t really wrap my head around OOP. Like I understand an array and a function and a variable, but I don’t understand what an object is. Why can’t we just use functions and variables everytime we need information or code to run? I code in Python and JS mainly, so objects are truly the most important thing, but I don’t really get it. Also, isn’t every program object orientated? Even C, does it not fit the definitions? If so, how is it any different from C++?

In: Technology

25 Answers

Anonymous 0 Comments

Object Oriented Programming is quite self explanatory. You’re able to create “objects” which share methods and constructors, but are still separate entities. It’s easiest to think of it in terms of a video game. You’re able to create a base `render` object which does nothing but output a mesh with textures to the screen, then a new object that builds directly upon the basic `render` but also has ways of simulating physics. Build upon the `physicsRender` object for a character, which takes inputs, reacts to them and can simulate physics once certain criteria are met. On top of the `physicsRenderCharacter` you have `physicsRenderCharacterPlayer`. etc

Or another example would be a program where you classify railroad cars. You start with a basic `railCar` type which specifies how many wheels each car has, the car’s weight, number, and owner. All `railCars` will have those variables set, and from there if you go for a `freightCar` you specify what kinds of loads it has, the volume of freight it can handle. All different types of rail vehicles will fall under the `railCar` type and inherit the variables from it.

No, not all programming languages are object oriented. An easy example is BrainFuck, where you’re controlling individual bits of memory. While it would be *technically* possible to achieve something *similar* to OOP, it’s not an inherent part of the language. Your objects aren’t going to have methods or anything as you know it, and you can’t easily create and manipulate them at will.

You are viewing 1 out of 25 answers, click here to view all answers.