Are global static classes and methods bad?

前端 未结 10 1293
予麋鹿
予麋鹿 2020-12-02 13:36

It\'s generally agreed upon that relying heavily on global stuff is to be avoided. Wouldn\'t using static classes and methods be the same thing?

10条回答
  •  庸人自扰
    2020-12-02 13:51

    If you're trying to be purist about your OO development, then statics probably don't fit the mold.

    However the real world is messier than theory, and statics are often a very useful way to solve some development problems. Use them when appropriate, and in moderation.

提交回复
热议问题