I can't figure out what is the more acceptable naming convention for derived
classes. Let's say we have a base class Fruit, from which we derive, classes for apple,
orange and passion fruit. It is a concensus that the name of the base class should appear in the
derived ones, but should it appear in the beginning of the class name or at the end?
Which is more Pythonic: FruitApple, FruitOrange and FruitPassionFruit or AppleFruit,
OrangeFruit and PassionFruitFruit?
Use common sense.
In your example, as others have discussed, the Fruit part is obviously redundant. Use just Apple, Orange, etc. Let's consider use another example instead.
If I had a base class called Plugin, I would name the derived class FormattingPlugin, which I read as “plugin that does formatting”. The alternative, PluginFormatting, reads as “formatting of plugins”. I guess the reading is subjective, so use your own best judgment.
But don't name it just Formatting, because, unlike in the fruits example, that's not a complete enough description of what the class does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With