Feb-07-2022, 04:13 PM
Hello, i have the following code:
So is it OK or it is still bad coding practice? Is there any improvement on this?
Is it a bad "decoupling" practice since writing code for the parent class i have to know properties of the child class?
class ParentClass: def use_name(self): print('Using {} somehow'.format(self.name)) class ChildClass(ParentClass): def __init__(self, name): self.name = nameAs you can see i'm using a property created in a subclass, in a method of the parent class which of course works fine only if i run the method from a subclass instance. And i don't intend to instantiate the parent class in any case.
So is it OK or it is still bad coding practice? Is there any improvement on this?
Is it a bad "decoupling" practice since writing code for the parent class i have to know properties of the child class?