How does Object Oriented Programming work? What does it do and how is it effective?

1.12K views

How does Object Oriented Programming work? What does it do and how is it effective?

In: Technology

10 Answers

Anonymous 0 Comments

It’s all about organization.

At a basic level, there’s only two things that make up a program: data and algorithms. Algorithms are just operations that take some data and produce other data. For example, you sort a list: [4, 2, 3, 1] becomes [1, 2, 3, 4]. Or you get the sum of a list: [1, 2, 3, 4] becomes 10.

Small programs have only a little data and a few algorithms, so organization isn’t a problem. We can just put data wherever and have all of our algorithms in one big namespace, and it might be messy but we can make sense of it. But big programs have a lot of data and algorithms, so in order for us humans to not get confused we have to come up with a system to organize things.

Object-Oriented Programming is a system of organization. We group together pieces of data that go together and put them in classes, and we also put algorithms that only pertain to that data inside the class. Those internals are hidden from the rest of the world, so nobody else has to worry about them, they just interact with the class. So a class might have a bunch of data (called fields) and algorithms (called methods) inside of it, but then all of that gets bundled into one thing.

Then a class can have instances of other classes for its fields. And by grouping things together in a hierarchy like this, we can make sense of very large programs with tons of data and algorithms.

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