• Post Reply Bookmark Topic Watch Topic
  • New Topic

Usage of ValueObject In This Architecture

 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I have following figs showing snap shot of an Architecture,these figs shows flow while Insert/Update and Load data.


Fig 1 (Load)


Fig 2 (Insert/Update)

As shown in fig 1 data is returned from Hibernate in form of List of Data class ,same list is given back to web layer,Action class iterates list and transfer value from Dataclass to FormBean and displays on browser.

Where as for Updating,
Action class takes value from FormBean
Fills in ValueObject
Transfers to Business layer
EJB at Business layer will Create new Data object
Fill it with values from Value Object
Pass to Hibernate to save the Object.

My Question is what is the advantage of using VO here,I can directly set Dataclass in Action from FormBean.

Only use of VO I can think of is to set some values not used to save in Database i.e not present in Dataclass.

Kindly let me know your thoughts on this.

Thanks Much
-Praful

[ April 06, 2006: Message edited by: Praful Thakare ]
[ April 06, 2006: Message edited by: Praful Thakare ]
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Question is what is the advantage of using VO here,I can directly set Dataclass in Action from FormBean


In which case your Data object will be the VO. VO is nothing but a DTO
[ April 07, 2006: Message edited by: Satish Chilukuri ]
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,

Thanks for your reply

In which case your Data object will be the VO


Yep thats true,My Question is ,is there need of Extra VO class in this Architecture,can't it be done just by Hibernate Dataclass ?

Cheers
-Praful
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're looking for performance improvements I'd start by eliminating the network part, i.e. running the web tier and application tier in the same JVM.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only imagine two potential advantages:

- your DataClass contains more fields than you actually need to transfer, so transferring a specialized DTO will save network resources and simplify serialization, or

- you need very different behaviour whether you are left or right from the network, so you want to have specialized classes on each side, transferring the data between them via a DTO.

As Fig 1 seems to suggest that you have the DataClass on both sides of the network, anyway, I suspect that you could savely use it as the "DTO".
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many Thanks Mattias and llja,

Mattias,I agree running in same JVM will surly improve the performance,but for some reason Web and Business are different servers.

your DataClass contains more fields than you actually need to transfer, so transferring a specialized DTO will save network resources and simplify serialization, or


Thats true llja,just doubt here,wont it be same if I assigne non required filds to null ?
And yes Dataclass (hibernate) is required at both ends as in fig 1 it is added in List,returned by Hibernate.

Cheers
-Praful
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Praful Thakare:
wont it be same if I assigne non required filds to null ?


Not exactly, as at least the null values needed to be transferred. I'm not sure how much impact that typically will have, though.

And yes Dataclass (hibernate) is required at both ends as in fig 1 it is added in List,returned by Hibernate.


Why is it required on the left hand side? As far as I can tell, you only have hibernate on the right side?
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja ,
Thanks again,

well the reason for having data class at both ends is as I mention earlier,the list returned by hibernate contains Data class,hence it eliminates the process of iterating and populating VO at business layer.

That's the reason I have doubt on why to have VO.

Cheers
-Praful
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. Until now I somehow didn't notice that in Fig 1, the whole list with DataClass instances gets transferred.

My guess would be that it was originally planned to use the VO, but that it later evolved in a different direction.

Without knowing more, I'd probably drive the design onward in that direction and totally remove VO. It might be wise to measure the performance before and after the change, just to be sure.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes llJA,even I have same opinion about VO.

Thanks for your inputs

Cheers
-Praful
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!