4 ms·
On the topic of "where do I put this function", for "library/utility" functions, I really like the Hack Standard Library approach: Organize namespaces by the ty
by xixixao 7y ago
On the topic of "where do I put this function", for "library/utility" functions, I really like the Hack Standard Library approach: Organize namespaces by the types of return values (or arguments). So we have Vec/Keyset/Dict namespaces for all library functions which return vec/keyset/dict, and the C (Collection) namespace for functions which take any collection and return something else (either element or a number). I'm sure this can be extended, and I'm always toying with the idea of replacing lodash with a library that follows this convention. Here the objective is really discoverability - you usually know the types of return value/argument, while you often don't remember the function name.
- wruza 7y agoAlso maybe mark arguments which are essential or auxiliary (and defaults), like functions receiving Lists of Foos are not really List-related, but Foo-related. I always wanted a code completion tool which I could ask: hey, I have these two values, say, one field and one pango layout, but forgot what to do next. And it would figure out that I want pango_layout_set_text( layout, gtk_entry_get_text(entry), -1); among the others. Soo cool.