Last time
I posted about what we had learned about object-oriented programming up until
that point, and I had stated that I found inheritance to be a very interesting
and powerful. This power was very well shown in assignment 2 where we were able
to wright game strategies that would work for multiple games (subtract square
and tippy in this case), without any game specific code. Along with the power
that comes with object-oriented programming in python, there may arise
confusion on how to make inheritance work in the way you want it to.
I find
that the best way to overcome these confusions is to play around with the
things that are confusing you until you have a thorough understanding of what
is happening. The best way to do this is to create a very simple class and then
make another class be a subclass of that class and then slowly add and test
things so build your understanding. As an example I was confused about how to
changes methods in the subclass but still retain the basic aspects of that
method in the subclass, through this experimentation process I quickly found I
could just use the original mothed in the new one (by using something like this
SuperClass.methond()).
No comments:
Post a Comment