
上QQ阅读APP看书,第一时间看更新
Tip
Factory functions encapsulate complexity
There's a trade-off that occurs between sophisticated __init__()
methods and factory functions. It's often better to stick with more direct but less programmer-friendly __init__()
methods and push the complexity into factory functions. A factory function works well if you wish to wrap and encapsulate the construction complexities.