Name: Anonymous 2011-08-09 18:28
I've tried to make parts of systems I build fit into classic OOP type design and it always feels so awkward and rigid...
Even with multiple inheritance it doesn't make sense to say "this thing's parents do this therefore it does this". Isn't it more natural to say "this thing has these properties therefore it can do these things". It seems more composable and less locked down. I think this is known as "traits".
For example, for a GUI library, instead of saying:
a "Slider" is descended from a "DraggableControl" is descended from a "Control" is descended from a "Window" class
wouldn't it be nicer to define it like:
if an object has a "handle" property then it can run this "Drag" method
Does anyone have experience with using traits or similar ways of designing systems?
Even with multiple inheritance it doesn't make sense to say "this thing's parents do this therefore it does this". Isn't it more natural to say "this thing has these properties therefore it can do these things". It seems more composable and less locked down. I think this is known as "traits".
For example, for a GUI library, instead of saying:
a "Slider" is descended from a "DraggableControl" is descended from a "Control" is descended from a "Window" class
wouldn't it be nicer to define it like:
if an object has a "handle" property then it can run this "Drag" method
Does anyone have experience with using traits or similar ways of designing systems?