2

I have a utility class that provides a set of algorithms (like supporting repetitive tasks when I parse input from different sources with the same format) and have made all the methods in this class static, added with a private constructor, so the methods can be used without needing to instantiate the class.

I was wondering now whether this is good practise performance-wise? Or is it better to remove all the static tags from the methods and instantiate classes more locally for when I need the methods?

Don
  • 1,428
  • 3
  • 15
  • 31
  • `static` methods are faster as they are simpler. However, you should consider what is the best design primarily and a more OOP approach may be better esp if you have state i.e. try to minimise static state as much as possible. – Peter Lawrey Jul 14 '14 at 08:29

0 Answers0