Do OO design principles apply to Python?

后端 未结 10 858
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 11:19

It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).

Do these patterns apply equally to Python? Or if I follow the design pat

10条回答
  •  [愿得一人]
    2021-01-30 12:11

    I'd say they apply to Python once you're already doing object-oriented programming with Python. Keep in mind that Python can do a lot more than OOP, and you should use common sense in choosing the appropriate paradigm for the job. If you decide that your program is best represented as a collection of objects, then sure, go ahead and use the design patterns, but don't be afraid to do something completely different if it's called for.

提交回复
热议问题