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

To attach behaviour to data in a functional language, you typically use first-class functions. Your draw function would look for a function in each drawable object and call it.

To your second question: find some great open source projects and read their code.



The problem with open source projects is that great != popular.

There are certainly a lot of very successful projects that have painfully unmaintainable code that still get maintained because so many people are invested.

And the problem with great open source projects is that they'll only show you how they did their problem right - but seeing how to do it wrong and _why_ it's wrong is typically a more useful process.

I think it's generally easier to avoid doing bad things you understand the problem with than try to write excellent code by blindly following patterns that you assume are good because someone well known uses them.


Excellent points. I'm doing a lot of code reading myself these days so it's nice to be reminded of some of the risks. :)




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

Search: