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

Aim towards a layered architecture using dependency inversion principle #2676

Open
MattHag opened this issue Nov 10, 2024 · 0 comments
Open

Comments

@MattHag
Copy link
Collaborator

MattHag commented Nov 10, 2024

Is your feature request related to a problem? Please describe.
Adapting Solaar code or even starting to work on it is hard, and you likely introduce a bug. As is, a lot of hardware is required to verify functionality.

Describe the solution you'd like
Aim for an architecture, that's easy to test, maintain and extend.
It should be possible to implement a FakeDevice, which e.g. behaves like an MX Master 3S and supports hardware independent implementation and testing of new features, while ensuring, that existing functionality still works. Final tests require the actual hardware.

Aim for a three layered architecture, consisting of

  • Presentation Layer
  • Business Logic
  • Database Layer

The business logic contains the most relevant code, we care about. It can be covered by unit tests, when applying the dependency inversion principle (DIP). The business logic should depend on abstractions (an interface), not on a specific implementation. This is achieved by explicitly passing an implementation which satisfies the interface, rather than hard coupling different components. This results in composition over inheritance.
It enables simple tests, without mocking and patching and simply passing a fake instead.

The (work in progress) gives a first insight on the proposed architecture. Parts of the code already satisfy the proposal, others need quite some work to move from inheritance to composition.

(Work in progress)
Solaar drawio

Describe alternatives you've considered
Stick with the untestable big ball of mud, as it was months ago.

Related tickets

Relevant books
https://www.cosmicpython.com/book/chapter_01_domain_model.html

Information

  • Solaar version: 1.1.13+
@MattHag MattHag changed the title Aim towards a layered architecture Aim towards a layered architecture using dependency inversion principle Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant