what do you think about this design?

enter image description here

In this image i have reported the dependencies between packages. I would like to reduce the coupling between them, but do you have any idea about how to do this? I think it is impossible to reduce it more than this. The Preferences package is responsible to manage program options, Persistence instead to save them in storage. Applogic and model are in domain layer.

Thanks in advance!

  • 4
    Have you heard of the Mediator pattern? Perhaps it can help you. – sakisk Mar 26 '11 at 17:09

From my point of view, the first thing is to apply an appropriate packaging strategy. This one can help really a lot to design/organize your classes/packages and solve dependencies between them. One rule: only Top to Bottom dependencies are allowed .
Around packages, having a modular approach (even if you don't use OSGI) is the best thing you can do.

Firstly: Packaging Strategy

Secondly: Modularity

  • Fun With Modules

    [...] Tight coupling between modules is a bad idea, and the worst form of coupling is cyclic dependencies between modules. Fortunately, there are a few techniques we can use to break the cycle [...]

  • Applied Modularity: part 1, part 2, part 3, part 4

    This article explains how to "apply modularity" on a concrete and tight coupled Billing app.

  • Hey Destroyica, welcome to P.SE! Linking to articles is fine, but we usually prefer people to either copy some info from the links or elaborate in their post. That way there is info in the post even if the links go down in the future. If you could edit to add some information, that would be great. – BlackJack Sep 21 '11 at 23:39

This is decoupled already, what do you want more ?

In graph theory, yours nearly has the minimal number of edges (just one up the minimum actually) before you start disconnecting vertices.

The triangle App/Preferences/Persistence might look unappealing, but it is fine as long as App and Preferences deal with logically different parts of Persistence. And this has nothing to do with coupling, but with control, you don't want several parts of code doing the same task because they'll diverge in time.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.