Pages

Thursday, June 25, 2020

Object-oriented Programming for Newbies

If you are new to object-oriented programming (OOP) like I am, you may find it helpful to read what I just learned through reading a few articles about it. For a programming language to qualify as OOP, it must include functionalities based on four principles.

First, there is encapsulation, which is kind of what it sounds like. We take an object and wrap it up so its inner workings are not visible so that we can control access.

Next, there is data abstraction, which is a fancy way to say, model, or template. If I were to describe to you a garden hose without showing it to you, I would tell you its color, diameter, length, material, and the type of fittings on either end. You would have a general idea of what class of hose I am describing and know if it can do the job you might have for it.

A third principle is inheritance. If my garden hose were a programming object, I could create copies of it, then add additional descriptions that correspond with a similar real-world object, like how long the warranty is, or what temperature range it can handle. I could change the default color inherited to another color.

And finally, we have polymorphism. Who comes up with this stuff? It just means an object has one name but can run in different forms. It is very complex, though, and I don’t quite understand it yet. 

I’ll be writing some basic programs in Java in the next few weeks, so I expect to have a better explanation for you soon. For now, I’ll provide links to resources I’ve been using to get up to speed.

Starting with the basics, here’s an excellent tutorial. When you’re ready to learn from the developers of Java, here’s the definitive reference. And here’s an older article, but still worthwhile, relating OOP concepts in laymen terms.

Thanks for reading.