-1

User story: I'm developing a new program and try to put as much program logic into different libraries as possible to increase the reusability.

For interfaces where only a single library or "module" is needed, it is easy. Simply add the library to the project and work with the interface of the library.

Problem: But now I want to outsource the processing layer, which I have to split in different libraries. Therefore I need to build an integration which supports such a structure.

I have looked into Java 9 but it seems it will not fit this use case.

How would a best practice for this use case look like?

  • 1
    “Therefore I need to build an integration which supports such a structure.” – could you please clarify what that means? Why can't you use these multiple libraries directly? Are you trying to bundle them into one library? Or do you want to expose a unified interface, like in the Facade Pattern? – amon Mar 8 '18 at 19:01
7

Don't make something reusable until you're actually trying to reuse it.

Some people like to architect their application in such a way that each piece can be "reused", without really defining what that reuse looks like. The main point of reusability is to get as much mileage out of a preexisting component as you can. If you're still designing your application, you're not actually using anything at all.

My advice would be to hold off on such discussions or thoughts until it's time to start splitting things out. Duplicate code is a smell that you can leverage that lets you know when it'd be a good time to split your code up.

  • Maybe I should have explained this further in my question. The reason I write this new program is because I have three different programs which handle pretty similar use cases at the interfaces to other programs, e.g. Socket vs HTTP handler. These applications have on the processing layer a totally different handling of incoming messages. Some would be hardcoded, performance oriented implementations and another one a xml defintion based scripted one with the target to allow the user to handle the edge cases themselves. But I definitely see your point here. – secustor Jan 30 '18 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy