The language we have studied so far in CSC108 and CSC148 has been Python, an object-oriented programming language. While Python is a pretty straightforward language compared to Javascript or any of the C languages, Assignment 1 showed me that it's not always easy to think in terms of object-oriented programming.
For example, it was a bit daunting to create a parent class, such as game state, that could be general enough to support different kinds of future subclass game states. As developers, we don't really know what those new child classes or games will look like. What if my future games support more than two players? What if I want to implement a game that can end in a draw, like Tic Tac Toe? Partly because of these concerns, I was confused with how to implement my parent and child classes in Assignment 1. Sometimes I would put the SubstractSquare code in the the general class, and just call that from the subclass. What I should've done was raise a NotImplementedError if anyone tried to use the general class, and then override those methods with the SubtractSquare code in my subclasses. This was the implementation I used for Lab #4, and it worked well. Hopefully I'll remember to override parent classes when necessary in the future.
No comments:
Post a Comment