Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Advantage or Disadvantage?  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally when I build an MDI type application I create my Internal Frames as necessary with the new keyword upon some event, like selecting NEW from a menu or whatever.
What if I went ahead and instantiated all my Internal Frame objects I new would be used and then just call setVisible(boolean) when I need them or don't need them?
Any advantage or disadvantage to doing this? Seems to me it may speed the GUI up a tad??
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it out?!
I think this comes down to the old question of lazy and eager instantiation. I read about it in an article on performance (singleton instantiation), and the author preferred eager instantiation, whenever instantiation was likely during each program run. Only if instantiation is optional and seldom, lazy instantiation is the way to go. For example, I wouldn't instantiate the help window/system up front.
cheers
Chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!