Is IntelliJ IDEA project Module different concept from Java 9 Module?

前端 未结 2 2028
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 17:41

I never used modules in IntelliJ IDEA, but in Java 9 appeared modules ( which I also never used but wanna study now what is this)

So the question is: are there match

2条回答
  •  遥遥无期
    2020-12-19 18:36

    Much as I love Intellij, I have to answer yes: there is one big difference.

    Java 9 Modules are a much needed step toward encapsulation and decoupling. But there is a form of (accidental? pathological?) coupling in Intellij modules by virtue of their membership in a single Intellij (and therefore VCS) project. Java 9 Modules can (and probably should, from the standpoint of encapsulation) be developed in separate VCS/IDE projects, from which they can expose only the APIs that make sense. A super (parent) POM is a mechanism providing non-pathological coupling across projects to reduce redundancy.

    A module based on a well-defined domain and bounded context should be freely available for reuse: it's a big step toward the componentization we have been talking about for years. These domains are not random - they reflect an emerging analysis of the world. If it sounds like I'm advocating something like the anarchy and Balkanization faced by Node developers - I'm not: the well-analyzed domain is the key.

    Either Intellij modules are "benefiting corruptly" from the kind of otherwise highly desirable coupling-under-the-hood that is one of the fantastic benefits of Intellij projects, or there is no value added by maintaining them in a single project. Working in a non-TBD environment with a branch for every JIRA ticket increases the cost of this kind of coupling (personal experience).

    The justification in another answer for this coupling is the possibility of a "refactoring" that involves changes to multiple modules. But this is a code/design smell: either breaking changes are being made to a public API, which is a problem for all clients and can usually be avoided or mitigated with some imagination, deprecation, EOL-warnings (Strangler pattern), etc., or the modules exhibit pathological cohesion, probably due to incomplete analysis into bounded contexts.

提交回复
热议问题