Vincent wrote:
I'm currently designing and developping an enterprise J2EE application based on Struts. In this application there's a layer of Data Access Object which abstract the underlying persistent storage. For populating my struts' *Form I've imagined first a transfert between forms and DAO based on Value Object, associated with helper classes for translating from one type to another. And I realized that struts Form can be in some situations quite good transfert objects, and by doing so we economize development of both helper classes and VO classes.

What do you thing about using forms as VO? Do you think it's a dirty solution? Forms are often mirrors of the database's table.

Personally I prefer to keep form beans and value objects seperate, for two key reasons:

1) form beans generally should consist of String data to facilitate round-tripping of invalid inputs. I like to constrain them to a clearly defined role of marshaling data 'into' and 'out of' the presentation layer, i.e. across the boundary between presentation and application.

2) value objects should use typed interfaces to ensure marshaling to and from presentation format (string types) is pushed as far up the application stack as possible. This also enables other, potentially type-aware, presentation / client tiers to be built on top of the same value objects (e.g. for a web-services interface).

To address Micheal's question (why not just make value objects and business objects the same thing?), I'd point out that it can be valuable to distinguish between business rules and application logic. I find my business objects often have functionality I don't want called directly from the presentatin layer, particularly when using a mediation layer between the two.

Essentially, though, it comes down to the complexity of the problem vs. the complexity of the solution. The more complex the application, the more it makes sense to partition responsibilities. For very simple applications it makes sense to collapse layers together.

L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to