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

Oh, yes. I totally agree with that philosophy.

The part about classes only acting on themselves resonates heavily with me. To me it's the same with components in frontend apps: the more independent they are, the better.

I'm probably never going to be copy-pasting my classes and components into other apps, but a good class/component should be copy-paste-able without needing many dependencies. This avoids the "banana gorilla jungle problem", as named by Joe Armstrong.

"Free Functions" also help with keeping those classes even more self-contained and decoupled: you can use Function types for callbacks and things like that, instead of having to couple the class to some other class or interface. The only thing the class has to worry about is that the function conforms to the type.

-

"Keep data (= classes) and functions separate. Divide and conquer complexity."

Yep, 100% agree. Amen to that.



Right. Functions and data can not be decoupled because functions must know what properties of data they need to access. So functions by necessity depend on data. BUT data, if it is really "data" should NOT depend on functions. So we have reduced what would be bi-directional dependency problem into one directional one.

In a typical OOP design there would be no clear rules as to who can depend on whom and whom not.




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

Search: