Is it expensive to create objects?

后端 未结 3 1184
小蘑菇
小蘑菇 2021-02-07 18:42

I have just refactored a colleague\'s code that, roughly, looked like this...

public class Utility
  public void AddHistoryEntry(int userID, HistoryType Historyty         


        
3条回答
  •  伪装坚强ぢ
    2021-02-07 19:08

    He might be correct if you have millions of these objects in memory simultaneously. But if you don't, then he's bringing up what is almost certainly a moot point. Always choose a better design first, and then modify it only if you're not meeting performance requirements.

提交回复
热议问题