Saturday, 31 January 2015

SLOG #2 A FEW THOUGHTS ON OBJECT-ORIENTED PROGRAMMING

In the first three weeks of the class, we learnt how to instantiate a class and define methods to the class. The instance variables, or attributes of the class is an example of objects, which is the core of the object-oriented programming.

At the first exposure to OOP, I was quite confused by its functionality. I got quite frustrated when I was trying to solve assignment one; we were required to use classes to make a game, but I can make exactly the same game with the functions and data types I learned in CSC108 and it is easier. The process of programming is after all the process of thinking, but thinking in an object-oriented way didn't quite fit my intuition. I did understand that defining new data types and storing data in classes can be handy in many situations, but the excessive usage of class in assignment one seemed to be artificial and unnecessary.

After I talked to one of my CS specialist friends about what I thought about classes and OOP, he explained to me why they are important in the design of a program. In first year computer science classes, projects usually do not have a large size, so collaboration is not essential. But as the thing we want to build get bigger and bigger, one person cannot possibly finish it on herself, or if we want to make something that other people can extend or modify, OOP is extremely useful. This is because that one of the most important feature of OOP is that data are accessible and usually modifiable by users and programmers. Moreover, a parent class provides roadmaps to the design of subclasses, so if other programmers want to extend the class for more functionalities, they will follow the instruction from parent classes or simply inherit methods from them. For example, in assignment one, making a class for generic game and generic strategy saves us from the trouble of writing a new file for each specific game and strategy.

No comments:

Post a Comment