Currently reading Clean Code, and the authors seem to imply that any function with an arity greater than 3 should be avoided at all costs.
I am unfortunately running into an issue where I am faced with a class method with an arity of 4 (5 if you count self
)
def start_job(self, operation, name, external_id, format):
...
All of the parameters can vary, and are necessary to start the job. However, if I think about encapsulating all of those parameters in some sort of class
class Job(object):
def __init__(self, operation, name, external_id, format):
but then all of those parameters would be necessary for the __init__
, and would still need to expose the underlying structure of the object to the start_job
function. At this point, it would seem like feature envy as well and would make sense to change the start_job
function over to the Job
class and just call it start
.
Any ideas on how to avoid this smell?