• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which one is a good programming practice?

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
to store some constants,which one is a better way?Whether storing it in a property file and reading it through Properties() or storing it as some constants in a java file.I feel that reading a property file everytime will be having some impact on the performance.But at the same time,when we need to add new entries,if we store it in a class file,we need to change the source code.So which one is better?
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sat Nar:
Hi,
to store some constants,which one is a better way?Whether storing it in a property file and reading it through Properties() or storing it as some constants in a java file.I feel that reading a property file everytime will be having some impact on the performance.But at the same time,when we need to add new entries,if we store it in a class file,we need to change the source code.So which one is better?



When you say constants, it means a value that is unlikely to change. So using constants in Java file is preffered approach and efficient as well.

Properties come into picture when you want to use some configurable values which can change frequently (e.g. DB URL, pwd, File Path etc).
It involves reading propeties file first time and getProperty() method call subsequently and hence it is not as fast as Constants.

So its upto you to decide as per your requirement.

Regards,
Jass
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic