3 ms·
What’s the name of design principle: “If you can’t name it, it shouldn’t exist”?
by thejackgoode 4y ago
What’s the name of design principle: “If you can’t name it, it shouldn’t exist”?
- xwdv 4y agoNames are mostly for humans. In functions with limited scopes there should be no need for names beyond single letters. Even functions don’t need names once they are small and pure enough. Alas, we still cling to names.
- ghqst 4y agohow do you plan to refer to these nameless functions when they are reused multiple times?
- yCombLinks 4y agoIs the function doing something I care about? If yes, the name should tell me what that is. If not, why's it there at all?
- xwdv 4y agoYou tell me. Seems like most functions can be eliminated and just replaced by comprehensions or a series of map, reduce, filters, sort, comparisons, etc, with small operations applied per element.
- yCombLinks 4y agoSure, they could. But I find naming these things explains to future users the point of why you're applying all of these functions. A chain of 10 filters / maps / comparisons / etc... do 0 to explain why a program cares about doing those things.
- xwdv 4y agoIf it is a true pure function that has already been proven and tested to be correct, you only need to be concerned with the output. The function itself will never have side effects you need to understand nor will it ever change.
- yCombLinks 4y agoRequirements change. I need a function that takes the same input, but the output is no longer valid. But I can't look at this "incredible pure function" and figure out how to do that.
- TeMPOraL 4y agoI know of an opposite principle: if you can point at a pattern in your code and name it, it means it's not sufficiently abstracted.