Hey,I'm wondering what you guys think of adding support for inheritance in avro IDL. We're starting to see unions of different types in our code and they mostly have the same fields. We're basically using unions to do inheritance except that the code that uses it remains cumbersome. The client code needs to do instanceof just to cast to the proper type in order to retrieve a value that is actually present in all types of the union.

It seems like this could be hidden from client by just creating a union of all types extending a parent type defined for a field and generating sources with that type.

Then you only need to use instanceof and casts for operations that arespecific to sub-types.

Doug

On Thu, Apr 11, 2013 at 2:51 PM, Alexandre Normand<[EMAIL PROTECTED]> wrote:> Hey,> I'm wondering what you guys think of adding support for inheritance in avro IDL. We're starting to see unions of different types in our code and they mostly have the same fields. We're basically using unions to do inheritance except that the code that uses it remains cumbersome. The client code needs to do instanceof just to cast to the proper type in order to retrieve a value that is actually present in all types of the union.>> It seems like this could be hidden from client by just creating a union of all types extending a parent type defined for a field and generating sources with that type.>> Any thoughts?>> --> Alex>

We're also using unions now for patterns like this so it's not terribly high priority. But I'd still like to do this as currently, the client code is not terribly nice to look at with all the casting and instanceofs. I haven't looked at what kind of effort would be involved but I'll create a ticket when I find some time to start work on this.

Thanks for the feedback Doug.

-- AlexOn Tuesday, 23 April, 2013 at 4:06 PM, Doug Cutting wrote:

> I would not be opposed to adding inheritance in IDL.> > FWIW, another way to represent sub-types is through a union field in> the "super" record, i.e.:> > record Shape {> int x;> int y;> union subFields { CircleFields, SquareFields }> }> > record CircleFields {> int radius;> }> > record SquareFields {> int size;> }> > Then you only need to use instanceof and casts for operations that are> specific to sub-types.> > Doug> > On Thu, Apr 11, 2013 at 2:51 PM, Alexandre Normand> <[EMAIL PROTECTED] (mailto:[EMAIL PROTECTED])> wrote:> > Hey,> > I'm wondering what you guys think of adding support for inheritance in avro IDL. We're starting to see unions of different types in our code and they mostly have the same fields. We're basically using unions to do inheritance except that the code that uses it remains cumbersome. The client code needs to do instanceof just to cast to the proper type in order to retrieve a value that is actually present in all types of the union.> > > > It seems like this could be hidden from client by just creating a union of all types extending a parent type defined for a field and generating sources with that type.> > > > Any thoughts?> > > > --> > Alex> > > > >

NEW: Monitor These Apps!

All projects made searchable here are trademarks of the Apache Software Foundation.
Service operated by Sematext