After this week's latest class I should probably comment on some of the more technical parts of O.O.P.
Often when creating an overriding subclass method it is useful to utilize the corresponding method of the master class such that the overriding method derives all the information from the original method. Then you can build around it to specialize that new overriding method. In this instance calling that method requires the following syntax:
MasterClass.method(self, arguments...)
Similarly if you simply want to use the more general method and not the specialized version the syntax required is MasterClass.method(subclass_object, arguments...).
Another less technical point made was that when designing an __eq__ method, it must encompass three qualities.
The simplest is symmetry.
If a == b, then b == a
The next is that it is reflexive.
a == a
The last quality, which is also the easiest to overlook, is transitivity.
If a == b and b == c, then a == c.
That's all for this week.
No comments:
Post a Comment