Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

alternatives to class-based design

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?

Name: Anonymous 2011-08-09 19:42

>>1
Data-oriented design, which is a superset of functional programming. You focus on coming up with the optimal formats for your data that are most efficient for the CPU and memory controller and then compose functions/operations that transform the data from one end of your system to the next. Throw in some macro/generic programming on top for compile-time polymorphism. And use a bit of OOP if you have to for where it makes sense. Confining yourself to a single paradigm, ie. forced OOP in Java of example is brain-damaging.

Lisp, Scheme, Go, C, and C++ all support data-oriented.

http://gamesfromwithin.com/data-oriented-design
http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List