lundi 23 octobre 2017

Factory design pattern : jar breakup

I would like to know how would I break a project into multiple jar files if I have many factory classes as below:

class Reconciler {
      public void process() {
AbstractOperatorX opX = OperatorXFactory.getInstance(reconcilerName);
opX.perform();
  .....
AbstractOperatorY opY = OperatorYFactory.getInstance(reconcilerName);
opY.perform();
......
AbstractOperatorZ opZ = OperatorZFactory.getInstance(reconcilerName);
opZ.perform();
....
}

Let us assume there are

  1. Two implementations of AbstractOperatorX viz. DeviceOperatorX and CardOperatorX, to returned by OperatorXFactory.
  2. Two implementations of AbstractOperatorY viz. DeviceOperatorY and CardOperatorY, to returned by OperatorYFactory.
  3. Two implementations of AbstractOperatorZ viz. DeviceOperatorZ and CardOperatorZ, to returned by OperatorZFactory.

Now if I have to deploy this project in the best modular way, I think I can decompose it into following jars:

  1. reconciler-framework.jar which has class Reconciler
  2. reconciler-operation-utils.jar which has classes AbstractOperatorX, AbstractOperatorY, AbstractOperatorZ
  3. device-reconciler.jar which contains DeviceOperatorX, DeviceOperatorY, DeviceOperatorZ
  4. card-reconciler.jar which contains CardOperatorX, CardOperatorY, CardOperatorZ
  5. factory.jar which contains OperatorXFactory, OperatorYFactory, OperatorZFactory

Thus tomorrow, if a Port Reconciler comes up, I need to change only factory.jar and NO OTHER jar. Is this the right way to modularize the jar files or is there a better way. Or am I modularizing it too much.

Aucun commentaire:

Enregistrer un commentaire