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/07 20:56:32 UTC

RE: Which is a better approach to avoid polymorphism and inherita nce

Will someone like to suggest something on this. I have several scenarios like
this in my API (which has to be interoperable) so I want to make sure that even
if I take small steps they are in the right direction.
 
Thanks
 
Dheeraj 

-----Original Message-----
From: Soti, Dheeraj [mailto:dsoti@harris.com] 
Sent: Wednesday, April 06, 2005 1:37 PM
To: 'axis-user@ws.apache.org'
Subject: 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