Richard
Richard

Reputation: 8935

Adapter Pattern and packaging

I am working on a project that needs to be refactored in order to achieve decoupled modules.

I need to us an Adapter to decide which module to route to depending on some config.

                   +===========+
                   | Front-end |
                   +===========+
                    |         |
   +==================+      +==================+
   | RESTful Service1 |      | RESTful Service2 |
   +==================+      +==================+
                    |         |
             +=========================+      +=========+
             |          Adapter        | ---  | Config  |
             +=========================+      +=========+
               |          |          |
       +=========+   +=========+  +=========+
       | Module1 |   | Module2 |  | Module3 |
       +=========+   +=========+  +=========+

I have a Java application, and want to package the modules in JARS using Maven.

RESTful Service1 will either talk to Module1 or Module2 while RESTful Service2 will always talk to Module3. I need to establish which is the nest way to package these modules.

RESTful Service1 will be in it's own Jar while Module1 and Module2 will have their own Jars too.

Question

Seeing that RESTful Service2 will always talk toModule3 only, should they be in the same Jar? Or should I separate them into two seperate Jars too?

Thanks

Upvotes: 0

Views: 77

Answers (1)

Nghia Bui
Nghia Bui

Reputation: 3784

Because RS2 when deployed always needs to work with M3, putting them in the same jar offers one benefit: we won’t forget M3 when deploying RS2. But the downside is that it is difficult to reuse and deploy M3 to another system which does not require RS2.

I think the benefit above is little. Often, when deploying a system you should have a document or checklist. Even if some component was forgotten, chance is that you could detect and fix it quickly.

So the better option is to seperate RS2 and M3 into two jars.

Upvotes: 1

Related Questions