3 ms·
I found some simple rules for single caller functions: 1. Use them if they take <5 parametets - no point making a function if you need to pass all the local co
by nnq 7y ago
I found some simple rules for single caller functions:
1. Use them if they take <5 parametets - no point making a function if you need to pass all the local context into it
2. Use them iff they return something that can be clearly named and have an explainable and understandable TYPE, even in dynamic langs where you don't explictly type things - if you'd end up returning a tuple of 3 arbitrary things that can't be "named as one single concept" it's a code smell
3. Kepp those functions local, maybe define them inside the calling function, at least private if they're methods, anything - if your single caller function becomes unwillingly part of an api, which can esily happen in Python with a _funk() method that users could ignore it's private, you've lost