Hacker News new | ask | show | jobs
by radarsat1 5349 days ago
> "It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures."

Oddly enough though, you yourself are pointing out that it is better to have 1 function that operates on 10 data structures. ("length" operates on vectors, strings, hash tables, etc.) On the surface this seems opposed to the quote you chose.

However, it is clearer if you replace "data structure" with "interface". The is classic separation of concerns. When specifying the "what", we can get away with "100 functions operate on one interface", but the efficiency, the "how", can be specified independently based on the choice of data structure implementing that interface.

1 comments

Yes, that is a better way of making the point. Thank you.