Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Helper classes  RSS feed

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From J2EE patterns I've read about using helper classes..
eg.
User user = new UserHelper().getUserWithUserId(id);
If there are no intention of using any instance variables, what's the point of using objects to encapsulate the methods?
Why not use just static classes? What's the performance comparison?
User user = UserHelper.getUserWithUserId(id)
Thanks
Chu
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be a rather long -unsure- answer but with respect to proper distribution of a Singelton with also performance issues !
AFAIK,
you are dead right, it should be more or less the same. One is more potentially performant.
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've grown out of my performance "nitpicking" habit...
1 million continuous calls to static methods might be few seconds faster than 1 million instanciations, followed by calling the method.
However, when that situation actually happens, that is probably not the first thing I'd worry about.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!