Evidlo / remarkable_mouse

use your reMarkable as a graphics tablet
GNU General Public License v3.0
506 stars 48 forks source link

Don't pass around `args` object #51

Closed nils-werner closed 2 years ago

nils-werner commented 3 years ago

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

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 2 years ago

The code has mostly been refactored to not do this anymore.