On Mon, 16 Jun 2008, Eyal Golan wrote: > This is a "Best Practice" question.
O-oh :) http://www.satisfice.com/blog/archives/27 > Suppose I have a component and I want to set its visibility according to > certain parameters. > Suppose I can do it by overriding the isVisible but I can also use the > setVisible after creating the constructor. > > Is there a preferable way? As you can gather from the answers, it really depends, though you should be well of by starting with the consideration of overriding isVisible(). Our current project has a lot of components that disappear and reappear and we have tried a lot of different ways of visibility control. Many cases we can handle cleanly by overriding isVisible(), but sometimes it gets so complicated or has so many dependencies to other components that it isn't practicable. Then we have gone with setting the visibility explicitly case by case. We have extensive unit tests anyway so things keep more or less under control, although having stale state is a real danger. A typical corner case where using the setter seems to make sense to me is when you make a panel visible by pressing a button (e.g. to create a new domain object) but the same panel is then made invisble by a lot of different actions which take the focus out of the panel. Best wishes, Timo -- Timo Rantalaiho Reaktor Innovations Oy <URL: http://www.ri.fi/ > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
