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

Refactor code to use dependency injection #3

Open
curieos opened this issue Aug 4, 2020 · 0 comments
Open

Refactor code to use dependency injection #3

curieos opened this issue Aug 4, 2020 · 0 comments
Labels
good first issue Good for newcomers refactor Code that needs refactoring
Milestone

Comments

@curieos
Copy link
Member

curieos commented Aug 4, 2020

Multiple objects create their own dependencies, which causes tight coupling and makes testing more difficult. An example is the rest server:

RestServer::RestServer(AsyncWebServer *server, Scheduler *scheduler) {
this->scheduler = scheduler;
module_service = new ModuleService();
plant_service = new PlantService(scheduler);

This should be changed so the root file (main.cpp) or a dependency injection framework creates these and passes them in as references. Don't worry about the sensors in plant service for now, those will be fixed in #4.

@curieos curieos added the refactor Code that needs refactoring label Aug 4, 2020
@curieos curieos added this to the 1.0 Release milestone Aug 4, 2020
@curieos curieos added the good first issue Good for newcomers label Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactor Code that needs refactoring
Projects
None yet
Development

No branches or pull requests

1 participant