Saturday, 25 January 2014

Week 3: Object Oriented Programming


To start, what is 'object oriented programming'?

Object oriented programming (OOP) is a style of programming that is used in many different programming languages such as Python(which we are using!), Java and C++. Just as its name suggests, OOP revolves around the idea of "objects". Objects are instances of a class and usually correspond to items or concepts that are in the real world. For example, the 'Dog' objects of the class "Dog" from Exercise 1 last week. These objects have attributes (like Dog.name) and methods (relatable to actions or functions that some item can do or have done to it) like play or call. This makes it easier for people who are not familiar with computer code or a certain programming  language to understand what the code is doing. It also breaks up what otherwise would have been large chunks of code that did a variety of operations into smaller, more manageable pieces which are grouped by their relevance to each other. 

Seeing as the only coding I've been doing has been this past semester in Python, OOP is the only style of programming that I know and I wasn't even aware that I knew it until doing this course. From the reading that I've done about it and my experience, OOP makes sense; well organized code that is easier to understand because of its association with real life items. OOP also has the benefit of inheritance. This is where one class gets most of its attributes and methods from a parent class (and will also acquire any changes made to its parent class post-creation). Inheritance is useful when you want to modify a class in possibly different, incompatible ways or when the original class was sufficient for one audience and the extension of its features would just create clutter. 

I'd love to hear the thoughts of people who have coded in other (possibly less object oriented) programming languages, so comment away! :)

No comments:

Post a Comment