Performance of using static methods vs instantiating the class containing the methods

后端 未结 8 1686
别跟我提以往
别跟我提以往 2020-11-30 07:31

I\'m working on a project in C#. The previous programmer didn\'t know object oriented programming, so most of the code is in huge files (we\'re talking around 4-5000 lines)

相关标签:
8条回答
  • 2020-11-30 08:14

    It depends on what else that object contains -- if the "object" is just a bunch of functions then it's probably not the end of the world. But if the object contains a bunch of other objects, then instantiating it is gonna call all their constructors (and destructors, when it's deleted) and you may get memory fragmentation and so on.

    That said, it doesn't sound like performance is your biggest problem right now.

    0 讨论(0)
  • 2020-11-30 08:17

    It's not valid in PHP,
    Object Method is faster :
    http://www.vanylla.it/tests/static-method-vs-object.php

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