I am a bit in a dilemma: Let's suppose I have a very general function and a specialization of it for convenience reasons. Let's also assume that the specialized function is used 90 per cent of the time, hence being "the common case".
Should I use a shorter function name for the general case (e.g. do
) and a longer
one for the special (do_something_special
) or the other way around (e.g.
do_something_general
and do
)? When applying Larry Wall's words (make simple
things easy and hard ones possible), I'd use a shorter form for the more often
used case.
EDIT: Just to make this a bit more clear: in this example, do
is just a placeholder for a short, descriptive name. Of course it could be longer, e.g. run_task
or process_file
. What I want to know is, if I have a function called run_task_in_specific_way
that is used most of time should actually be called run_task
(although being more specific) or the general abstraction.
EDIT 2: To clarify once more: The functions I am talking about are neither providing more than one functionality nor should they be replaced by a class-based design. The reason is: they are abstract in the same sense as qsort, e.g. taking callable from users to fulfill a specific action. Wrapping them into some auxiliary class does not make much sense.
process_file
do everything with files, like create, read, update, delete, move, copy etc.? It seems to me that your function does more than one thing, which is bad for your program's design (and lead to problems like this). I think your root issue is a different one.