Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Property initialization location  RSS feed

 
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to read properties and was wondering where would the right location be. These are the lines I require in a couple of classes:



Right now they are written at the start of the main method. Though I would like it to not clutter the main method. For this reason, it occured to me that the constructor could better enclose that piece of code.

What is the preferred way for using properties file related code?

Edit: While we are talking about Java properties, I also would be happy to get your thoughts on my utility class for reading properties file:





 
lowercase baba
Bartender
Posts: 12620
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be almost ZERO code in your main method. you should move chunks of code into methods. Then, call those methods when you need to.

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will work on segregating blocks of code into methods, thanks!

Edit: Made a method like:


and using it like:



Deep down I have a feeling I will have to handle some exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!