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

> Avoid Object-Oriented Programming

Yeah, no. Every time I saw code written by someone who attempted to avoid OOP it ended up with passing a huge 'context' parameter to most functions, effectively reinventing Python's OOP but worse.

Use pure functions as the starting point, but when you find yourself start passing complex structure around (any abstract word in parameter names, like 'context', 'data', 'fields' is a sign for that) just use OOP.



I think of context parameters being a replacement for dependency injection. What parts of OOP are replaced by context params? State?


I think of context parameters as a replacement for dynamic scoping.

I think it can be all of these things, which in my opinion partially undermines the GP's point.

Recommended related musings: https://wiki.c2.com/?ClosuresAndObjectsAreEquivalent




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

Search: