You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Poon, Johnny" <Jo...@ANICO.com> on 2003/07/03 16:24:38 UTC

Big Javabean?

Hi

There are 2 quick questions.

1) I'm considering making one huge javabean that will have 100+ fields.
This bean will be share in the session across up to 23 different screen.  I
think this is probably the cleanest way, as the same field might show up in
different screens.  I don't think this will be a problem, however, I have
never heard or made one single bean with that many fields.  Have you seen or
done that?  Have you heard of any problem that might or have cause?

2) Also, since I'm on this note, I noticed if I have a variable name "mI"
(stands for middle initial), therefore having getMI() and setMI(..), struts
does not recognize those getter and setter because it is actually expecting
getiM() and setiM().  I got around it by renaming my variable
"middleInitial", so that the getter and setter are getMiddleInitial() and
setMiddleInitial().  This works fine.  I'm just wondering if anyone out
there aware of this or am I missing anything in the JavaBean standard?

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Big Javabean?

Posted by Sandeep Takhar <sa...@yahoo.com>.
I would disagree with having fine-grained action
forms.

You will run into problems by splitting them apart for
a logicial entity.

This is especially true if you have more than one
"type".  JSP re-use is not a problem since this is
done by reflection.  However form-bean re-use will
cause problems when you try and access some property
of the base "type" but it isn't there and so you have
some ugly casting.  Using the validator solves a lot
of this problem.

The other advantage of coarse-grained is that you
could probably write some XDoclet to help with this. 
Not great to have the back-end know about the
front-end, but this should be minimal and with
coarse-grained it won't know about the screens. 
Haven't done this, but wherever you need to know about
the structure of the screens you could have a subclass
from the XDoclet generated class.

sandeep
--- David Graham <gr...@yahoo.com> wrote:
> --- "Poon, Johnny" <Jo...@ANICO.com> wrote:
> > Hi
> > 
> > There are 2 quick questions.
> > 
> > 1) I'm considering making one huge javabean that
> will have 100+ fields.
> > This bean will be share in the session across up
> to 23 different screen.
> >  I
> > think this is probably the cleanest way, as the
> same field might show up
> > in
> > different screens.  I don't think this will be a
> problem, however, I
> > have
> > never heard or made one single bean with that many
> fields.  Have you
> > seen or
> > done that?  Have you heard of any problem that
> might or have cause?
> 
> It will be confusing for people to maintain a class
> that large.  You
> should break your beans into logically separate
> classes.
> 
> > 
> > 2) Also, since I'm on this note, I noticed if I
> have a variable name
> > "mI"
> > (stands for middle initial), therefore having
> getMI() and setMI(..),
> > struts
> > does not recognize those getter and setter because
> it is actually
> > expecting
> > getiM() and setiM().  I got around it by renaming
> my variable
> > "middleInitial", so that the getter and setter are
> getMiddleInitial()
> > and
> > setMiddleInitial().  This works fine.  I'm just
> wondering if anyone out
> > there aware of this or am I missing anything in
> the JavaBean standard?
> 
> Struts relies on commons-beanutils to find the bean
> properties.  Having a
> variable named mI is an absolutely terrible idea
> anyways and middleInitial
> is much more descriptive.
> 
> David
> 
> > 
> > Thanks.
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Big Javabean?

Posted by David Graham <gr...@yahoo.com>.
--- "Poon, Johnny" <Jo...@ANICO.com> wrote:
> Hi
> 
> There are 2 quick questions.
> 
> 1) I'm considering making one huge javabean that will have 100+ fields.
> This bean will be share in the session across up to 23 different screen.
>  I
> think this is probably the cleanest way, as the same field might show up
> in
> different screens.  I don't think this will be a problem, however, I
> have
> never heard or made one single bean with that many fields.  Have you
> seen or
> done that?  Have you heard of any problem that might or have cause?

It will be confusing for people to maintain a class that large.  You
should break your beans into logically separate classes.

> 
> 2) Also, since I'm on this note, I noticed if I have a variable name
> "mI"
> (stands for middle initial), therefore having getMI() and setMI(..),
> struts
> does not recognize those getter and setter because it is actually
> expecting
> getiM() and setiM().  I got around it by renaming my variable
> "middleInitial", so that the getter and setter are getMiddleInitial()
> and
> setMiddleInitial().  This works fine.  I'm just wondering if anyone out
> there aware of this or am I missing anything in the JavaBean standard?

Struts relies on commons-beanutils to find the bean properties.  Having a
variable named mI is an absolutely terrible idea anyways and middleInitial
is much more descriptive.

David

> 
> Thanks.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Big Javabean?

Posted by Sandeep Takhar <sa...@yahoo.com>.
Don't think there is a problem with a javabean that
size.

We have similar sizes.

May want to think about using request scope though
(with the same java bean).  This means more calls to
the database however.

One question to ask is if you need to have concurrent
access to the same data.  Your session scoped bean
could be out of date if someone else updates it.

sandeep
--- "Poon, Johnny" <Jo...@ANICO.com> wrote:
> Hi
> 
> There are 2 quick questions.
> 
> 1) I'm considering making one huge javabean that
> will have 100+ fields.
> This bean will be share in the session across up to
> 23 different screen.  I
> think this is probably the cleanest way, as the same
> field might show up in
> different screens.  I don't think this will be a
> problem, however, I have
> never heard or made one single bean with that many
> fields.  Have you seen or
> done that?  Have you heard of any problem that might
> or have cause?
> 
> 2) Also, since I'm on this note, I noticed if I have
> a variable name "mI"
> (stands for middle initial), therefore having
> getMI() and setMI(..), struts
> does not recognize those getter and setter because
> it is actually expecting
> getiM() and setiM().  I got around it by renaming my
> variable
> "middleInitial", so that the getter and setter are
> getMiddleInitial() and
> setMiddleInitial().  This works fine.  I'm just
> wondering if anyone out
> there aware of this or am I missing anything in the
> JavaBean standard?
> 
> Thanks.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org