I have a set of base characteristics, and then a number of sub-types. Each instance must be one of the sub-types, but can be multiple sub-types at once. The sub-types of each thing can change. In general, I don't care what subtype I have, but sometimes I do care.This is much like a Users-Roles sort of relationship where a User having a particular Role gives the user additional characteristics. Sort of like duck-typing (ie. If my Foo has a Bar, I can treat it like a ThingWithABar.)Straight inheritance doesn't work, since that doesn't allow mix/match of sub-types. (ie. no multi-inheritance).Straight composition doesn't work because I can't switch that up at runtime.How can I model this?
What class structure allows for a base class and mix/match of subclasses? (Similar to Users w/ roles)
java;class design;groovy;grails