Which is better as a design perspective?
An object that gets initialized and then checks to see if the parameters passed to it are valid before destroying itself (so in __init__) or
Check to see if the parameters are valid and then the object gets initialised?
I think the answer is the latter. However that leaves me with this question. What class owns the primary functions for checking this input? Under an MVC design, would it be in the controller, another class, or as a @staticmethod in the class in question
I'll provide a simple example:
Let's say class B is valid when x > 10 under a MVC design.
class Controller(): ... age = view.age() HumanObj = Human(age) Humanobj.is_Of_Age() # Delete obj ...
class Controller() ... age = view.age() if age > 10: HumanObj = Human(age) ...
class Controller() ... age= view.age() if Human.is_Of_Age(age): HumanObj = Human(age) ...