Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Prefer inheritance if the first thing you're gonna have to do under composition is to crank out a bunch of delegate methods from the parent object to the contained child, to make the parent substitutable for the child, and the child won't be replaced at run time.


Probably. I personally haven't done anything like that. Though I'm not sure I follow.

I've mostly done ASTs and (scene) graphs. I prefer dumb objects, stuffing most behavior and logic in an Interpreter (design pattern) implementation. Being a very simple bear, my working memory can't keep track of all the smarts scattered all about.

My current example is processing SQL statements; think expression evaluator (subset) for a very specific use case. I tend to use so called "External" Iterators for walking trees, to keeping all the logic in one place. Versus Visitor, Listeners, or even Active Objects. Which is feasible for this use case, because its bounded and unlikely to change (eg extension points).

YMMV of course. Now I'm just babbling, apologies, and probably went too far off topic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: