Sunday 15 February 2015

Week 6: A world of objects

Our discussion of Object Orient Programming in week 6 has a close connection to the 4th week discussion on Abstract Data Types. In a way, this post continues from where we left off in week 4.

As previously discussed, an Abstract Data Type describes a solution to some programmatic problem. When an ADT is implemented it becomes a class and instances of this class are called objects. With that, we have our foray into Object Orient Programming!

Object state and behaviour


Objects in computer science often correspond to things found in the real world. One such object could be a car, telephone or even a dog! It could literally be any object that a program needs to handle. What I find most appealing about Objects in the programming world, is that they are self-contained modules that bind methods to the data they contain. Put simply, objects are neatly organized packages of methods and data that can be easily used over and over again.

Most (if not all) objects contain some data during their lifetime. This data describes their state at any given point. An objects data does change, It’s added, removed and updated by functions that are specifically designed for this object. We can get a sense of what an object is meant to do by reviewing these functions and so we get an impression of it’s behaviour.

Object hierarchies and inheritance


Another interesting thing about objects is that they exist within a hierarchy. The top most object in a hierarchy can pass down some or all of it’s properties (data and functions) to lower objects through inheritance. If a change is required at the bottom of the hierarchy, it is possible to make the change without worrying about the consequences this may have on other objects that are further up the chain.

No comments:

Post a Comment