Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add encapsulation, reduce code duplication, and simplify cascading logic #434

Open
xsdg opened this issue Dec 11, 2023 · 0 comments
Open
Assignees
Labels
codehealth Tasks focused on improving the maintainability of the codebase

Comments

@xsdg
Copy link
Collaborator

xsdg commented Dec 11, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codehealth Tasks focused on improving the maintainability of the codebase
Projects
None yet
Development

No branches or pull requests

1 participant