You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hemant <ya...@softhome.net> on 2002/05/08 21:42:52 UTC
Should ValueObjects extend ActionForm?
Now that we seem to accumulate Form parameters and create a ValueObject (partially or fully populated), would it make sense to have ValueObjects extend ActionForm? . We can use these ValueObjects in non Struts environments too.
We can have a ValueObjectContainer Interface,
then have
NonStrutsValueObject implements ValueObjectContainer
StrutsValueObject extends ActionForm implements ValueObjectContainer
Regards
pathangi r
Re: Should ValueObjects extend ActionForm?
Posted by Eddie Bush <ek...@swbell.net>.
I don't see how you can compare a piece of software with a car.
Yeah, I think that each component of a car should, to some degree, have a
bit of intelligence. However, I think (and I could be wrong because I'm not
super-knowledgable on cars electronic systems) that the 'smart pieces of
cars' act like stupid VOs =)
... the main processor (the controller? MVC?) still is where the logic takes
place. The 'smart complenents (model?) drag in the data. ... and the user
console (view?) is there to keep the user up-to-date on what's going on.
... again I could be wrong =) My brother is an excellent mechanic, but I am
not. It seems to me all I've ever heard him talk about so far as 'smart
components' though are sensors that send data back to the processor.
... huh - maybe it's not a bad comparison after all ...
Regards,
Eddie
----- Original Message -----
From: "hemant" <ya...@softhome.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 3:24 PM
Subject: Re: Should ValueObjects extend ActionForm?
> Thanks for the link. It has some interesting content, and I agree
validate()
> is business logic. But the idea is that every ValueObject should have
> intelligence by which it can know if it is valid as a Business Unit. For
> example if there was a car Object and if it had the intelligence to check
> itself and report if there is anything wrong with its components like a
> engine problem or transmission problems, then would it not make the car a
> smarter Car??. It would be good if each of the sub car components could
> validate themselves.
>
> I think Business logic need not be lumped but can be distributed across
> layers so that each layer has the appropriate amount of intelligence and
> still be pluggable.
>
> Regards
> pathangi
>
>
>
>
>
>
> ----- Original Message -----
> From: "Eddie Bush" <ek...@swbell.net>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, May 08, 2002 3:51 PM
> Subject: Re: Should ValueObjects extend ActionForm?
>
>
> > Isn't 'validate' business logic?
> >
> > If VO = VALUE Object, would it not be improper for it to contain LOGIC?
> >
> > Hrm ... take a look at this:
> >
> > http://www.javadude.com/articles/layering.html
> >
> > Isn't that a lot cleaner? =)
> >
> > ... don't just run through it at warp speed - study it and let it sink
in
> > ...
> >
> > I haven't decided how I'm going to work this into the next apps I write
> yet,
> > but I think he presents a very good approach.
> >
> > Comments welcome =)
> >
> > HTH,
> >
> > Eddie
> >
> > ----- Original Message -----
> > From: "hemant" <ya...@softhome.net>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, May 08, 2002 2:53 PM
> > Subject: Re: Should ValueObjects extend ActionForm?
> >
> >
> > > The good thing is that every ValueObject in someform or other needs to
> > have
> > > a validate() method and ActionForm already has it and it will be
called
> by
> > > the framework.
> > >
> > > later
> > > hemant
> > >
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "hemant" <ya...@softhome.net>
> > > To: "struts" <st...@jakarta.apache.org>
> > > Sent: Wednesday, May 08, 2002 3:42 PM
> > > Subject: Should ValueObjects extend ActionForm?
> > >
> > >
> > > Now that we seem to accumulate Form parameters and create a
ValueObject
> > > (partially or fully populated), would it make sense to have
ValueObjects
> > > extend ActionForm? . We can use these ValueObjects in non Struts
> > > environments too.
> > >
> > > We can have a ValueObjectContainer Interface,
> > >
> > > then have
> > >
> > > NonStrutsValueObject implements ValueObjectContainer
> > >
> > > StrutsValueObject extends ActionForm implements ValueObjectContainer
> > >
> > >
> > > Regards
> > > pathangi r
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by hemant <ya...@softhome.net>.
Thanks for the link. It has some interesting content, and I agree validate()
is business logic. But the idea is that every ValueObject should have
intelligence by which it can know if it is valid as a Business Unit. For
example if there was a car Object and if it had the intelligence to check
itself and report if there is anything wrong with its components like a
engine problem or transmission problems, then would it not make the car a
smarter Car??. It would be good if each of the sub car components could
validate themselves.
I think Business logic need not be lumped but can be distributed across
layers so that each layer has the appropriate amount of intelligence and
still be pluggable.
Regards
pathangi
----- Original Message -----
From: "Eddie Bush" <ek...@swbell.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 3:51 PM
Subject: Re: Should ValueObjects extend ActionForm?
> Isn't 'validate' business logic?
>
> If VO = VALUE Object, would it not be improper for it to contain LOGIC?
>
> Hrm ... take a look at this:
>
> http://www.javadude.com/articles/layering.html
>
> Isn't that a lot cleaner? =)
>
> ... don't just run through it at warp speed - study it and let it sink in
> ...
>
> I haven't decided how I'm going to work this into the next apps I write
yet,
> but I think he presents a very good approach.
>
> Comments welcome =)
>
> HTH,
>
> Eddie
>
> ----- Original Message -----
> From: "hemant" <ya...@softhome.net>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, May 08, 2002 2:53 PM
> Subject: Re: Should ValueObjects extend ActionForm?
>
>
> > The good thing is that every ValueObject in someform or other needs to
> have
> > a validate() method and ActionForm already has it and it will be called
by
> > the framework.
> >
> > later
> > hemant
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "hemant" <ya...@softhome.net>
> > To: "struts" <st...@jakarta.apache.org>
> > Sent: Wednesday, May 08, 2002 3:42 PM
> > Subject: Should ValueObjects extend ActionForm?
> >
> >
> > Now that we seem to accumulate Form parameters and create a ValueObject
> > (partially or fully populated), would it make sense to have ValueObjects
> > extend ActionForm? . We can use these ValueObjects in non Struts
> > environments too.
> >
> > We can have a ValueObjectContainer Interface,
> >
> > then have
> >
> > NonStrutsValueObject implements ValueObjectContainer
> >
> > StrutsValueObject extends ActionForm implements ValueObjectContainer
> >
> >
> > Regards
> > pathangi r
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by Jim Crossley <jc...@ifleet.com>.
"Robert" <rm...@bull-enterprises.com> writes:
> That depends. Most value object implementations come from the EJB
> area, and if one is using CMP beans, then value objects with logic
> make sense because in CMP you cannot have implementations of the
> setXXX methods.
True, but as you probably know, you can validate your CMP beans in the
ejbStore callback. This is admittedly gross, and you'd likely use a
session facade in practice to encapsulate both the validation and the
storage of the entity.
> I'm sure there are LOTS of opinions on this though :-)
Truer still! ;-)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Should ValueObjects extend ActionForm?
Posted by Robert <rm...@bull-enterprises.com>.
That depends. Most value object implementations come from the EJB area,
and if one is using CMP beans, then value objects with logic make sense
because in CMP you cannot have implementations of the setXXX methods.
Even in non-Entity bean environments, logic in a value object can still
make sense, as you can trap errors before the DB gets it. And as most
are aware, SQL Exceptions are about worthless for telling you exactly
what went wrong...
Then again, if you want to be more tightly coupled to Struts, you could
do your validation in formbeans, then pass the validated data to a
'dumb' value object.
Each has their place, and a lot of people suggest doing validation
everywhere it is appropriate and makes sense. You can do JavaScript,
form bean, valueobject and as a last resort do it at the DB level. Just
depends on what your app needs and if the UI layer is going to change
over time (like having a web service front end to it, or a WML front
end).
I'm sure there are LOTS of opinions on this though :-)
- Robert
-----Original Message-----
From: Eddie Bush [mailto:ekbush@swbell.net]
Sent: Wednesday, May 08, 2002 2:51 PM
To: Struts Users Mailing List
Subject: Re: Should ValueObjects extend ActionForm?
Isn't 'validate' business logic?
If VO = VALUE Object, would it not be improper for it to contain LOGIC?
Hrm ... take a look at this:
http://www.javadude.com/articles/layering.html
Isn't that a lot cleaner? =)
... don't just run through it at warp speed - study it and let it sink
in
...
I haven't decided how I'm going to work this into the next apps I write
yet,
but I think he presents a very good approach.
Comments welcome =)
HTH,
Eddie
----- Original Message -----
From: "hemant" <ya...@softhome.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 2:53 PM
Subject: Re: Should ValueObjects extend ActionForm?
> The good thing is that every ValueObject in someform or other needs to
have
> a validate() method and ActionForm already has it and it will be
called by
> the framework.
>
> later
> hemant
>
>
>
>
> ----- Original Message -----
> From: "hemant" <ya...@softhome.net>
> To: "struts" <st...@jakarta.apache.org>
> Sent: Wednesday, May 08, 2002 3:42 PM
> Subject: Should ValueObjects extend ActionForm?
>
>
> Now that we seem to accumulate Form parameters and create a
ValueObject
> (partially or fully populated), would it make sense to have
ValueObjects
> extend ActionForm? . We can use these ValueObjects in non Struts
> environments too.
>
> We can have a ValueObjectContainer Interface,
>
> then have
>
> NonStrutsValueObject implements ValueObjectContainer
>
> StrutsValueObject extends ActionForm implements ValueObjectContainer
>
>
> Regards
> pathangi r
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by Eddie Bush <ek...@swbell.net>.
Isn't 'validate' business logic?
If VO = VALUE Object, would it not be improper for it to contain LOGIC?
Hrm ... take a look at this:
http://www.javadude.com/articles/layering.html
Isn't that a lot cleaner? =)
... don't just run through it at warp speed - study it and let it sink in
...
I haven't decided how I'm going to work this into the next apps I write yet,
but I think he presents a very good approach.
Comments welcome =)
HTH,
Eddie
----- Original Message -----
From: "hemant" <ya...@softhome.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 2:53 PM
Subject: Re: Should ValueObjects extend ActionForm?
> The good thing is that every ValueObject in someform or other needs to
have
> a validate() method and ActionForm already has it and it will be called by
> the framework.
>
> later
> hemant
>
>
>
>
> ----- Original Message -----
> From: "hemant" <ya...@softhome.net>
> To: "struts" <st...@jakarta.apache.org>
> Sent: Wednesday, May 08, 2002 3:42 PM
> Subject: Should ValueObjects extend ActionForm?
>
>
> Now that we seem to accumulate Form parameters and create a ValueObject
> (partially or fully populated), would it make sense to have ValueObjects
> extend ActionForm? . We can use these ValueObjects in non Struts
> environments too.
>
> We can have a ValueObjectContainer Interface,
>
> then have
>
> NonStrutsValueObject implements ValueObjectContainer
>
> StrutsValueObject extends ActionForm implements ValueObjectContainer
>
>
> Regards
> pathangi r
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by hemant <ya...@softhome.net>.
Great Ideas. Thanks for posting.
Regards
hemant
----- Original Message -----
From: "Jim Crossley" <jc...@ifleet.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 4:19 PM
Subject: Re: Should ValueObjects extend ActionForm?
> "hemant" <ya...@softhome.net> writes:
>
> > The good thing is that every ValueObject in someform or other needs
> > to have a validate() method and ActionForm already has it and it
> > will be called by the framework.
>
> I agree with this, sort of. A value object should have no behavior,
> but anything accepting one should, of course, validate its state. I
> tend to think the validate method should *NOT* be on the VO -- it's
> merely a "struct" with public data members whose sole purpose is to
> consolidate multiple remote calls into one. Because of that, having a
> validate method on the form bean usually makes good sense since it's
> "closer" and therefore more convenient to the user.
>
> The primary reason you don't want to define a VO in terms of an
> ActionForm is because whatever accepts that VO (usually an EJB) is now
> dependent on Struts. That's bad.
>
> I've also toyed with defining VO's as interfaces that the ActionForm
> can implement. On the surface, this seems like a very clean
> solution. What sucks is that even the implementation of the interface
> needs to be in the classpath of the EJB accepting the VO (interface).
> I assume this is because it needs to know how to serialize the
> object. Regardless, it blows the "clean solution" right out of the
> water.
>
> What I'd really like -- I think -- is the reverse solution: ActionForm
> would become an interface that my VO could implement! I *think* it
> would be possible using dynamic proxy classes. The proxy class would
> silently ignore any methods the implementation (my VO) didn't
> implement, e.g. getMultipartRequestHandler. Of course, the VO (or
> whichever ActionFormImpl you prefer) would have to define those
> methods important to it.
>
> -- Jim
>
> >
> > later
> > hemant
> >
> > ----- Original Message -----
> > From: "hemant" <ya...@softhome.net>
> > To: "struts" <st...@jakarta.apache.org>
> > Sent: Wednesday, May 08, 2002 3:42 PM
> > Subject: Should ValueObjects extend ActionForm?
> >
> > Now that we seem to accumulate Form parameters and create a ValueObject
> > (partially or fully populated), would it make sense to have ValueObjects
> > extend ActionForm? . We can use these ValueObjects in non Struts
> > environments too.
> >
> > We can have a ValueObjectContainer Interface,
> >
> > then have
> >
> > NonStrutsValueObject implements ValueObjectContainer
> >
> > StrutsValueObject extends ActionForm implements ValueObjectContainer
> >
> >
> > Regards
> > pathangi r
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by Jim Crossley <jc...@ifleet.com>.
"hemant" <ya...@softhome.net> writes:
> The good thing is that every ValueObject in someform or other needs
> to have a validate() method and ActionForm already has it and it
> will be called by the framework.
I agree with this, sort of. A value object should have no behavior,
but anything accepting one should, of course, validate its state. I
tend to think the validate method should *NOT* be on the VO -- it's
merely a "struct" with public data members whose sole purpose is to
consolidate multiple remote calls into one. Because of that, having a
validate method on the form bean usually makes good sense since it's
"closer" and therefore more convenient to the user.
The primary reason you don't want to define a VO in terms of an
ActionForm is because whatever accepts that VO (usually an EJB) is now
dependent on Struts. That's bad.
I've also toyed with defining VO's as interfaces that the ActionForm
can implement. On the surface, this seems like a very clean
solution. What sucks is that even the implementation of the interface
needs to be in the classpath of the EJB accepting the VO (interface).
I assume this is because it needs to know how to serialize the
object. Regardless, it blows the "clean solution" right out of the
water.
What I'd really like -- I think -- is the reverse solution: ActionForm
would become an interface that my VO could implement! I *think* it
would be possible using dynamic proxy classes. The proxy class would
silently ignore any methods the implementation (my VO) didn't
implement, e.g. getMultipartRequestHandler. Of course, the VO (or
whichever ActionFormImpl you prefer) would have to define those
methods important to it.
-- Jim
>
> later
> hemant
>
> ----- Original Message -----
> From: "hemant" <ya...@softhome.net>
> To: "struts" <st...@jakarta.apache.org>
> Sent: Wednesday, May 08, 2002 3:42 PM
> Subject: Should ValueObjects extend ActionForm?
>
> Now that we seem to accumulate Form parameters and create a ValueObject
> (partially or fully populated), would it make sense to have ValueObjects
> extend ActionForm? . We can use these ValueObjects in non Struts
> environments too.
>
> We can have a ValueObjectContainer Interface,
>
> then have
>
> NonStrutsValueObject implements ValueObjectContainer
>
> StrutsValueObject extends ActionForm implements ValueObjectContainer
>
>
> Regards
> pathangi r
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Should ValueObjects extend ActionForm?
Posted by hemant <ya...@softhome.net>.
The good thing is that every ValueObject in someform or other needs to have
a validate() method and ActionForm already has it and it will be called by
the framework.
later
hemant
----- Original Message -----
From: "hemant" <ya...@softhome.net>
To: "struts" <st...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 3:42 PM
Subject: Should ValueObjects extend ActionForm?
Now that we seem to accumulate Form parameters and create a ValueObject
(partially or fully populated), would it make sense to have ValueObjects
extend ActionForm? . We can use these ValueObjects in non Struts
environments too.
We can have a ValueObjectContainer Interface,
then have
NonStrutsValueObject implements ValueObjectContainer
StrutsValueObject extends ActionForm implements ValueObjectContainer
Regards
pathangi r
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>