Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties File or a Class???

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I would like to know that while accessing some variables I sometimes use a properties file and sometimes use a class and use the variables with the code CLASS_NAME.VARIABLE_NAME or sometime use setter and getter methods. So I would like to know which out of the three methods is the most efficient inn terms of performance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoa! Premature optimization if I ever heard it

Recovery of values from a class instance or a Properties instance is going to be so much faster than anything else a serious application does that you are asking the wrong question.

The right question is - which will be easiest to maintain later and explain to other people.

Designers seem to favor properties files when the user is allowed/required to make some settings with a text editor.

Bill
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to know.. which of the three incurred less overheads. Coz the properties file needs a properties class to be intialized. But a setter and getter is just a method call. And refering to CLASS_NAME.VARIABLE_NAME should be the fastest.

And i didnt get your second sentence very clearly!
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somnath Mallick wrote:I just wanted to know.. which of the three incurred less overheads. Coz the properties file needs a properties class to be intialized. But a setter and getter is just a method call. And refering to CLASS_NAME.VARIABLE_NAME should be the fastest.

And i didnt get your second sentence very clearly!



Each method has its own pros and cons

Coz the properties file needs a properties class to be intialized. But a setter and getter is just a method call.

Its very easy to maintain properties file especially when you change your value without affecting any code.
For setter , getter , there is some where you got to set before using it and it has to be start of your application


CLASS_NAME.VARIABLE_NAME should be the fastest.


Yes and if your variable name is final and when you change the value of VARIABLE_NAME , you go to recompile all your referrer files. would you ?!?



 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<<I just wanted to know.. which of the three incurred less overheads>>
I agree with what William is saying. It really doesn't matter which is faster as both are sufficiently fast. This is more of a design issue than a performance issue. Determine which of the solutions makes your application easier to manage and go with that. Sometimes the right answer isn't the one you want to hear.

If it is really important to find out which solution is fastest (and I hope you will agree it isn't) write some test code and profile it. None of us know which is faster.

Read the FAQ at the bottom of my listing.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion guys!!! It was really helpful!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic