Hacker News new | past | comments | ask | show | jobs | submit login

I don't see the need to do the "ret->doThink = null_think;" since you always pass ret to the function. Just call null_think( ret... )



Ah, but what if the object is handed over to some other deep end of the code? We want to bake the null behavior into it so that any Foo knows how to think itself--calling code just needs to be aware that any Foo object will always have a valid think callback defined.

This is basically the null-object pattern.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: