Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Variables Vs Performance

 
Harnoor Singh
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am designing one application which reads one file and do lots of processing before displaying to user. While designing application, I decided so keep lots of variables as static so that I need to peform processing logic only once and same variables can be used at number of places. One of my fried said that it is not good idea to declare variables as static as it is against principle of OOP. Can any one please tell if he is right ? Because if he is right than performace of my software will decrease because every time I need to use variables, i will first have to process the recornds and then dispaly to user. Please guide.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Performance is not a good excuse for poor design -- especially when the performance issues are specious. Have you verified that performance is actually an issue when the program is properly designed?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following OO principles and not misusing static variables does't mean you can't store the processed records. It just means using objects to store your data. So there's no reason the performance should be affected.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic