Wednesday, 11 February 2015

Week 6 (Summary of Object-Oriented Programming Concept)

I've learned Object-Oriented Programming before coming to CSC148, not in python, but in java instead. So it's not really a new concept for me. To my knowledge, OOP is a concept that mainly uses classes and methods, instead of using functions. In Object-Oriented coding, codes are categorized into different classes, and each class represents something that has many different attributes. An class is an abstract idea, and when you make a specific class by giving all the attributes, you now have an instance. For example, if person is a class, with attribute of gender, height, weight, and age, an instance would be a 20 year-old male, 180cm tall, and weighs 70KG. Methods are similar to functions, but they belong to a class. For example, check if the person is male or female would be a method belong to the class Person.

If we have to make a simple program, for example our first assignment where we had to make "subtract square", then we would organize the code into various classes. We had a class for the game state for saving the current game data with attributes of "who's turn is it", "current number", etc, a class for strategy for the computer to choose a move, and a class for game view for interacting with the player. Each of the classes has an unique use, and all of them together will be sufficient to make "subtract square".

I have a difficulty time explaining Object-Oriented Programming concept even though I know exactly what it is, so I think we should've focused more on the basic definition in class.

No comments:

Post a Comment