November 2018
Beginner
330 pages
7h 21m
English
Another common refactoring operation is to change the function arguments. Let's look at reordering arguments, since findings from this example can also be applied to other situations.
Here is a sample method in animal.py:
def act(self, target, verb): return 'Suddenly {kind} {verb} at {target}!'.format( kind=self.kind, verb=verb, target=target)
The order of arguments in this method doesn't seem very intuitive. We might be better off changing it to look like this:
def act(self, verb, target): return 'Suddenly {kind} {verb} at {target}!'.format( kind=self.kind, verb=verb, target=target)
However, there are quite a few callers for this method already, since we also use the method in farm.py (the code is intentionally ...
Read now
Unlock full access