Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes OO, Patterns, UML and Refactoring and the fly likes FormBean[Struts] Vs ValueObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "FormBean[Struts] Vs ValueObject" Watch "FormBean[Struts] Vs ValueObject" New topic
Author

FormBean[Struts] Vs ValueObject

wrushasen dakhane
Ranch Hand

Joined: Sep 25, 2006
Posts: 47
Hi,

Please tell me what is the difference between FormBeans in Struts and ValueObject design pattern.

Thanks
Wrushasen


SCJP 1.4, SCWCD 1.4
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
I know very little of Struts however you may want to clarify whether you are referring to the Value Object (P of EAA) pattern, or the Value Object (J2EE) pattern which has been renamed to Transfer Object (J2EE), which is more generally referred to as the Data Transfer Object (P of EAA) pattern.


Value Object (VO) vs. Transfer Object (TO) vs. Data Transfer Object (DTO)
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Upon cursory inspection I would suspect that the motivation behind the design of the Struts Form Bean is different from the motivation behind the Data Transfer Object.

The motivation behind the Data Transfer Object is to create a serializable data container that can help move data across JVM, process and network boundaries. It often carries more data than is required by the caller and is usually devoid of any behavior besides what is necessary to set and get its data members.

A Form Bean can add validation behavior. Being a Java bean means that it has an easily discoverable interface that is easy to configure (and load) declaratively through configuration files (rather than programmatically through program code). It's primary purpose seems to be an abstraction/container for form data, to serve as a parameter to an object modeled after the Command pattern (the Action). The Form Bean is serializable but I'm not sure how essential that is to the primary purpose of the Form Bean - I don't believe that the Action consuming the Form Bean is likely to be in a different JVM from the one where the Form Bean was created in the first place.

It would be incorrect to assume that designs and/or patterns that lead to similar looking implementations "are the same" when in fact the driving motivations are different.
[ March 28, 2007: Message edited by: Peer Reynders ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What Peer said.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
Don't get me started about those stupid light bulbs.
 
subject: FormBean[Struts] Vs ValueObject
 
Similar Threads
StreamCorruptedException error
how can we call valueobject class in servlet
how to display content of session on JSP page?
Question on Transaction Management
bean:write error