mkchromecast icon indicating copy to clipboard operation
mkchromecast copied to clipboard

Refactor mkchromecast to make `__init__.py` minimal and avoid `import __init__`

Open xsdg opened this issue 1 year ago • 0 comments

As implemented, there's a lot of work being done in __init__.py that should be done elsewhere.

  • Argument parsing should be done directly in bin/mkchromecast
  • The mkchromecast library should be designed as a library, with one or more classes that encapsulate the functionality, can be instantiated with appropriate arguments, and can be unit-tested independently
  • Many of the python files in mkchromecast use import mkchromecast.__init__. This is a code smell. Especially given that mkchromecast is a binary + library pair, __init__.py shouldn't do any work, and should only present the external API of the library. The modules in the library should import things directly, and shouldn't pass back through __init__.py.
  • __init__.py is used in this way because mkchromecast uses a lot of global variables and very little encapsulation. This is also a code smell, and makes the code difficult to unit test effectively.

xsdg avatar Nov 29 '23 20:11 xsdg