I'm looking for the most proper way to design a modular application with ServiceLoader.
--MAIN IDEA--
- module app.view | exports
app.view.View
interface that defines UI api - module app.engine | exports
app.engine.Engine
interface that defines Engine (core functionality) api - module app | (entry point) requires and uses
app.view
,app.engine
in order to combine them into actual program
The app will be open for extension, anyone can add new implementations of app.view.View
interface.
--CONCERNS--
Since app.view
will be exported through exports keyword, it will be accessible in every other modules, also in unrelated ones. This feels like a design mistake. Is it?
On the other hand, if I'd change exports to exports to I could force it to be accessible only in related modules, but it will not be extension friendly anymore.
Is my design idea proper for that kind of application? Should I ignore my concerns? If so, why?
--EDIT--
I removed ability to extend app.engine.Engine
just to simplify the case.
Each app.view.View
implementation will provide new javafx.scene.Scene
(which is basically whole UI "skin", as I'm working with JavaFX).
View
interface looks like this:
public interface View {
String name();
javafx.scene.Scene createScene(Engine engine); //takes engine and maps buttons and ui functions to actual engine
}
View
implementation be a different screen in the same UI, or would each one be an alternative UI for the whole app? And the equivalent question forEngine
? Could you perhaps add some example methods for each of those interfaces as well, to help understand your design?Engine
to simplify the case and added sampleView
interface methods. (please read post EDIT)