Skip to content

The project structure

zenbones edited this page Mar 14, 2011 · 1 revision

The Project Structure

In the diagram below <project> should refer to a single source control management tree, such as 'smallmind'. Each <module> is a sub-module of the parent project, such as 'persistence', or 'events'. The module name is repeated in the directory structures for each language (such as 'java'), and each resource (such as 'spring'), creating a module-wide package name space, which guarantees its uniqueness for all files within that module. Note that the module root of the test classpath is forked into 3 sub-paths, representing the requirements of each test scenario, e.g. unit ('unit'), integration ('integ'), or functional ('func'). The expectations are that...

  • Unit - A 'unit' test exercises a single class, and requires no other services outside of that target class. As a practical matter, all required dependencies should be mocked out in a way which completely isolates the test scenario.
  • Integration - An 'integration' test allows the usage of external services, and exists to test the connection and message passing mechanisms amongst the set of target services, but should not require a complete runtime container. Dependencies upon the runtime container should be mocked out as necessary.
  • Functional - Lastly, a 'functional' test exists to exercise the project's runtime container, and may require any dependencies to do so.

The structure depicted below may seem a bit stringent, but the practice guarantees we play well with any other modules or third-party projects, across the entire class path, and it standardizes the placement and location of all files within the project.

<project>
         |- pom.xml
         |- <module>
         |          |- pom.xml
         |          |- src
         |                |- main
         |                |      |- java
         |                |      |      |- com
         |                |      |            |- <project>
         |                |      |                           |- <module>
         |                |      |                                      |- ... classes
         |                |      |- resources
         |                |                  |- spring
         |                |                  |        |- com
         |                |                  |              |- <project>
         |                |                  |                             |- <module>
         |                |                  |                                        |- ... spring files
         |                |                  |- liquibase
         |                |                  |           |- com
         |                |                  |                 |- <project>
         |                |                  |                                |- <module>
         |                |                  |                                           |- ... liquibase files
         |                |                  |- <resource type>
         |                |                                    |- etc...
         |                |- test
         |                       |- java
         |                       |      |- com
         |                       |            |- <project>
         |                       |                           |- <module>
         |                       |                                      |- func
         |                       |                                      |      |- ... classes
         |                       |                                      |- integ
         |                       |                                      |       |- ... classes
         |                       |                                      |- unit
         |                       |                                             |- ... classes
         |                       |- resources
         |                                   |- <resource type>
         |                                   |                 |- com
         |                                   |                       |- <project>
         |                                   |                                      |- <module>
         |                                   |                                                 |- func
         |                                   |                                                 |      |- ... classes
         |                                   |                                                 |- integ
         |                                   |                                                 |       |- ... classes
         |                                   |                                                 |- unit
         |                                   |                                                        |- ... classes
         |                                   |- <resource type>
         |                                                     |- etc...
         |- <module>
                    |- pom.xml
                    |- etc...