Why do you subdivide into maven modules into your own projects?

We have ongoing discussion in our project regarding the detailing of our maven modules. We agreed that there may be differences in the needs of the structure (for example, spring) and the internal application, which is always deployed seamlessly.

We also agree that it is quite reasonable to hide the details of the implementation of adapters to external systems behind a separate API module, so the implementation classes do not fall into the path to the classes of the main implementations. in the form But as for us. This is a web project, so we have modules like "web", "core" and "adapter (s)". We have several backends, but we do not require plugins.

What criteria do you use for modulation in maven? What modules do you do for web projects?

+3
source share
1 answer

In my opinion, the design department should be quite small, even for a "web-only application."

I would make separate projects for data access and implementation level interfaces, business level and implementation interfaces, as well as the web server itself. I would also make at least one β€œcommons” project to contain code related to more than one of the other projects. But this is only the beginning. I would not hesitate to extract the commons-util project for utility classes regardless of the application being developed (String, Date, Reflection, etc.). I would also like to make a project for useful testing utilities (commons-test). And this is just the next step ...;)

If I wrote normally useful code related to hibernation, I would put it in the hibernate-utils project. Useful Spring utilities will work in the spring -utils project, etc. However, many projects will contain only one or more packages, and packages usually contain several classes.

My reasoning for this is that it helps me think about the code I'm writing. Is this REALLY business logic, or is it general string manipulation, date manipulation, Hibernate logic, etc.? My layers are getting cleaner and it's getting harder to get circular dependencies between packages and projects (we don't want that). It also makes it much easier to reuse code in other projects. There will always be other projects ...

I also found that new developers find it easier to understand the structure because projects are becoming smaller and more manageable; it’s easier to start coding when you feel that you don’t need to stand it all.

As a last benefit to the fine-grained approach, assembly time is reduced because you don't have to build all the time.

+4
source

All Articles