Sunday, October 13, 2013

Object-Oriented Programming (OOP)

So it's been a few weeks since my last post. Whoops, TAs please forgive me. I just haven't had many thoughts. That said, this post is on an assigned topic, Object-Oriented Programming or OOP.

Object-oriented programming is centred around the creation of classes. A class is a template for an object (e.g. an int or a string) that can have attributes (color, amount, etc.) and methods associated with it.

I took ICS3U and ICS4U in highschool (Ontario system). We studied Java and the first course was focused on... well I'm not really sure what the name of the programming paradigm was. We learned to write functions and implemented everything in the file's main class.

In ICS4U we learned object-oriented programming. At first I didn't see much point in it, creating a class felt like writing a function with a few extra steps thrown in. It wasn't until my culminating project for the course, a checkers game, that I realized OOPs usefulness.

In my opinion, the feature of OOP that is the most useful is the ability to assign attributes to objects. In Java, and as far as I know in Python, you can pass severable values into a function but you can only return one. There are ways around this like returning a list or using global variables, but this can lead to more lines of code or initialized variables. Having an object simplifies this because passing the object passes everything that goes with it.


1 comment:

  1. Something to think about: what are the disadvantages of OO programming paradigm?

    ReplyDelete