• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formulas in static class  RSS feed

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are building an application where we have to run number of formulas, more than 50 or so. These formulas will be accessed by two different classes. I am thinking of putting these formulas in a sepearate static class and those two classes will invoke formulas on this static class. Since static class will be invoked many times will it impact the performace of the application in any way as compare to if i put the formulas directly in those two classes.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "access" - would those be method calls, or a static data structure in that class that is used by both client classes? I'd think that more important than whether the information is in a separate class is whether access to it needs to be synchronized (because the two clients might access it simultaneously, and the underlying data can change). If there's no need for synchronization then I don't see a problem.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would prefer separate static utility classes in such cases. But beware of multi-threading esp when 2 clasess simultaneously call the utility class . prefer to use only local variables instead of class level variables.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!