• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on Value Objects

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I saw an application that is using the following design for ValueObjects:
public class RequestVO {
public void setName() {}

...... similarly other methods.

}
public class ResponseVO extends RequestVO {
}

Like this the response extends the request VO. Is there any advantage of using such a design.I need some comments on this.
Thanks in advance,
chandru ram
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you posted this at EJB forum, then I won't tell u about inheritance.
U may wish to do this kind of design when u want to return something from an ejb server, but u may don't know what u will return.
For example, lets say that u have your response from server as an array of classes requestvo (u have no ideea how big the array is, so u have to use array).
in these requestvo classes, some of them might have something different one from the other (lets say u do a select, and according to a customer_type, u make a difference in the result, for example the class requestvo should have additional fields in it, but there is no point of putting those fields in it, while not all the classes in the response should have it , even could have nothing in common but the only field inherited from mother class).
To be more specific: u want to return in an array customer's address, customer's children, etc, and, according to customer type (government, corporation, etc), u may wish to add additional_inform class if customer_type=corporation, which is different from the one of a government.
The only easy way is to do this design:
response would be : requestvo[]
class address extends requestvo
class additional_inform_corporate extends requestvo //information about category of corporation, how many employess, etc
class additional_inform_private extends requestvo //information about how many children, his address, marital status
In this way, the input parameter of the method would be the customer_id, no matter what type of customer it is, while u would have to do a retrieve, to see the customer type, which would not be desirable. Then u could see with "instanceof", or getClass(), what type of class that is, and invoke the proper methods on it.
In other "beautiful minds" (I've seen it at Amdocs), the return type of a method is Response and ResponseException (why did they need J2EE for, cause this looks something like CORBA?).
Hope I didn't misslead u in any way.
reply
    Bookmark Topic Watch Topic
  • New Topic