Thursday, January 23, 2014

Object-Oriented Programming

Object-oriented programming, also known as OOP, is a computer programming approach that represents abstract ideas and concepts as ‘objects’.  I personally find this fascinating perhaps due to striking similarity between the normal flow of human thoughts and this programming paradigm; people like to think in terms of objects and now programs get to follow our lead!  Things known as ‘classes’ within OOP encompass attributes, methods and variables which are all found to better describe an object.  To put this more concretely, you may think of an object “blue jar” which is of class “Jar” then you can assign your blue jar a method to open it, another one to pour its contents, and so on.  Your blue jar will have all the features a typical Jar has.  I normally like to think of a class as a template which leads to the creation of an object allowing it to inherit that class’s properties; its attributes.   In some cases there may even be sub-classes within a class forming what is known as a class hierarchy.  This gives on a glimpse of the level of complexity within OOP which largely resembles our real world systems.   It is worth mentioning that OOP is widely used across different programming platforms including Java, Python and PHP.

I find that object-oriented programming creates easily-edited, high-quality software to solve problems, albeit not all problems.  Some programs cannot be accurately coded to work using OOP and this is where an alternative such as functional programming may be used instead.  The complexity of OOP and thus the necessity of foresight may require a programmer to put an extra amount of work on an otherwise basic project.  With its ability to refer to the type or class of an object as it is processed (polymorphism), OOP may avoid errors of misattributing objects to the wrong classes.  I believe that the encapsulation feature within OOP, where certain components of the object such as methods are restricted and secured from unauthorized access, makes it worthwhile.    OOP allows new objects to be created and old ones to be manipulated and reused by other programs thus facilitating the enhancement and “recycling” of code by future programmers.  I must confess: finally grasping the concept of objects interacting with each other to make a program run was a milestone for me at the beginning of this term; I used to be irritated by its logic but applying its concepts to the real world has helped make it far less abstract.

No comments:

Post a Comment