The Artima Developer Community
Sponsored Link

Bean Dilemma

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Bean Dilemma

Posted by Andrew Semprebon on 16 Sep 1998, 10:06 AM

I've been working on a joystick class and recently came across your "Bean or not to Bean" discussion. My first thought was, "Boy, my joystick class would make a great bean!" A developer could drop it in to a visual development tool and it could generate events when the joystick is moved. The only problem is that my current class not only doesn't have a no-arg constructor, it has no public construct at all! Instead, it uses a factory method to get an array of all the joysticks currently attached to the system, so I don't need to do anything special if there aren't any (you just get a zero-length array. I still like the idea of making it a bean, though, so I'll have to rethink the design.

Anyway, I wanted to make the point that whether there is an appropriate no-arg state is in this case hardware dependent. If there is at least one joystick, it can be set up as controlled by the no-arg object. But if there is no joystick, then no instance of the class has valid state.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us