Polymorphism

Mat Ellis mat at tecnh.com
Fri Feb 11 16:10:33 EST 2011


We build lots of interfaces to other systems. Generally we like to do this using Polymorphism. For instance, if we had to interface with 50 different publishers of books, we'd have one class called "Publisher" with the core logic and then interface specific overrides as "PenguinPublisher", "RandomHousePublisher", etc.

When using Ripple this seems to be partially broken. We can use various sub-classes and they will behave as before. But now I can say "PenguinPublisher.find("RandomHouse")" and it will return a Publisher object. Also, when I create a "PenguinPublisher" object it won't set the type field correctly. I've tried overriding this (by adding property :type, String, :default => "PenguinPublisher" in the PenguinPublisher sub-class) and also ommitting the type field in the parent class (which then makes all Publishers without a type set fail and still doesn't fix the 'issue').

This isn't stopping us from using sub-classes. I would like to know:

(a) if there is any fundamental reason why we couldn't have polymorphism 
(b) if the answer to (a) is no, is it on the roadmap?
(c) what kind of problems should we be looking out for with this until/if polymorphism is fully supported

We're still getting our heads around Riak so apologies in advance if this is a dumb question. We decided to cut over the entire schema (including the stuff that doesn't really need Riak and may actually be a bit harder to do on it) to keep things simpler.

Cheers

M.





More information about the riak-users mailing list