mercredi 16 mars 2016

How to hide the implementation class using Interface or Abstaract class

I have this scenario with me. there would be two flavours of project build,

  1. Normal Build
  2. Developer Build.

In case of a developer build i will require to compile few more packages and include them in the build structure.

There is common file MainClass in this case,

Mainclass {
     if(devFeature){
        CommonInterface int = new DeveloperFile();
         ........ other logic ......
     }else{
         CommonInterface int = new NormalFile();
         ........ other logic ......
     }
}

as above MainClass is a CommonResource the jar holding DeveloperFile is referenced only during the Dev build. But during a normal build, this would lead to compilation error.

How can i solve this ? any design pattern in specific ?

Aucun commentaire:

Enregistrer un commentaire