gm50x/pripyat

Implementing dependency inversion principle

brbarmex opened this issue · 0 comments

We could improve this class by implementing inversion of control in the class by injecting the repository object directly into the constructor

Sample:


module.exports = class {
    constructor( { SampleRepository }) {
        this.repository = SampleRepository 
    }

    async getAllSamples() {
        return await this.repository.getAll()
    }

    async getSampleById(id) {
          ...
    }
}

Benefits

Improved implementation of unit tests.

I would apply SOLID good practices (dependency inversion principle)