Skip to content

Refactor code to use dependency injection #3

@curieos

Description

@curieos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions