Making all methods static

后端 未结 7 2089
-上瘾入骨i
-上瘾入骨i 2020-12-25 08:20

In my application there are many classes which contain methods for processing data which can be computation and data enrichment.

My question is - if the class doesn\

相关标签:
7条回答
  • 2020-12-25 08:52

    If you have no class level variables, then yes, you can make all the methods on your class static. And it might even be slightly more efficient due to avoiding object instantiations. But in object oriented programming, objects have "state" and "behavior". Your objects have no state, only behavior. So are you really doing object oriented programming here? I would argue you are not (which isn't necessarily a bad thing). But maybe you might be more comfortable in a non-OO programming language.

    0 讨论(0)
提交回复
热议问题