Sunday, 1 March 2015
Object Oriented Programming
Returning from reading week, my group and i began assignment 2. Assignment 2 is mostly all object oriented programming. In my opinion, object oriented programming makes programming a lot more simple. It's easier to keep things neat, and by creating methods, for objects, yourself helps you understand them and how they work. This also allows something called inheritance, where a class can be a general object, and you can have other objects that are specific instances of it. This helps us in our assignment for many things, such as different games and different computer strategies. For the games, they share some same properties. They have two players, only one can win, one player goes at a time, and a good move for one player is a bad move for the other. Using this, we set up a general class called GameState, however, you need subclasses that are specific games. So each subclass represents a unique game with rules and a different objective to complete. The subclass takes on the general properties of GameState and then is assigned it's own unique properties. This cuts out the work of making two separate classes with a lot of repeated code. A common problem i have is trying to decide what the general code should all have. You must consider what is the same for each subclass, and that is what you will use for the general class. Also, many methods are specific to the subclasses, but in some cases a method in the general class works for both. This again saves you from repeating the same methods in the subclasses. So when a method is not in the subclass, it automatically looks with the general class for the method. I look forward to learning more on object oriented programming.
Subscribe to:
Comments (Atom)