> In a Been, you can use a Hashtable to save your attributes,
> but you don't have to use a Hashtable. I normaly don't.
> Because I know which attributes to expect, I implement these
> as fields in the Bean, and save the values in these. I know
> that a Hashtable has an expected constant-time on the get and
> put operations, but it is only expected time. With fields, I
> know that I have a constant-time operations, besides I'm sure
> that Java won't have to do some bookkeeping behind my back to
> insure the proper working of a Hashtable.
>
> Besides that, you can do a lot of other interesting stuff in
> the get/set methods, like accessing other objects, if you
> don't want to store the attributes in your Been.
>
> I have also been programming Perl, and I know that Hashtables
> are a nice thing. But remember, that a Java class is a proper
> class, and not just a hashtable in desguise.
>
> But of course there are situations, where what you propose is
> very usefull.

Even if a bean can do more, I thought ActionForm beans should do little.

My main question was perhaps not so clearly formulated. Why have a
cumbersome interface (getXxx() and setXxx(String val) methods) when a
simpler one could do the same job? A class with the interface

String getAttribute(String name),
void setAttribute(String name, String val) and
String [] getAttributeNames()

could do the same job as the current setup. In addition populating and
retreiving information would be simpler.

Jonas

Reply via email to