0

URL generation in my web app is in charge of the presentation layer. Now consider another module sending out messages containing URLs. (Not necessarily triggered from presentation). However, the presentation layer has to know about the module (since it might be the trigger, and the user can configure the module using the frontend).

I.e. the modules are dependent of each other... any ideas how this cyclic dependency could be avoided?

Storing URLs in my database does not seem right to me, same goes for merging the two modules.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
peter p
  • 778
  • 5
  • 14

2 Answers2

1

Create a third module which both modules know, but they don't know each other?

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • hmmm maybe I just don't get what you are pointing out, but... if A depends on B and vice versa, and we're plugging C inbetween,we've got two cyclic references: A<->C<->B If you are suggesting to enclose URL generation in a thirdproject: I do not think this is possible... the page classes are needed for url mounting, the URLs are needed to generate links on the pages.... – peter p Jun 02 '09 at 19:50
  • 1
    No, make A->C and a B->C dependencies. – Thorbjørn Ravn Andersen Jun 02 '09 at 20:20
0

Wouldn't using an interface help here? How about specifying and "consuming" an UrlGenerator interface in your backend module and implementing it in your presentation layer?

In combination with some sort of dependency injection mechanism (Factory pattern for construction of UrlGenerator clients, frameworks like Spring or Guice, Service Locator pattern), this will break the cyclic compile-time dependencies.

Nils Wloka
  • 1,483
  • 10
  • 20