4 ms·
Sounds closer to type classes usage a la Haskel than what I'd call OO (late binding)?
by sixbrx 9y ago
Sounds closer to type classes usage a la Haskel than what I'd call OO (late binding)?
- bluejekyll 9y agoI try to capture data in a enum or struct, then define the operations available to that type. A trait allows me to capture common functionality across different types which implement that trait. With generics it allows me to be polymorphic. If that’s not OO, I don’t know what is :)
- Tarean 9y agoWell, technically traits dispatch based on type and not on value. As long as you aren't wrapping everything into trait objects that is much closer to functional programming. Seems like a mostly semantical difference, though. I guess there is a philosophical difference in whether you pass a large struct into a function or select the needed data at the call side and only pass that, though. Former might be easier to extend, latter is probably easier to test?