When it comes to the package configuration there is “no certain way to do this”, but there are basic concepts. Consider package configuration according to the project characteristics.
Basically, it is desirable to decide on a package structure that facilitates the division of labor. If you divide up the project so that the scope of responsibility for the deliverables is clear, such as assigning a member in charge to each package in consideration of the project structure, it will be easier to proceed with development.
The following 2 ways (or a combination) can be used to consider the package configuration.
As an example, the “member management system” has the following business functions.
|Business name||Package name|
When divided by business function, it is as follows.
When development is carried out in a project, work is often assigned by grouping the business functions. For example, assigned as follows:
In this case, dividing a package into business functions makes it easier to divide labor and parallel development because only that member’s work is stored under the package. For example, if an unused class is under the package, the person in charge of it is responsible for reviewing the need and removing it.
However, if segregation of a package is too big, development becomes more difficult as too many classes are stored in one package. In such a case, the number of classes in 1 package can be reduced by subdividing the package into multiple hierarchies. For example, if the function of “enrollment” business expands, create a hierarchy like
Division according to class role is as follows.
The so-called layered architecture is easier to achieve with this configuration. This is not very common, but sometimes the work is divided by layers rather than by business functions. (such as presentations and domains) In such cases, it is easier to divide the package according to class role.
If the system size is too large, development becomes difficult due to too many classes in the package. The problem cannot be solved with this package configuration, and large projects should avoid this configuration.
Example of division by class role – business function
The above two can also be combined.
In this case, the Action classes are aggregated into a single package. Since
com.example.member.action can be specified as the root package, it is easier to make entries in the routes.xml.
Example of division by business function – class role
At first glance it looks good, but it is difficult to handle with routes.xml of Nablarch because it allows multiple action packages. There is a disadvantage that if you try to forcibly use this method, the URL length will be longer.
This content is compliant with Creative Commons 4.0 “Attribution-ShareAlike”.
Copyright 2020 TIS Inc.keyboard_arrow_up