Sunday, January 26, 2014

Sunday Serious Series: Object-oriented Programming Part 1

Hi everyone, this is ACC and this is my courSe bLOG (SLOG) for CSC148 (no idea why I wrote 240 at first, and I am not sure if I should change the blog address now). The blog will be revolving around my adventure in CSC148, and this series will be the main focus where I report my learning progress each week. For this week, I will be writing about Object-oriented programming, on the concept itself.

Edit: See my second post, together with this they are a better round-up of OOP.
Object-oriented programming (OOP) is one of the so called 'programming paradigm', that is, programming style. In this programming style the main focus is all kinds of different abstract objects and their interactions, to make the purpose of the program more clearly presented. These objects can be inspired from real life objects intuitively, which is a main selling point for OOP. Since OOP itself is quite abstract too I shall illustrate this by two examples:

  • Real objects have all sort of properties, which are called attributes and methods in OOP. Attributes are like information such as height of a person, while methods are functions are what an object can carry out, for example the toast function of a toaster. You can then ask the toaster to toast the bagel, which is another object. Pretty straight forward.
  • Now of course objects in real life are not all distinct but can be categorized by their properties (example being laptop and desktop are both computer, and spork having the properties of spoon and fork). Now notice that this two way of categorization is different: a laptop inherits the properties of a computer and it could have other properties (a touch pad), but the property of spork is a composition of the properties of a spoon and a fork. This kind of difference is carried to OOP as inheritance and composition of objects (see http://learnpythonthehardway.org/book/ex44.html).

As you can see, OOP is pretty powerful in representing and illuminating intricate relations, and I would imagine there is much more that can be drawn from how OOP works. Next week I will be covering my actual experience of OOP in Python (by the time I finished my second exercise and started working on my first assignment).

P.S. Please tell me if the font size is too small, or any other suggestions you have!

No comments:

Post a Comment