You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Soti, Dheeraj" <ds...@harris.com> on 2005/04/06 22:36:50 UTC

Which is a better approach to avoid polymorphism and inheritance

Hi,

I have class structure like as shown below. I am using doc/literal wrapped style
and I don't want to expose concepts like polymorphism, inheritance and
overloading in my service methods. There are two ways to handle this:
*	Define two different complex elements for each type of content. The
advantage is its very clear and simple. The disadvantage is that there are many
calls like findById, findByHouseId, findByName etc. So I'll end up writing
duplicate set of calls for each type of content
*	Define a single complex element with union of the fields from both and
introduce a field to store type. The advantage is that I only need single set of
calls. The disadvantage is the additional type. There is a saying that "Adding
type means killing your object".

I understand that this is not really axis related question but I will highly
appreciate if some would like to share his experience with me.

Thanks

Dheeraj Soti


                          Content
                             |
           -----------------------------------------
           |                                       |
         CommercialContent    		ProgramContent

Re: Which is a better approach to avoid polymorphism and inheritance

Posted by Anne Thomas Manes <at...@gmail.com>.
Definitely go with the first approach. JAX-RPC does not require
support for <xsd:union>, and very few products support it.

Anne

On Apr 6, 2005 4:36 PM, Soti, Dheeraj <ds...@harris.com> wrote:
>  
> 
> Hi, 
> 
> I have class structure like as shown below. I am using doc/literal wrapped
> style and I don't want to expose concepts like polymorphism, inheritance and
> overloading in my service methods. There are two ways to handle this: 
> Define two different complex elements for each type of content. The
> advantage is its very clear and simple. The disadvantage is that there are
> many calls like findById, findByHouseId, findByName etc. So I'll end up
> writing duplicate set of calls for each type of content 
> Define a single complex element with union of the fields from both and
> introduce a field to store type. The advantage is that I only need single
> set of calls. The disadvantage is the additional type. There is a saying
> that "Adding type means killing your object". 
>  
> 
> I understand that this is not really axis related question but I will highly
> appreciate if some would like to share his experience with me. 
> 
> Thanks 
> 
> Dheeraj Soti 
>  
> 
>                           Content 
>                              | 
>            ----------------------------------------- 
>            |                                       | 
>          CommercialContent              ProgramContent