6

So I've a little freelance project, is basically a blog. I've decided to use microservices with angular in the front end and python in the backend.

I've been about 2 weeks copy pasting code in my api because all the modules are pretty simple CRUDs that do the same thing, there is not heavy business logic or anything, just database handling.

I was really tired of copy pasting modules and his test, only changing function names and parameters, today I've this "epifany" about the inheritance and thinked about using it in my service, creating a base class and making all the other classes children of him.

Before the change my project has 220 tests (100% coverage) now I have only 40 tests (the same 100% coverage)

So, the lesson is: don't start throwing code like an idiot and start your project with some good planning

Comments
  • 0
    @illusion466 i already use ioc and di with all the dependences of the class before rewriting it in order to ease the tests and class reutilization, besides the code decoupling. But I think for this matter in concrete the heritage's works better, i only override the methods that need some logic to add it and call the parent class after that.
Add Comment