0

We have a product with standard functionality and our clients also customize the product to their requirements. But currently they make changes in the core product code. I want to know the approaches that can be used to make a j2EE application extensible or customizable. To elaborate this, read below: for example: consider below class:

Class A{
    public void doSomething(Object o){
     // standard product functionality goes here.
     // due to client customizations. client code also goes here.
     }
}

In above class, client has added the code to the core product code. Ideally the product code should not be modified based on open-closed principle.

Currently we dont directly allow client to add code in the method but provide customization points as below.

Class A{
    public ClassAExtension ext;
    public void doSomething(Object o){
     // standard product functionality goes here.
    // client code goes in doClientCustomizations();
     ext.doClientCustomizations(Object o);
     }
}

So now client uses "ClassAExtension" class to override the behaviour. However, this approach is still not that elegant and makes the product code more cluttered with such customization points.

What different approaches or frameworks are available to do such things in a more elegant and efficient way?

NaiveCoder
  • 957
  • 3
  • 14
  • 34

1 Answers1

0

First thing you should do is to clearly separate the code being the standard product and the extensions by using separate packages and deployment artefacts (so having a JAR for your core and a JAR for the extensions).

Sticking to basic Java mechanisms, you could for example specify hook methods in your component, which don't do anything by default, but could be overridden by an customized component extending the core component.

A small side note: Don't use the term J2EE anymore if not having to maintain ancient applications.

Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96
  • that's what we are doing currently but it is inefficient as we have to provide hooks at many places in the method. – NaiveCoder Nov 03 '15 at 07:14