Relations between Layers, Technologies and source directories

The expanders support multiple stacks of technologies. The selection of the technology stack has effect on one or more layers in 2 ways:

  1. Artifacts are generated for a certain stack and layer
  2. Source folders have to be generated for generated and external files and registered by the build tool

Current state

In versions <3.2.2 this was made possible by a combination of hard-coded config files and an enum ExpansionTarget:

public enum ExpansionTarget {

  // @formatter:off
  VIEW_ROOT               (VIEW_LAYER,    null,     null),
  VIEW_MAVEN              (VIEW_LAYER,  MAVEN,    null),
  VIEW_ANT                (VIEW_LAYER,  ANT,    null),
  VIEW_KNOCKOUT_HTML      (VIEW_LAYER,    KNOCKOUT, HTML),
  VIEW_KNOCKOUT_JSP       (VIEW_LAYER,    KNOCKOUT, JSP),
  VIEW_KNOCKOUT_JS        (VIEW_LAYER,    KNOCKOUT, JS),
  VIEW_KNOCKOUT_JSON      (VIEW_LAYER,    KNOCKOUT, JSON),

  VIEW_STRUTS2_JSP        (VIEW_LAYER,    STRUTS2, JSP),
  VIEW_STRUTS2_JS         (VIEW_LAYER,    STRUTS2, JS),

  VIEW_COCOON2_JSP        (VIEW_LAYER,    COCOON2, JSP),
  VIEW_COCOON2_JS         (VIEW_LAYER,    COCOON2, JS),

  CONTROL_ROOT            (CONTROL_LAYER, null,    null),
  CONTROL_MAVEN           (CONTROL_LAYER,  MAVEN,    null),
  CONTROL_ANT             (CONTROL_LAYER,  ANT,    null),
  CONTROL_COMMON_SRC      (CONTROL_LAYER, COMMON,  SRC),
  CONTROL_COMMON_RESOURCE (CONTROL_LAYER, COMMON,  RESOURCE),
  CONTROL_COMMON_LIB      (CONTROL_LAYER, COMMON,  LIB),

  CONTROL_STRUTS2_SRC     (CONTROL_LAYER, STRUTS2, SRC),
  CONTROL_STRUTS2_RESOURCE(CONTROL_LAYER, STRUTS2, RESOURCE),
  CONTROL_STRUTS2_LIB     (CONTROL_LAYER, STRUTS2, LIB),
  \\ ...
}

note the repetition of some patterns (JSP-JS, SRC-RESOURCE-LIB). Maven and Ant are, not unexpectedly, present in every layer.

Layers and technologies

Each layer is created for a single concern (logic handles transactions, view handles the client, control exposes the backend for these clients etc.)

Each concern is typically handled by a technology. There are also variations in technology for each layer. E.g. the View layer can be implemented with Knockout, Struts or Cocoon. So it would seem the relation between layers and technologies is OneToMany (one layer can be implemented with one of a number of technologies.)

However, some technologies appear in multiple layers. E.g. Struts can be used to implement both the View and Control layer. This means the relation is not purely OneToMany, but rather ManyToMany. Often with a ManyToMany relation, the model is simplified by introducing a third concept that has a OneToMany relation with both parties.

Technologies and SourceTypes

When a technology is used to implement the logic of a layer, it's artifacts are generated of placed in a number of different source directories. The most common example of this is the src and resources folders in most layers.

Typically, a technology has a set number of source types required to implement it.

However, in some cases the source directories used by a technology differ for each layer the technology is used in. This is most apparent in the View layer, where there are no src directories and sourceTypes such as Jsp and Js are introduced.

Layer implementations

Most of the issues spring from the dual nature of some Technologies and can be simplified by looking at the application of a technology to different layers as different instances. This aligns well with the concept of a third entity mentioned above.

In more concrete terms, this would mean introducing a LayerImplementation concept. This separates for example Struts:View in the View layer and Struts:MVC in the Control layer as well as enumerating all possible implementations for a specific layer.

Technology languages and implementations

When applied, each LayerImplementation has only 1 set of source directories:

  • Struts:View uses js and jsp directories
  • Knockout:View uses html, js and jsp directories
  • Struts:MVC uses src and resources directories

Finally, these stacks are used in LayerImplementations, but each stack can be used over multiple implementations and layers. The relation linking a specific LayerImplementation to a source stack can be represented with a layerSource element.

Diagrams

The following relationship diagram shows the simplified model:

relations

Next, these diagrams show some examples of how the introduced elements simplify the links between technologies, layers and sourceTypes:

layers: examples

layers: examples

results matching ""

    No results matching ""