mkchromecast icon indicating copy to clipboard operation
mkchromecast copied to clipboard

Add encapsulation, reduce code duplication, and simplify cascading logic

Open xsdg opened this issue 1 year ago • 0 comments

This bug covers three classes of deficiencies in mkchromecast:

  1. It uses a lot of module-level code (that is, code that takes action immediately upon import, and that cannot ever be triggered again after that import). Among other things, this style of code is impossible to unit-test, and also makes it difficult to make conditional use of functionality that is defined in those modules.

  2. A lot of code is duplicated both within single modules and across modules (for instance, code to reset the state of casting is duplicated in slightly different forms across 6 different modules)

  3. A lot of multi-dimensional policies (that is, where two or more factors decide which outcome to execute) are implemented as huge cascades of if/then/else conditionals, where many of the outcomes have small differences that could be expressed in ways that are more compact and easier to understand. The current implementation of audio.py is a prime example of this.

The goal of making progress on this issue is to make the codebase easier to unit test, easier to understand, easier for non-experts to update, less prone to bugs, and less prone to copy-paste errors.

xsdg avatar Dec 11 '23 07:12 xsdg