I know this question has a similar name: C ++: calling member functions in the constructor? but I ask a more general question.
Is it good to use member functions from the constructor? This makes it easier to read the code, and I prefer its type of encapsulation (i.e., each block of code has one purpose).
Illustrative example in python:
class TestClass: def __init__(self): self.validate() def validate(self):
Is this a better way to do this than write validate code inside the constructor? Are there any disadvantages of this method? For example, is this a more expensive process with overhead features?
I personally prefer it for readability, but that's just my preference.
Greetings
oop
Simon walker
source share