Don't pass around `args` object
Closed this issue · 1 comments
nils-werner commented
I believe that passing container objects like args
to all your subroutines is eventually asking for trouble. By using such a container, functions are allowed to hide what fields of the container they are actually using. And those functions are not reusable, as I have to first create an args
container with all the right fields.
If you search for args
you will find it is used in open_remote_device()
, pipe_device()
, and read_tablet()
. But actually
open_input_device()
is usingargs.address
, and optionallyargs.key
andargs.password
.pipe_device()
is usingargs.orientation
,args.monitor
,args.threshold
,args.mode
, andargs.debug
read_tablet()
is usingargs.orientation
,args.monitor
,args.threshold
, andargs.mode
That fact is completely hidden in the generic function(args)
interface.
Instead of a function
def foo(args):
print(args.address, args.debug)
foo(args)
I would recommend unpacking the arguments in the call
def foo(address, debug=False)
print(address, debug)
foo(args.address, args.debug)
Evidlo commented
The code has mostly been refactored to not do this anymore.