Java (Eclipse) - Conditional compilation

后端 未结 3 1520
慢半拍i
慢半拍i 2021-01-01 05:11

I have a java project that is referenced in j2me project and in android project. In this project i would like to use conditional compilation.

Something like...

3条回答
  •  有刺的猬
    2021-01-01 06:13

    Perhaps you should consider creating interfaces around the logic that's specific to a profile (J2ME, Android or other in the future). Then create concrete implementations of your interface for each profile. Any common parts you could split out into an abstract base class for both implementations to extend. This way your logic for each profile is nicely separated for different concerns. For each profile just build the appropriate set of classes (you could separate them by package for example). It'll be easier to maintain, debug, test and understand in the long run.

提交回复
热议问题