Tuesday, 17 February 2015

Object Oriented Programming

Ah, Object Oriented Programming. I remember when you were as simple as programming a virtual cash register in CSC108.

The way that Object Oriented Programming was explained to me is that its nothing more than Class Design, at least for the purpose of this course. Originally, class design was one of the topics that I understood the least in 108, but it ended up being the topic I understood the most by this point in CSC148. The concept of class design is simple, at least in my opinion; you create a name for some sort of data type, you determine what variables (usually numbers or lists, at least in this course) are associated with it (usually in the __init__ method), and finally you create an array of functions which perform operations on those variables.

Object Oriented Programming is incredibly useful, because while Python has many different kinds of objects already built into it, it is limited to a handful of general objects, such as integers, strings, lists, etc. With some clever class design, a programmer could implement games, create different data types, and do much more, where they otherwise couldn't using only built-in objects. Working on assignment 2, my partners and I, for example, are adding a game, Tippy, to our already existing game classes. We initialized the board the game is going to use, and we are adding in functions to add moves to the board and to represent them visually to the player.

All in all, OOP is a good way to tackle problems which deal with a central piece of information, like a game board or the contents of a cash register. I'm interested in seeing the many ways we will use OOP in the remaining weeks of class.

Edit: Evaluate this one.

No comments:

Post a Comment