I have 2 small libraries (literally 1 class) designed as composer packages, they solve the same tasks, just by a different approach.

Without using interfaces or abstractions, I brought them to a uniform API, and my hands are itching to write an interface for them (this is the reverse). But writing the same interfaces in different repositories somehow doesn’t allow conscience.

How appropriate is it to single out an entire package for one interface (perhaps composer.json will weigh more than an interface file)? There are more beautiful solutions without merging repositories?

  • one
    the question is very interesting, my opinion, in the API, select an additional parameter - the name of the class, and combine them with the interface - and you can continue branching in the repository. - Shilgen

1 answer 1

Approach the question practically.

Will anybody use both of yours at the same time?

If your answer is no , then do not force programmers to download complex hierarchies of libs only to save on one file. I like without dependencies, there are few problems with them. Since they themselves, then no dependencies can not be broken, hemorrhoids to a minimum. Then there is not much sense in the interface either, it is a fictitious abstraction that nobody needs.

If your answer is yes , then the sense in three packages for two classes and one interface is generally zero. If someone needs two at once, but they are so small, then why even share it? Let it be one with all the functions at once.

Now, if yours were wildly complex, with a bunch of code, different dependencies, if you used both at once, then you can arrange a complex hierarchy of packages, there will be a practical meaning.

In short, do not do simple difficult, the code will not become more beautiful.